I’m working on an integration test that utilizes a custom model and am unable to load the object. Core objects are loading fine. I can create a quote using my own fixture without issue. As far as I can tell, the Account
model and resource model are structured properly.
Consider the following (failing) test:
/**
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @magentoDataFixture loadFixture
*/
public function testOrderProvidesDiscountWithPromo( ) {
\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('frontend');
/** @var Mageplaza\Affiliate\Model\Account $affiliate */
$affiliate = Bootstrap::getObjectManager()->create(Mageplaza\Affiliate\Model\Account::class);
$affiliate->load(1, 'account_id');
$quote = Bootstrap::getObjectManager()->create(\Magento\Quote\Model\Quote::class);
$quote->load('test_promo', 'reserved_order_id');
$this->assertEquals(1, $affiliate->getData('account_id'));
}
The affiliate
account is created using the following fixture:
\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('frontend');
/** @var Mageplaza\Affiliate\Model\Account $affiliate */
$affiliate = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(Mageplaza\Affiliate\Model\Account::class);
$affiliate->setAccountId(1)
->setCustomerId(1)
->setCode('mycode')
->setGroupId(1)
->setBalance(0)
->setStatus(1)
->setTree(1);
$affiliate->save();
The $quote
object is loading properly but the $affiliate
one is not.
Can anyone see what I may be doing wrong or are there any extra steps that must be taken to ensure that the custom model loads properly as well?
(I'm using Magento 2.2 for what it’s worth)