35 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
37 $this->selectMock = $this->createPartialMock(
38 \
Magento\Framework\DB\Select::class,
39 [
'orWhere',
'where',
'setPart',
'getPart']
41 $this->mapperFactoryMock = $this->createPartialMock(\
Magento\Framework\DB\MapperFactory::class, [
'create']);
44 \
Magento\Framework\DB\GenericMapper::class,
46 'select' => $this->selectMock,
47 'mapperFactory' => $this->mapperFactoryMock,
59 $criteriaMock = $this->getMockForAbstractClass(
60 \
Magento\Framework\Api\CriteriaInterface::class,
66 [
'getMapperInterfaceName']
68 $mapperInstanceMock = $this->getMockForAbstractClass(
69 \
Magento\Framework\DB\MapperInterface::class,
78 $criteriaMock->expects($this->any())
79 ->method(
'getMapperInterfaceName')
80 ->will($this->returnValue(
'mapper-name'));
81 $this->mapperFactoryMock->expects($this->exactly(4))
83 ->with(
'mapper-name', [
'select' => $this->selectMock])
84 ->will($this->returnValue($mapperInstanceMock));
85 $mapperInstanceMock->expects($this->exactly(4))
87 ->will($this->returnValue($this->selectMock));
89 $this->geneticMapper->mapCriteriaList(array_fill(0, 4, $criteriaMock));
97 public function testMapFilters()
102 'field' =>
'test-field',
103 'condition' =>
'test-condition',
107 'field' =>
'test-field',
108 'condition' =>
'test-condition' 112 'field' =>
'test-field',
113 'condition' =>
'test-condition' 117 'field' =>
'test-field',
118 'condition' =>
'test-condition' 122 $connectionMock = $this->getMockForAbstractClass(
123 \
Magento\Framework\DB\Adapter\AdapterInterface::class,
129 [
'quoteInto',
'prepareSqlCondition']
134 $this->createPartialMock(\
Magento\Framework\DB\GenericMapper::class, [
'getConnection',
'getSelect']);
137 ->method(
'getConnection')
138 ->will($this->returnValue($connectionMock));
140 ->method(
'getSelect')
141 ->will($this->returnValue($this->selectMock));
142 $connectionMock->expects($this->exactly(2))
143 ->method(
'quoteInto')
144 ->with(
'test-field=?',
'test-condition')
145 ->will($this->returnValue(
'test-condition'));
146 $this->selectMock->expects($this->once())
148 ->with(
'test-condition');
149 $this->selectMock->expects($this->exactly(3))
151 ->with(
'test-condition');
152 $connectionMock->expects($this->any())
153 ->method(
'prepareSqlCondition')
154 ->with(
'test-field',
'test-condition')
155 ->will($this->returnValue(
'test-condition'));
165 public function testMapFields()
169 'test-correlation-name',
174 'test-correlation-name',
179 'test-correlation-name',
186 $geneticMapper = $this->createPartialMock(\
Magento\Framework\DB\GenericMapper::class, [
'getSelect']);
189 ->method(
'getSelect')
190 ->will($this->returnValue($this->selectMock));
191 $this->selectMock->expects($this->once())
195 $this->selectMock->expects($this->once())