Esempio n. 1
0
 /**
  * @magentoDataFixture Magento/SalesRule/_files/order_with_coupon.php
  * @magentoDataFixture Magento/SalesRule/_files/report_coupons.php
  */
 public function testGetItems()
 {
     $expectedResult = array(array('coupon_code' => '1234567890', 'coupon_uses' => 1));
     $actualResult = array();
     /** @var \Magento\Reports\Model\Item $reportItem */
     foreach ($this->_collection->getItems() as $reportItem) {
         $actualResult[] = array_intersect_key($reportItem->getData(), $expectedResult[0]);
     }
     $this->assertEquals($expectedResult, $actualResult);
 }
 public function testApplyRulesFilterWithRulesList()
 {
     $rulesList = [1 => 'test rule 1', 10 => 'test rule 10', 30 => 'test rule 30'];
     $this->connection->expects($this->at(1))->method('quoteInto')->with($this->equalTo('rule_name = ?'), $this->equalTo($rulesList[1]))->will($this->returnValue('test_1'));
     $this->connection->expects($this->at(2))->method('quoteInto')->with($this->equalTo('rule_name = ?'), $this->equalTo($rulesList[30]))->will($this->returnValue('test_2'));
     $this->selectMock->expects($this->at(3))->method('where')->with($this->equalTo(implode(['test_1', 'test_2'], ' OR ')));
     $ruleMock = $this->getRuleMock();
     $ruleMock->expects($this->once())->method('getUniqRulesNamesList')->will($this->returnValue($rulesList));
     $this->ruleFactory->expects($this->once())->method('create')->will($this->returnValue($ruleMock));
     $ruleFilter = [1, 2, 30];
     $this->object->addRuleFilter($ruleFilter);
     $this->assertInstanceOf(get_class($this->object), $this->object->loadWithFilter());
 }