コード例 #1
0
 public function testGetMessages()
 {
     $messageCollection = $this->getMockBuilder('Magento\\Framework\\Message\\Collection')->disableOriginalConstructor()->setMethods(['addMessage'])->getMock();
     $this->messagesFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($messageCollection));
     $this->session->expects($this->at(0))->method('getData')->with(ManagerInterface::DEFAULT_GROUP)->will($this->returnValue(null));
     $this->session->expects($this->at(1))->method('setData')->with(ManagerInterface::DEFAULT_GROUP, $messageCollection)->will($this->returnValue($this->session));
     $this->session->expects($this->at(2))->method('getData')->with(ManagerInterface::DEFAULT_GROUP)->will($this->returnValue($messageCollection));
     $this->eventManager->expects($this->never())->method('dispatch');
     $this->assertEquals($messageCollection, $this->model->getMessages());
 }
コード例 #2
0
 public function test_aroundGetReport()
 {
     /** === Test Data === */
     $REQUEST_NAME = \Praxigento\Core\Config::DS_CUSTOMERS_GRID;
     /** === Setup Mocks === */
     $mResult = $this->_mock(\Magento\Customer\Model\ResourceModel\Grid\Collection::class);
     $mProceed = function () use($mResult) {
         return $mResult;
     };
     // $this->_subQueryModifier->populateSelect($result);
     $this->mSubQueryModifier->shouldReceive('populateSelect')->once();
     // $this->_subQueryModifier->addFieldsMapping($result);
     $this->mSubQueryModifier->shouldReceive('addFieldsMapping')->once();
     /** === Call and asserts  === */
     $res = $this->obj->aroundGetReport($this->mSubject, $mProceed, $REQUEST_NAME);
     $this->assertTrue($res instanceof \Magento\Customer\Model\ResourceModel\Grid\Collection);
 }
コード例 #3
0
 public function test_aroundGetReport()
 {
     /** === Test Data === */
     $REQUEST_NAME = \Praxigento\Core\Config::DS_SALES_ORDERS_GRID;
     $RESULT = $this->_mock(\Magento\Sales\Model\ResourceModel\Order\Grid\Collection::class);
     /** === Setup Mocks === */
     $mProceed = function ($dataIn) use($REQUEST_NAME, $RESULT) {
         $this->assertEquals($REQUEST_NAME, $dataIn);
         return $RESULT;
     };
     // $this->_subQueryModifier->populateSelect($result);
     $this->mSubQueryModifier->shouldReceive('populateSelect')->once()->with($RESULT);
     // $this->_subQueryModifier->addFieldsMapping($result);
     $this->mSubQueryModifier->shouldReceive('addFieldsMapping')->once()->with($RESULT);
     /** === Call and asserts  === */
     $res = $this->obj->aroundGetReport($this->mSubject, $mProceed, $REQUEST_NAME);
     $this->assertEquals($RESULT, $res);
 }
コード例 #4
0
 public function test_aroundCreate()
 {
     /** === Test Data === */
     $DATA = [];
     $RESULT = $this->_mock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
     /** === Setup Mocks === */
     $mProceed = function ($dataIn) use($DATA, $RESULT) {
         $this->assertEquals($DATA, $dataIn);
         return $RESULT;
     };
     // $query = $result->getSelect();
     $mQuery = $this->_mockDbSelect();
     $RESULT->shouldReceive('getSelect')->once()->andReturn($mQuery);
     // $tbl = [self::AS_TBL_PROD_PV => $this->_resource->getTableName(Product::ENTITY_NAME)];
     $this->mResource->shouldReceive('getTableName')->once()->andReturn('TABLE');
     // $query->joinLeft($tbl, $on, $cols);
     $mQuery->shouldReceive('joinLeft')->once();
     // $result->addFilterToMap(self::AS_FLD_PV, self::FULL_PV);
     // $result->addFilterToMap('`e`.`' . self::AS_FLD_PV . '`', self::FULL_PV);
     $RESULT->shouldReceive('addFilterToMap')->twice();
     /** === Call and asserts  === */
     $res = $this->obj->aroundCreate($this->mSubject, $mProceed, $DATA);
     $this->assertEquals($RESULT, $res);
 }