Based on the above code you mentioned, you need to create a Account, Contact and user.
account acc1=new account();
Contact c1=new contact();
the only reason you are getting null in the query is because you might be creating an user but didn't tag the contactId to the user record( assuming you are creating a portal user and have portal user license)
Use below code to create an user and your query will return results.
Note:I'm assuming you have below profile name in your org as it's one of standard profile for a portal user (refer this link)
Profile p = [SELECT Id FROM Profile WHERE Name='Customer Portal User'];
User u = new User(Alias = 'testUser', Emailfirstname.lastname@example.org',
EmailEncodingKey='UTF-8', LastName='Test', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = p.Id,
TimeZoneSidKey='America/Los_Angeles',contactid=c1.id, Username = 'testU@a.com' + System.currentTimeMillis());
your final test class code will look like this