-
Notifications
You must be signed in to change notification settings - Fork 381
Closed
Description
Blameable doesn't detects user in Unit Tests too. My code:
public function testAddEntity() {
$client = static::createClient();
$client->request('GET', '/admin/');
$container = $client->getContainer();
$doctrine = $container->get('doctrine');
$user = $this->loadUser($doctrine, $username); // returns User Entity object
$request = $client->getRequest();
$token = new UsernamePasswordToken($user, $user->getPassword(), "main", $user->getRoles());
$container->get("security.context")->setToken($token);
$event = new InteractiveLoginEvent($request, $token);
$container->get("event_dispatcher")->dispatch("security.interactive_login", $event);
$this->assertTrue( $client->getContainer()->get('security.context')->isGranted('ROLE_ADMIN') ); // correct, user is logged
$newEntity = new Post;
$this->em->persist($newEntity);
$this->em->flush(); // error: Integrity constraint violation: 1048 Column 'created_by' cannot be null
}
I've tried this method of authentication (above) and standard HTTP authentication, but there is always MySQL error when I try to flush.
Metadata
Metadata
Assignees
Labels
No labels