You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a strange behavior with POST tests with my API and Behat.
My project is a symfony2 project.
I have an entity with a token field which is the identifier (with a customid generator which generates random token).
To simplify the tests, i force the idgenerator of entity to an other which generate id (1, 2, 3 ...) in the FeatureContext of Behat. It works on every test (GET, PUT, POST, ... of my API).
In one of my post tests, i try to do 3 posts in one scenario and get the entity with GET /entity/1, entity/2, entity/3. On the first post, the entity is created and the token is an id generated by the generator defined in FeatureContext. On the second and third post, entity is created but the token is generated by the generator defined in entity and not in FeatureContext.
public function __construct(ManagerRegistry $doctrine)
{
$this->doctrine = $doctrine;
$this->manager = $doctrine->getManager();
// Disable auto token assignment on Booking class (to use auto id for tests)
$bookingClassMetaData = $this->manager->getClassMetaData('ApiBundle\Entity\Booking');
$bookingClassMetaData->setIdGenerator(new FakeToken());
$this->schemaTool = new SchemaTool($this->manager);
$this->classes = $this->manager->getMetadataFactory()->getAllMetadata();
}
I know it's really specific but i want to know if you have similar issues.
Thanks you,
Best regards,
Dimitri
The text was updated successfully, but these errors were encountered:
Hello,
I have a strange behavior with POST tests with my API and Behat.
My project is a symfony2 project.
I have an entity with a token field which is the identifier (with a customid generator which generates random token).
To simplify the tests, i force the idgenerator of entity to an other which generate id (1, 2, 3 ...) in the FeatureContext of Behat. It works on every test (GET, PUT, POST, ... of my API).
In one of my post tests, i try to do 3 posts in one scenario and get the entity with GET /entity/1, entity/2, entity/3. On the first post, the entity is created and the token is an id generated by the generator defined in FeatureContext. On the second and third post, entity is created but the token is generated by the generator defined in entity and not in FeatureContext.
My entity :
The construct function of FeatureContext loaded :
I know it's really specific but i want to know if you have similar issues.
Thanks you,
Best regards,
Dimitri
The text was updated successfully, but these errors were encountered: