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
Conversation
f622579
to
9513b80
Compare
0992bc2
to
82fcdc5
Compare
82fcdc5
to
7e8a12c
Compare
@@ -392,6 +387,21 @@ public function testFindContentFieldCriterion(bool $isActive): void | |||
self::assertSame($isActive, $value->bool); | |||
} | |||
|
|||
public function testAddFieldDefinition() |
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.
public function testAddFieldDefinition() | |
public function testAddFieldDefinition(): void |
$content = $this->addFieldDefinition(); | ||
|
||
$this->assertCount(2, $content->getFields()); |
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.
Would like to see sanity check prior addFieldDefinition
- assert count = 1
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.
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
public function testAddFieldDefinition() | |
{ | |
$content = $this->addFieldDefinition(); | |
$this->assertCount(2, $content->getFields()); | |
$this->assertTrue( | |
$this->getRepository()->getFieldTypeService()->getFieldType( | |
$this->getTypeName() | |
)->isEmptyValue( | |
$content->getFieldValue('data') | |
) | |
); | |
} |
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
$content = $this->removeFieldDefinition(); |
and then adds it again
The flow inside addFieldDefinition
looks like this then:
- The Content item is created (with 2 fields)
- the tested field definition is removed
- the tested field definition is added again
Current approach makes the $content
variable available only after the call to addFieldDefinition
finishes, I can't really add that sanity check without reworking this test.
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
{ | ||
$content = $this->addFieldDefinition(); | ||
|
||
$this->assertCount(2, $content->getFields()); |
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.
Static methods should be called statically.
$this->assertCount(2, $content->getFields()); | |
self::assertCount(2, $content->getFields()); |
|
||
$this->assertCount(2, $content->getFields()); | ||
|
||
$this->assertFalse( |
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.
$this->assertFalse( | |
self::assertFalse( |
$this->assertCount(2, $content->getFields()); | ||
|
||
$this->assertFalse( | ||
$this->getRepository()->getFieldTypeService()->getFieldType( |
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.
Readability, please extract
$fieldTypeService = $this->getRepository()->getFieldTypeService()
as the first call of the method. If you need to call it after addFieldDefinition
then it should be called as getRepository(false)
because the method has side effects.
/** | ||
* @dataProvider provideForValueIsNeverEmpty | ||
*/ | ||
public function testValueIsNeverEmpty(CheckboxValue $value) |
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.
public function testValueIsNeverEmpty(CheckboxValue $value) | |
public function testValueIsNeverEmpty(CheckboxValue $value): void |
@ezsystems/documentation-team this is behavior change - CheckBox Field Type after the change is not going to be considered as empty in any case - it can be either true or false. This should be reflected on the Doc page for that Field Type. |
Kudos, SonarCloud Quality Gate passed!聽 聽 0 Bugs No Coverage information |
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.
QA approved IbexaDXP 3.3 commerce.
Merged up ezsystems/ezplatform-kernel#336 Co-Authored-By: Marek Noco艅 <mnocon@users.noreply.github.com>
v3.3
Replacement for https://github.com/ezsystems/ezplatform-version-comparison/pull/81
I've:
isEmptyValue(SPIValue $value)
signature does not allow nulls, this removal is even suggested by PHPStorm.In the original discussion there was this suggestion:
But I'm not sure about it - the default value seems to be
false
andnull
seems is not even specified as an allowed value:https://github.com/ezsystems/ezplatform-kernel/blob/1.3/eZ/Publish/Core/Persistence/Legacy/Content/FieldValue/Converter/CheckboxConverter.php#L74
https://github.com/ezsystems/ezplatform-kernel/blob/1.3/eZ/Publish/Core/Persistence/Legacy/Content/FieldValue/Converter/CheckboxConverter.php#L39
https://github.com/ezsystems/ezplatform-kernel/blob/1.3/eZ/Publish/Core/FieldType/Checkbox/Value.php#L16-L21
Changing the default value to
null
(and allowing the value to bebool|null
) seems like asking for trouble, because 3rd party code might not be ready to deal with nulls in the value - that's why I went the "this field is never empty" way.If accepted, I will prepare a PR removing this condition:
https://github.com/ezsystems/ezplatform-admin-ui/blob/e9f2b07f26a47f0158417ea0e2ddf4f0ea5436b7/src/bundle/Resources/views/themes/admin/content/content_view_fields.html.twig#L25
as it will be no longer needed.
I will gladly accept any feedback, as my kernel-fu is very, very basic 馃槃
Checklist:
$ composer fix-cs
).@ezsystems/engineering-team
).