consistency in twig methods

The method chill_custom_fields_is_empty take now the fields as first argument, and the customField as second argument, to be consistent with other twig methods.
This commit is contained in:
Julien Fastré 2015-12-28 00:54:38 +01:00
parent d2039893b3
commit 54391b02f3
3 changed files with 25 additions and 2 deletions

View File

@ -22,7 +22,7 @@
{%- endif -%} {%- endif -%}
{%- endif -%} {%- endif -%}
{% else %} {% else %}
{%- if show_empty == true or (chill_custom_field_is_empty(customField, cFData) == false) -%} {%- if show_empty == true or (chill_custom_field_is_empty(cFData, customField) == false) -%}
{%- if title is not empty -%} {%- if title is not empty -%}
{{ chill_custom_field_widget(cFData, title) }} {{ chill_custom_field_widget(cFData, title) }}
{%- set title = null -%} {%- set title = null -%}

View File

@ -85,7 +85,7 @@ class CustomFieldRenderingTwig extends \Twig_Extension implements ContainerAware
} }
public function isEmptyValue(CustomField $customField, $fields, $slug = null) public function isEmptyValue($fields, CustomField $customField)
{ {
return $this->container->get('chill.custom_field.helper') return $this->container->get('chill.custom_field.helper')
->isEmptyValue($fields, $customField); ->isEmptyValue($fields, $customField);

View File

@ -102,4 +102,27 @@ class CustomFieldRenderingTwigTest extends KernelTestCase
$this->assertContains('My tailor is rich', $text, $this->assertContains('My tailor is rich', $text,
"The rendering text should contains the 'test' text"); "The rendering text should contains the 'test' text");
} }
public function testIsEmpty()
{
$cf = $this->getSimpleCustomFieldText();
// value is not empty
$fields = array(
'test' => "My tailor is rich"
);
$result = $this->cfRendering->isEmptyValue($fields, $cf);
$this->assertFalse($result);
// value is empty
$fields = array(
'text' => ''
);
$result = $this->cfRendering->isEmptyValue($fields, $cf);
$this->assertTrue($result);
}
} }