Skip to content

Commit

Permalink
Add tests for #9105
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jul 16, 2016
1 parent e38cda7 commit 1bf67c1
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/TestCase/View/Helper/FormHelperTest.php
Expand Up @@ -4149,6 +4149,56 @@ public function testError()
$this->assertHtml($expected, $result);
}

/**
* test error translation can use rule names for translating.
*
* @return void
*/
public function testErrorRuleName()
{
$this->article['errors'] = [
'Article' => [
'field' => ['email' => 'Your email was not good']
]
];
$this->Form->create($this->article);

$result = $this->Form->error('Article.field');
$expected = [
['div' => ['class' => 'error-message']],
'Your email was not good',
'/div',
];
$this->assertHtml($expected, $result);

$result = $this->Form->error('Article.field', ['email' => 'Email in use']);
$expected = [
['div' => ['class' => 'error-message']],
'Email in use',
'/div',
];
$this->assertHtml($expected, $result);

$result = $this->Form->error('Article.field', ['Your email was not good' => 'Email in use']);
$expected = [
['div' => ['class' => 'error-message']],
'Email in use',
'/div',
];
$this->assertHtml($expected, $result);

$result = $this->Form->error('Article.field', [
'email' => 'Key is preferred',
'Your email was not good' => 'Email in use'
]);
$expected = [
['div' => ['class' => 'error-message']],
'Key is preferred',
'/div',
];
$this->assertHtml($expected, $result);
}

/**
* Test error with nested lists.
*
Expand Down

0 comments on commit 1bf67c1

Please sign in to comment.