/** * Negative test */ public function testGetFilterNegativeApply() { $this->applierMock->expects($this->never())->method('apply')->willReturn(true); $this->appliersPoolMock->expects($this->once())->method('getApplier')->willReturn($this->applierMock); $mapper = new FilterMapper($this->appliersPoolMock, $this->braintreeSearchAdapterMock); $result = $mapper->getFilter('orderId', []); $this->assertEquals(null, $result); }
/** * @inheritdoc */ public function addFieldToFilter($field, $condition) { if (is_array($field)) { return $this; } if (!is_array($condition)) { $condition = ['eq' => $condition]; } $this->addFilterToList($this->filterMapper->getFilter($field, $condition)); return $this; }
/** * Get items with limit */ public function testGetItemsWithNullLimit() { $transations = range(1, TransactionsCollection::TRANSACTION_MAXIMUM_COUNT + 10); $this->filterMapperMock->expects($this->once())->method('getFilter')->willReturn(new BraintreeSearchNodeStub()); $this->braintreeAdapterMock->expects($this->once())->method('search')->willReturn($transations); $this->entityFactoryMock->expects($this->exactly(TransactionsCollection::TRANSACTION_MAXIMUM_COUNT))->method('create')->willReturn($this->transactionMapMock); $collection = new TransactionsCollection($this->entityFactoryMock, $this->braintreeAdapterMock, $this->filterMapperMock); $collection->setPageSize(null); $collection->addFieldToFilter('orderId', ['like' => '0']); $items = $collection->getItems(); $this->assertEquals(TransactionsCollection::TRANSACTION_MAXIMUM_COUNT, count($items)); $this->assertInstanceOf(DocumentInterface::class, $items[1]); }