Skip to content

Commit

Permalink
Remove requirements from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chevli committed Mar 29, 2017
1 parent 2ab4e63 commit 51b8e7c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 61 deletions.
62 changes: 2 additions & 60 deletions Test/Unit/Component/WidgetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,18 @@
namespace CtiDigital\Configurator\Test\Unit\Component;

use CtiDigital\Configurator\Model\Component\Widgets;
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
use Magento\Framework\Data\Collection\EntityFactoryInterface;
use Magento\Framework\Event\ManagerInterface;
use Magento\Store\Model\StoreFactory;
use Magento\Widget\Model\ResourceModel\Widget\Instance\Collection as WidgetCollection;
use Magento\Theme\Model\ResourceModel\Theme\Collection as ThemeCollection;
use Psr\Log\LoggerInterface;

class WidgetsTest extends ComponentAbstractTestCase
{
/**
* Test 'where' condition for assertion
*/
const TEST_WHERE_CONDITION = 'condition = 1';

protected function componentSetUp()
{
$entityFactory = $this->getMock(EntityFactoryInterface::class);
$logger = $this->getMock(LoggerInterface::class);
$fetchStrategy = $this->getMock(FetchStrategyInterface::class);
$eventManager = $this->getMock(ManagerInterface::class);

$widgetSelect = $this->getMock('Magento\Framework\DB\Select', [], [], '', false);
$themeSelect = $this->getMock('Magento\Framework\DB\Select', [], [], '', false);
$widgetSelect->expects($this->any())->method('where')->with(self::TEST_WHERE_CONDITION);
$themeSelect->expects($this->any())->method('where')->with(self::TEST_WHERE_CONDITION);
$widgetResource = $this->getResource($widgetSelect);
$themeResource = $this->getResource($themeSelect);

$widgetArguments = array($entityFactory, $logger, $fetchStrategy, $eventManager, null, $widgetResource);
$themeArguments = array($entityFactory, $logger, $fetchStrategy, $eventManager, null, $themeResource);
$methods = array('getConnection');

$storeFactory = $this->getMock(StoreFactory::class);
$widgetCollection = $this->getMockBuilder(WidgetCollection::class)
->setConstructorArgs($widgetArguments)
->setMethods($methods)
->getMock();

$themeCollection = $this->getMockBuilder(ThemeCollection::class)
->setConstructorArgs($themeArguments)
->setMethods($methods)
->getMock();
$widgetCollection = $this->getMock(WidgetCollection::class, [], [], '', false);
$themeCollection = $this->getMock(ThemeCollection::class, [], [], '', false);

$this->component = new Widgets(
$this->logInterface,
Expand All @@ -56,31 +25,4 @@ protected function componentSetUp()
);
$this->className = Widgets::class;
}

/**
* Retrieve resource model instance
*
* @param \Magento\Framework\DB\Select $select
* @return \PHPUnit_Framework_MockObject_MockObject
*/
protected function getResource(\Magento\Framework\DB\Select $select)
{
$connection = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false);
$connection->expects($this->once())->method('select')->will($this->returnValue($select));
$connection->expects($this->any())->method('quoteIdentifier')->will($this->returnArgument(0));

$resource = $this->getMockForAbstractClass(
'Magento\Framework\Model\ResourceModel\Db\AbstractDb',
[],
'',
false,
true,
true,
['getConnection', 'getMainTable', 'getTable', '__wakeup']
);
$resource->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
$resource->expects($this->any())->method('getTable')->will($this->returnArgument(0));

return $resource;
}
}
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"php": "~5.6.0|~7.0.0",
"symfony/yaml": ">2.8.0",
"magento/framework": "100.1.*",
"magento/zendframework1": "1.12.16",
"firegento/fastsimpleimport": "1.0.0"
},
"require-dev": {
Expand Down

0 comments on commit 51b8e7c

Please sign in to comment.