Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractCollectionTest.php
Go to the documentation of this file.
1 <?php
8 
9 class AbstractCollectionTest extends \PHPUnit\Framework\TestCase
10 {
16  protected $collection;
17 
18  protected function setUp()
19  {
20  $entityFactory = $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class);
21  $logger = $this->createMock(\Psr\Log\LoggerInterface::class);
22  $fetchStrategy = $this->createMock(\Magento\Framework\Data\Collection\Db\FetchStrategy\Query::class);
23  $eventManager = $this->createMock(\Magento\Framework\Event\Manager::class);
24  $connection = $this->createMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class);
25 
26  $resource = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class)
27  ->disableOriginalConstructor()
28  ->setMethods(['getConnection'])
29  ->getMockForAbstractClass();
30  $resource->method('getConnection')->willReturn($connection);
31 
32  $this->collection = new \Magento\Reports\Model\ResourceModel\Report\Collection\AbstractCollection(
33  $entityFactory,
34  $logger,
35  $fetchStrategy,
36  $eventManager,
38  $resource
39  );
40  }
41 
42  public function testIsSubtotalsGetDefault()
43  {
44  $this->assertFalse($this->collection->isSubTotals());
45  }
46 
47  public function testSetIsSubtotals()
48  {
49  $this->collection->setIsSubTotals(true);
50  $this->assertTrue($this->collection->isSubTotals());
51 
52  $this->collection->setIsSubTotals(false);
53  $this->assertFalse($this->collection->isSubTotals());
54  }
55 }
$resource
Definition: bulk.php:12
$logger
$connection
Definition: bulk.php:13