function testVisitingWhileLoggedIn() { $client = static::createClient(); // get or create the user somehow (e.g. creating some users only // for tests while loading the test fixtures) $userRepository = static::$container->get(UserRepository::class); $testUser = $userRepository->findOneByEmail('
[email protected]'); $client->loginUser($testUser); // user is now logged in, so you can test protected resources $client->request('GET', '/profile'); $this->assertResponseIsSuccessful(); $this->assertSelectorTextContains('h1', 'Hello Username!'); }