Skip to content

Commit

Permalink
Rewrite to have one test using a dataprovider
Browse files Browse the repository at this point in the history
  • Loading branch information
michielgerritsen committed Oct 13, 2017
1 parent 9ee464c commit 8e843ad
Showing 1 changed file with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,38 @@
*/
class StatusTest extends \PHPUnit\Framework\TestCase
{
/**
* In the backend the regular label must be showed.
*
* @magentoDataFixture Magento/Sales/_files/order_status.php
*/
public function testTheLabelIsUsedInTheBackend()
public function theCorrectLabelIsUsedDependingOnTheAreaProvider()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$objectManager->get(\Magento\Framework\App\State::class)->setAreaCode('adminhtml');

/** @var \Magento\Sales\Model\Order $order */
$order = $objectManager->create(\Magento\Sales\Model\Order::class);
$order->loadByIncrementId('100000001');

$this->assertEquals('Example', $order->getStatusLabel());
return [
'backend label' => [
'adminhtml',
'Example',
],
'store view label' => [
'frontend',
'Store view example',
],
];
}

/**
* In the frontend the store view specific label must be showed.
* In the backend the regular label must be showed.
*
* @param $area
* @param $result
*
* @magentoDataFixture Magento/Sales/_files/order_status.php
* @dataProvider theCorrectLabelIsUsedDependingOnTheAreaProvider
*/
public function testTheStoreViewLabelIsUsedInTheFrontend()
public function testTheCorrectLabelIsUsedDependingOnTheArea($area, $result)
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$objectManager->get(\Magento\Framework\App\State::class)->setAreaCode('frontend');
$objectManager->get(\Magento\Framework\App\State::class)->setAreaCode('adminhtml');

/** @var \Magento\Sales\Model\Order $order */
$order = $objectManager->create(\Magento\Sales\Model\Order::class);
$order->loadByIncrementId('100000001');

$this->assertEquals('Store view example', $order->getStatusLabel());
$this->assertEquals('Example', $order->getStatusLabel());
}
}

0 comments on commit 8e843ad

Please sign in to comment.