Doctrine orm Codeception/Doctrine2:调用&x27;从存储库抓取数据';在'之前;可参见存储';导致后者破裂
奇怪的一个。我正在使用Codeception和Symfony4/Doctrine2测试RESTAPI 如果测试有一个对Doctrine orm Codeception/Doctrine2:调用&x27;从存储库抓取数据';在'之前;可参见存储';导致后者破裂,doctrine-orm,codeception,symfony4,Doctrine Orm,Codeception,Symfony4,奇怪的一个。我正在使用Codeception和Symfony4/Doctrine2测试RESTAPI 如果测试有一个对$I->canSeeInRepository(…)的调用,工作正常 但是,如果我调用$I->grabEntityFromRepository(…)(工作正常)在进行此调用之前,$I->canSeeInRepository(…)调用失败 这似乎是一个理论问题 有人能解释一下吗?非常感谢 /** * @param ApiTester $I */ public function t
$I->canSeeInRepository(…)的调用代码>,工作正常
但是,如果我调用$I->grabEntityFromRepository(…)
(工作正常)在进行此调用之前,$I->canSeeInRepository(…)代码>调用失败
这似乎是一个理论问题
有人能解释一下吗?非常感谢
/**
* @param ApiTester $I
*/
public function testConvertOfferToTemplate(ApiTester $I)
{
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
/** @var \App\ServiceProviderBundle\Entity\Offer $offer */
$offer = $I->grabEntityFromRepository(\App\ServiceProviderBundle\Entity\Offer::class, [
'notes' => 'SOME NOTES - Custom Offer final draft',
'dateArchived' => null,
]);
$I->sendPOST('/offer-templates', json_encode([
'name' => 'Codeception Created Template From Offer',
'offer_id' => $offer->getId(),
]));
$json = array(
'offer_template' =>
array(
'name' => 'Codeception Created Template From Offer',
'charge_period' => $offer->getChargePeriod(),
'charge_amount' => $offer->getChargeAmount(),
'charge_currency' => $offer->getChargeCurrency(),
'terms' => $offer->getTerms(),
'_embedded' =>
array(),
),
);
$I->seeResponseContainsJson($json);
$I->canSeeInRepository(\App\ServiceProviderBundle\Entity\OfferTemplate::class, [
'name' => 'Codeception Created Template From Offer', // FAILS
]);
}
/**
* @param ApiTester $I
*/
public function testOfferCreatedFromTemplate(ApiTester $I)
{
$I->canSeeInRepository(\App\ServiceProviderBundle\Entity\OfferTemplate::class, [
'name' => 'Codeception Created Template From Offer', // PASSES
]);
}
怎么会失败?非常感谢你回复我。基本上,如果在调用“grabEntityFromRepository”后在同一测试中调用“canSeeInRepository”,它将返回false。如果我立即在单独的测试中调用它(完全相同的代码),那么它将返回true。我已经添加了上面使用的代码-注意标记为“FAILS”和“PASSES”的行(相同的代码)