コード例 #1
0
 /**
  * @expectedExcpetion \Magento\Framework\Exception\NoSuchEntityException
  * @expectedExceptionMessage No such entity with cartId = 15
  */
 public function testGetWithExceptionByIsActive()
 {
     $cartId = 15;
     $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock);
     $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->once())->method('getId')->willReturn($this->storeMock);
     $this->quoteMock->expects($this->never())->method('setSharedStoreIds');
     $this->quoteMock->expects($this->once())->method('load')->with($cartId)->willReturn($this->storeMock);
     $this->quoteMock->expects($this->once())->method('getId')->willReturn($cartId);
     $this->quoteMock->expects($this->once())->method('getIsActive')->willReturn(0);
     $this->model->get($cartId);
 }
コード例 #2
0
 public function testGetActiveForCustomer()
 {
     $cartId = 17;
     $customerId = 23;
     $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock);
     $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->once())->method('getId')->willReturn(1);
     $this->quoteMock->expects($this->never())->method('setSharedStoreIds');
     $this->quoteMock->expects($this->once())->method('loadByCustomer')->with($customerId)->willReturn($this->storeMock);
     $this->quoteMock->expects($this->exactly(2))->method('getId')->willReturn($cartId);
     $this->quoteMock->expects($this->exactly(2))->method('getIsActive')->willReturn(1);
     $this->assertEquals($this->quoteMock, $this->model->getActiveForCustomer($customerId));
     $this->assertEquals($this->quoteMock, $this->model->getActiveForCustomer($customerId));
 }
コード例 #3
0
ファイル: QuoteTest.php プロジェクト: Doability/magento2dev
 /**
  * Run test getQuote method
  *
  * @return void
  * @dataProvider getQuoteDataProvider
  */
 public function testGetQuoteWithQuoteId($customerId, $quoteCustomerId, $expectedNumberOfInvokes)
 {
     $quoteId = 22;
     $storeId = 10;
     $this->quote->expects($this->any())->method('getQuoteId')->will($this->returnValue($quoteId));
     $this->quote->expects($this->any())->method('setQuoteId')->with($quoteId);
     $this->quote->expects($this->any())->method('getStoreId')->will($this->returnValue($storeId));
     $this->quote->expects($this->any())->method('getCustomerId')->will($this->returnValue($customerId));
     $dataCustomerMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->disableOriginalConstructor()->getMock();
     $this->customerRepositoryMock->expects($this->{$expectedNumberOfInvokes}())->method('getById')->with($customerId)->willReturn($dataCustomerMock);
     $quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', ['setStoreId', 'setCustomerGroupId', 'setIsActive', 'getId', 'assignCustomer', 'setIgnoreOldQty', 'setIsSuperMode', 'getCustomerId', '__wakeup'], [], '', false);
     $quoteMock->expects($this->once())->method('setStoreId')->with($storeId);
     $quoteMock->expects($this->{$expectedNumberOfInvokes}())->method('assignCustomer')->with($dataCustomerMock);
     $quoteMock->expects($this->once())->method('setIgnoreOldQty')->with(true);
     $quoteMock->expects($this->once())->method('setIsSuperMode')->with(true);
     $quoteMock->expects($this->once())->method('getCustomerId')->will($this->returnValue($quoteCustomerId));
     $this->quoteRepositoryMock->expects($this->once())->method('get')->with($quoteId)->willReturn($quoteMock);
     $this->assertEquals($quoteMock, $this->quote->getQuote());
 }