-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
IBX-3856: Changed Checkbox's value to never be considered empty #336
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -306,22 +306,17 @@ public function provideFromHashData() | |||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
public function providerForTestIsEmptyValue() | ||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||
return [ | ||||||||||||||||||||||||||||||||||||
[new CheckboxValue()], | ||||||||||||||||||||||||||||||||||||
[new CheckboxValue(null)], | ||||||||||||||||||||||||||||||||||||
[new CheckboxValue(false)], | ||||||||||||||||||||||||||||||||||||
]; | ||||||||||||||||||||||||||||||||||||
return []; | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
public function providerForTestIsNotEmptyValue() | ||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||
return [ | ||||||||||||||||||||||||||||||||||||
[ | ||||||||||||||||||||||||||||||||||||
$this->getValidCreationFieldData(), | ||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||
[ | ||||||||||||||||||||||||||||||||||||
new CheckboxValue(true), | ||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||
[$this->getValidCreationFieldData()], | ||||||||||||||||||||||||||||||||||||
[new CheckboxValue(true)], | ||||||||||||||||||||||||||||||||||||
[new CheckboxValue()], | ||||||||||||||||||||||||||||||||||||
[new CheckboxValue(null)], | ||||||||||||||||||||||||||||||||||||
[new CheckboxValue(false)], | ||||||||||||||||||||||||||||||||||||
]; | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
@@ -392,6 +387,21 @@ public function testFindContentFieldCriterion(bool $isActive): void | |||||||||||||||||||||||||||||||||||
self::assertSame($isActive, $value->bool); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
public function testAddFieldDefinition() | ||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||
$content = $this->addFieldDefinition(); | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
$this->assertCount(2, $content->getFields()); | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would like to see sanity check prior There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure how to do this - this test is a variation of the base one: ezplatform-kernel/eZ/Publish/API/Repository/Tests/FieldType/BaseIntegrationTest.php Lines 1009 to 1022 in 59ca143
But I had to change the assertion. The method 'addFieldDefinition` first removes the fieldDefinition: ezplatform-kernel/eZ/Publish/API/Repository/Tests/FieldType/BaseIntegrationTest.php Line 985 in 59ca143
and then adds it again The flow inside
Current approach makes the I wanted to reuse the existing setup methods, but if you think it's good to add some custom setup for this test then I will do it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Static methods should be called statically.
Suggested change
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
$this->assertFalse( | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||
$this->getRepository()->getFieldTypeService()->getFieldType( | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Readability, please extract $fieldTypeService = $this->getRepository()->getFieldTypeService() as the first call of the method. If you need to call it after |
||||||||||||||||||||||||||||||||||||
$this->getTypeName() | ||||||||||||||||||||||||||||||||||||
)->isEmptyValue( | ||||||||||||||||||||||||||||||||||||
$content->getFieldValue('data') | ||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
protected function createCheckboxContentItems(Repository $repository): void | ||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||
$contentType = $this->createContentTypeWithCheckboxField($repository); | ||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -297,4 +297,30 @@ public function provideDataForGetName(): array | |||||
[new CheckboxValue(false), '0', [], 'en_GB'], | ||||||
]; | ||||||
} | ||||||
|
||||||
/** | ||||||
* @dataProvider provideForValueIsNeverEmpty | ||||||
*/ | ||||||
public function testValueIsNeverEmpty(CheckboxValue $value) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
{ | ||||||
$fieldType = $this->getFieldTypeUnderTest(); | ||||||
|
||||||
self::assertFalse($fieldType->isEmptyValue($value)); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @return iterable<array{ | ||||||
* \eZ\Publish\Core\FieldType\Checkbox\Value, | ||||||
* }> | ||||||
*/ | ||||||
public function provideForValueIsNeverEmpty(): iterable | ||||||
{ | ||||||
yield [new CheckboxValue(true)]; | ||||||
yield [new CheckboxValue(false)]; | ||||||
} | ||||||
|
||||||
public function testEmptyValueIsEmpty(): void | ||||||
{ | ||||||
self::markTestSkipped('Value of Checkbox fieldtype is never considered empty'); | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.