18 $this->_condition = $this->getMockForAbstractClass(
19 \
Magento\Rule\Model\Condition\AbstractCondition::class,
31 $this->_condition->setAttribute(
'category_ids');
32 $this->assertEquals([], $this->_condition->getTablesToJoin());
33 $this->_condition->setAttribute(
'gdsjkfghksldjfg');
34 $this->assertEmpty($this->_condition->getTablesToJoin());
39 $this->_condition->setAttribute(
'category_ids');
40 $this->assertEquals(
'category_ids', $this->_condition->getMappedSqlField());
50 [1,
'==', new \stdClass(),
false],
51 [new \stdClass(),
'==', new \stdClass(),
false],
55 [
'0',
'==', 1,
false],
57 [
'x',
'==',
'x',
true],
58 [
'x',
'==', 0,
false],
63 [
'1',
'!=', 1,
false],
64 [
'x',
'!=',
'x',
false],
68 [1,
'!=', [1],
false],
69 [1,
'==', [3, 1, 5],
false],
70 [1,
'!=', [1, 5],
true],
72 [[1,2,3],
'==',
'1,2,3',
false],
73 [[1],
'==', 1,
false],
101 $this->_condition->setOperator($operator);
102 $this->_condition->setData(
'value_parsed', $existingValue);
105 $this->_condition->validateAttribute($valueForValidate),
106 "Failed asserting that " 107 . var_export($existingValue,
true)
109 . var_export($valueForValidate,
true)
121 public function testValidate($existingValue, $operator, $valueForValidate, $expectedResult)
123 $objectMock = $this->createPartialMock(
124 \
Magento\Framework\Model\AbstractModel::class,
125 [
'hasData',
'load',
'getId',
'getData']
127 $objectMock->expects($this->once())
130 $objectMock->expects($this->once())
133 $objectMock->expects($this->once())
136 $objectMock->expects($this->once())
138 ->willReturn($valueForValidate);
140 $this->_condition->setOperator($operator);
141 $this->_condition->setData(
'value_parsed', $existingValue);
144 $this->_condition->validate($objectMock),
145 "Failed asserting that " 146 . var_export($existingValue,
true)
148 . var_export($valueForValidate,
true)
159 [[1, 2, 3],
'==', [2, 1, 3],
true,
'multiselect'],
160 [[1, 2],
'==', [2, 3],
true,
'multiselect'],
161 [[1, 1, 3],
'==', [2, 4],
false,
'multiselect'],
162 [[1, 2],
'!=', [2, 3],
false,
'multiselect'],
163 [[1, 2],
'!=', 1,
false,
'multiselect'],
165 [[1, 2, 3],
'{}',
'1',
true,
'grid'],
166 [[1, 2, 3],
'{}',
'8',
false,
'grid'],
167 [[1, 2, 3],
'{}', 5,
false,
'grid'],
168 [[1, 2, 3],
'{}', [2, 3, 4],
true,
'grid'],
169 [[1, 2, 3],
'{}', [4],
false,
'grid'],
170 [[3],
'{}', [],
false,
'grid'],
171 [1,
'{}', 1,
false,
'grid'],
172 [1,
'!{}', [1, 2, 3],
false,
'grid'],
173 [[1],
'{}',
null,
false,
'grid'],
174 [
null,
'{}',
null,
true,
'input'],
175 [
null,
'!{}',
null,
false,
'input'],
176 [
null,
'{}', [1],
false,
'input'],
178 [[1, 2, 3],
'()', 1,
true,
'select'],
179 [[1, 2, 3],
'!()', 1,
false,
'select'],
180 [[1],
'()', 3,
false,
'select'],
181 [[1],
'!()', 3,
true,
'select'],
182 [3,
'()', 3,
false,
'select'],
183 [[3],
'()', [3],
true,
'select'],
184 [3,
'()', [3],
false,
'select'],
205 $this->_condition->setOperator($operator);
206 $this->_condition->setData(
'value_parsed', $existingValue);
207 $this->_condition->getDefaultOperatorInputByType();
209 ->expects($this->any())
210 ->method(
'getInputType')
211 ->will($this->returnValue($inputType));
215 $this->_condition->validateAttribute($valueForValidate),
216 "Failed asserting that " 217 . var_export($existingValue,
true)
219 . var_export($valueForValidate,
true)
225 $value = [1, 2, 3, 4, 5, 6, 7, 8, 9];
226 $this->_condition->setValue([
'1,2,3,4,5,6,7,8,9']);
227 $this->_condition->setOperator(
'()');
228 $this->assertEquals(
$value, $this->_condition->getValueParsed());
validateAttributeDataProvider()
testValidate($existingValue, $operator, $valueForValidate, $expectedResult)
testValidateAttribute($existingValue, $operator, $valueForValidate, $expectedResult)
testValidateArrayOperatorType( $existingValue, $operator, $valueForValidate, $expectedResult, $inputType)
validateAttributeArrayInputTypeDataProvider()