2 replaced http://magento.stackexchange.com/ with https://magento.stackexchange.com/
source | link

I was not about to get @joni's fix working with the exact same code that @vinai uses in the video. Since i ran into the exact same problem, i wanted to post what i was able to get working for me.

The call to Magento\Framework\TestFramework\Unit\Helper\ObjectManager does correctly bring in the right ObjectManager, but this class works very differently then how the Magento\TestFramework\ObjectManager works. The outline of the difference is explained by @Marius here:

http://magento.stackexchange.com/questions/96192/how-to-obtain-the-object-manager-in-unit-testsHow to obtain the Object Manager in Unit-Tests?

For me i was able to get the tests working with this code:

public function testTheModuleIsConfiguredAndEnabled()
{

    $objectManager = new ObjectManager($this);

    $moduleList = $objectManager->getObject(ModuleList::class);

    $this->assertTrue($moduleList->has($this->moduleName));
}

The main difference here is that you are calling in the object manager and passing the current class into it with $this. You then get a list of all the modules in the same way, but with the method getObject instead of create. After these changes the test worked for me.

I was not about to get @joni's fix working with the exact same code that @vinai uses in the video. Since i ran into the exact same problem, i wanted to post what i was able to get working for me.

The call to Magento\Framework\TestFramework\Unit\Helper\ObjectManager does correctly bring in the right ObjectManager, but this class works very differently then how the Magento\TestFramework\ObjectManager works. The outline of the difference is explained by @Marius here:

http://magento.stackexchange.com/questions/96192/how-to-obtain-the-object-manager-in-unit-tests

For me i was able to get the tests working with this code:

public function testTheModuleIsConfiguredAndEnabled()
{

    $objectManager = new ObjectManager($this);

    $moduleList = $objectManager->getObject(ModuleList::class);

    $this->assertTrue($moduleList->has($this->moduleName));
}

The main difference here is that you are calling in the object manager and passing the current class into it with $this. You then get a list of all the modules in the same way, but with the method getObject instead of create. After these changes the test worked for me.

I was not about to get @joni's fix working with the exact same code that @vinai uses in the video. Since i ran into the exact same problem, i wanted to post what i was able to get working for me.

The call to Magento\Framework\TestFramework\Unit\Helper\ObjectManager does correctly bring in the right ObjectManager, but this class works very differently then how the Magento\TestFramework\ObjectManager works. The outline of the difference is explained by @Marius here:

How to obtain the Object Manager in Unit-Tests?

For me i was able to get the tests working with this code:

public function testTheModuleIsConfiguredAndEnabled()
{

    $objectManager = new ObjectManager($this);

    $moduleList = $objectManager->getObject(ModuleList::class);

    $this->assertTrue($moduleList->has($this->moduleName));
}

The main difference here is that you are calling in the object manager and passing the current class into it with $this. You then get a list of all the modules in the same way, but with the method getObject instead of create. After these changes the test worked for me.

1
source | link

I was not about to get @joni's fix working with the exact same code that @vinai uses in the video. Since i ran into the exact same problem, i wanted to post what i was able to get working for me.

The call to Magento\Framework\TestFramework\Unit\Helper\ObjectManager does correctly bring in the right ObjectManager, but this class works very differently then how the Magento\TestFramework\ObjectManager works. The outline of the difference is explained by @Marius here:

http://magento.stackexchange.com/questions/96192/how-to-obtain-the-object-manager-in-unit-tests

For me i was able to get the tests working with this code:

public function testTheModuleIsConfiguredAndEnabled()
{

    $objectManager = new ObjectManager($this);

    $moduleList = $objectManager->getObject(ModuleList::class);

    $this->assertTrue($moduleList->has($this->moduleName));
}

The main difference here is that you are calling in the object manager and passing the current class into it with $this. You then get a list of all the modules in the same way, but with the method getObject instead of create. After these changes the test worked for me.