Skip to content

Commit

Permalink
AngularTest.php missing array in testSortRelationArrayDirective (#297)
Browse files Browse the repository at this point in the history
* Update AngularTest.php

a small typo, a defined list is missing
from directives.js
* @var object $options Provides options to build the sort relation array:
     *
     * ```js
     * {
     * 	'sourceData': [
     * 		{'value': 1, 'label': 'Source Entry #1'}
     * 		{'value': 2, 'label': 'Source Entry #2'}
     * 		{'value': 3, 'label': 'Source Entry #3'}
     * 		{'value': 4, 'label': 'Source Entry #4'}
     * 	]
     * }
     * ```

* Update Angular.php

* Ensure value and label as keys

* Update Angular.php

* Update AngularTest.php
  • Loading branch information
vavepl authored and nadar committed May 19, 2019
1 parent 6059ac9 commit d1b2c25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/helpers/Angular.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public static function directive($name, array $options = [])
*/
public static function sortRelationArray($ngModel, $label, array $sourceData, array $options = [])
{
return self::injector(TypesInterface::TYPE_SORT_RELATION_ARRAY, $ngModel, $label, ['sourceData' => $sourceData], $options);
return self::injector(TypesInterface::TYPE_SORT_RELATION_ARRAY, $ngModel, $label, ['sourceData' => static::optionsArrayInput($sourceData)], $options);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/admin/helpers/AngularTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public function testTextDirective()

public function testSortRelationArrayDirective()
{
$this->assertSame('<zaa-sort-relation-array model="the-model" label="the-label" options=\'{"sourceData":{"foo":"bar"}}\' fieldid="the-model-zaa-sort-relation-array" fieldname="the-model"></zaa-sort-relation-array>', Angular::sortRelationArray('the-model', 'the-label', ['foo' => 'bar'])->render());
$this->assertSame('<zaa-sort-relation-array classAtr="value" model="the-model" label="the-label" options=\'{"sourceData":{"foo":"bar"}}\' fieldid="the-model-zaa-sort-relation-array" fieldname="the-model"></zaa-sort-relation-array>', Angular::sortRelationArray('the-model', 'the-label', ['foo' => 'bar'], ['classAtr' => 'value'])->render());
$this->assertSame('<zaa-sort-relation-array model="the-model" label="the-label" options=\'{"sourceData":[{"label":"bar","value":"foo"}]}\' fieldid="the-model-zaa-sort-relation-array" fieldname="the-model"></zaa-sort-relation-array>', Angular::sortRelationArray('the-model', 'the-label', ['foo' => 'bar'])->render());
$this->assertSame('<zaa-sort-relation-array classAtr="value" model="the-model" label="the-label" options=\'{"sourceData":[{"label":"bar","value":"foo"}]}\' fieldid="the-model-zaa-sort-relation-array" fieldname="the-model"></zaa-sort-relation-array>', Angular::sortRelationArray('the-model', 'the-label', ['foo' => 'bar'], ['classAtr' => 'value'])->render());
}

public function testCheckbox()
Expand Down

0 comments on commit d1b2c25

Please sign in to comment.