14 use PHPUnit_Framework_MockObject_MockObject as MockObject;
26 private $braintreeAdapterMock;
31 private $adapterFactoryMock;
36 private $entityFactoryMock;
41 private $filterMapperMock;
46 private $transactionMapMock;
53 $this->transactionMapMock = $this->getMockBuilder(DocumentInterface::class)
54 ->disableOriginalConstructor()
57 $this->entityFactoryMock = $this->getMockBuilder(EntityFactoryInterface::class)
58 ->setMethods([
'create'])
59 ->disableOriginalConstructor()
62 $this->filterMapperMock = $this->getMockBuilder(FilterMapper::class)
63 ->setMethods([
'getFilter'])
64 ->disableOriginalConstructor()
67 $this->braintreeAdapterMock = $this->getMockBuilder(BraintreeAdapter::class)
68 ->setMethods([
'search'])
69 ->disableOriginalConstructor()
71 $this->adapterFactoryMock = $this->getMockBuilder(BraintreeAdapterFactory::class)
72 ->disableOriginalConstructor()
74 $this->adapterFactoryMock->method(
'create')
75 ->willReturn($this->braintreeAdapterMock);
83 $this->filterMapperMock->expects($this->once())
87 $this->braintreeAdapterMock->expects($this->once())
89 ->willReturn([
'transaction1',
'transaction2']);
91 $this->entityFactoryMock->expects($this->exactly(2))
93 ->willReturn($this->transactionMapMock);
96 $this->entityFactoryMock,
97 $this->adapterFactoryMock,
98 $this->filterMapperMock
101 $collection->addFieldToFilter(
'orderId', [
'like' =>
'0']);
103 $this->assertEquals(2, count(
$items));
104 $this->assertInstanceOf(DocumentInterface::class,
$items[1]);
112 $this->filterMapperMock->expects($this->once())
113 ->method(
'getFilter')
116 $this->braintreeAdapterMock->expects($this->once())
120 $this->entityFactoryMock->expects($this->never())
122 ->willReturn($this->transactionMapMock);
125 $this->entityFactoryMock,
126 $this->adapterFactoryMock,
127 $this->filterMapperMock
130 $collection->addFieldToFilter(
'orderId', [
'like' =>
'0']);
132 $this->assertEquals(0, count(
$items));
142 $this->filterMapperMock->expects($this->once())
143 ->method(
'getFilter')
146 $this->braintreeAdapterMock->expects($this->once())
152 ->willReturn($this->transactionMapMock);
155 $this->entityFactoryMock,
156 $this->adapterFactoryMock,
157 $this->filterMapperMock
161 $collection->addFieldToFilter(
'orderId', [
'like' =>
'0']);
164 $this->assertInstanceOf(DocumentInterface::class,
$items[1]);
174 $this->filterMapperMock->expects($this->once())
175 ->method(
'getFilter')
178 $this->braintreeAdapterMock->expects($this->once())
184 ->willReturn($this->transactionMapMock);
187 $this->entityFactoryMock,
188 $this->adapterFactoryMock,
189 $this->filterMapperMock
193 $collection->addFieldToFilter(
'orderId', [
'like' =>
'0']);
196 $this->assertInstanceOf(DocumentInterface::class,
$items[1]);
204 public function testAddToFilter($field, $condition, $filterMapperCall, $expectedCondition)
206 $this->filterMapperMock->expects(static::exactly($filterMapperCall))
207 ->method(
'getFilter')
208 ->with($field, $expectedCondition)
212 $this->entityFactoryMock,
213 $this->adapterFactoryMock,
214 $this->filterMapperMock
217 static::assertInstanceOf(
218 TransactionsCollection::class,
231 [
'orderId', [
'like' => 1], 1, [
'like' => 1]],
232 [
'type',
'sale', 1, [
'eq' =>
'sale']],
233 [[
'type',
'orderId'], [], 0, []],
const TRANSACTION_MAXIMUM_COUNT
testGetItemsEmptyCollection()
testGetItemsWithNullLimit()
addToFilterDataProvider()
testAddToFilter($field, $condition, $filterMapperCall, $expectedCondition)