22 private $connectionMock;
27 private $queryGeneratorMock;
32 private $dataConverterMock;
42 private $queryModifierMock;
47 private $selectFactoryMock;
52 private $fieldDataConverter;
57 private $objectManager;
62 $this->connectionMock = $this->createMock(AdapterInterface::class);
63 $this->queryGeneratorMock = $this->createMock(Generator::class);
64 $this->dataConverterMock = $this->createMock(DataConverterInterface::class);
65 $this->selectMock = $this->createMock(Select::class);
66 $this->queryModifierMock = $this->createMock(QueryModifierInterface::class);
67 $this->selectFactoryMock = $this->getMockBuilder(SelectFactory::class)
68 ->disableOriginalConstructor()
70 $this->fieldDataConverter = $this->objectManager->getObject(
71 FieldDataConverter::class,
73 'queryGenerator' => $this->queryGeneratorMock,
74 'dataConverter' => $this->dataConverterMock,
75 'selectFactory' => $this->selectFactoryMock,
85 public function testConvert($useQueryModifier, $numQueryModifierCalls)
90 $where = $field .
' IS NOT NULL';
92 $rows = [1 =>
'value'];
93 $convertedValue =
'converted value';
94 $this->selectFactoryMock->expects($this->once())
96 ->with($this->connectionMock)
97 ->willReturn($this->selectMock);
98 $this->selectMock->expects($this->once())
102 [$identifier, $field]
105 $this->selectMock->expects($this->once())
109 $this->queryModifierMock->expects($this->exactly($numQueryModifierCalls))
111 ->with($this->selectMock);
112 $this->queryGeneratorMock->expects($this->once())
114 ->with($identifier, $this->selectMock)
116 $this->connectionMock->expects($this->once())
117 ->method(
'fetchPairs')
120 $this->dataConverterMock->expects($this->once())
123 ->willReturn($convertedValue);
124 $this->connectionMock->expects($this->once())
128 [$field => $convertedValue],
129 [$identifier .
' IN (?)' => [1]]
131 $this->fieldDataConverter->convert(
132 $this->connectionMock,
136 $useQueryModifier ? $this->queryModifierMock :
null 160 $where = $field .
' IS NOT NULL';
161 $this->selectFactoryMock->expects($this->once())
163 ->with($this->connectionMock)
164 ->willReturn($this->selectMock);
165 $this->selectMock->expects($this->once())
169 [$identifier, $field]
172 $this->selectMock->expects($this->once())
176 $this->queryGeneratorMock->expects($this->once())
178 ->with($identifier, $this->selectMock, $usedBatchSize)
180 $fieldDataConverter = $this->objectManager->getObject(
181 FieldDataConverter::class,
183 'queryGenerator' => $this->queryGeneratorMock,
184 'dataConverter' => $this->dataConverterMock,
185 'selectFactory' => $this->selectFactoryMock,
186 'envBatchSize' => $envBatchSize
189 $fieldDataConverter->convert(
190 $this->connectionMock,
221 $where = $field .
' IS NOT NULL';
222 $this->selectFactoryMock->expects($this->once())
224 ->with($this->connectionMock)
225 ->willReturn($this->selectMock);
226 $this->selectMock->expects($this->once())
230 [$identifier, $field]
233 $this->selectMock->expects($this->once())
237 $fieldDataConverter = $this->objectManager->getObject(
238 FieldDataConverter::class,
240 'queryGenerator' => $this->queryGeneratorMock,
241 'dataConverter' => $this->dataConverterMock,
242 'selectFactory' => $this->selectFactoryMock,
243 'envBatchSize' => $batchSize
246 $fieldDataConverter->convert(
247 $this->connectionMock,
261 [bcadd(PHP_INT_MAX, 1)],
testConvertBatchSizeFromEnvInvalid($batchSize)
testConvert($useQueryModifier, $numQueryModifierCalls)
convertBatchSizeFromEnvInvalidDataProvider()
testConvertBatchSizeFromEnv($envBatchSize, $usedBatchSize)
convertBatchSizeFromEnvDataProvider()