Skip to content

Commit

Permalink
Merge pull request #7729 from cakephp/phpcs
Browse files Browse the repository at this point in the history
Make PHPCS happy
  • Loading branch information
markstory committed Nov 24, 2015
2 parents 4b837ae + 15a5607 commit b80de12
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 35 deletions.
40 changes: 26 additions & 14 deletions tests/TestCase/ORM/RulesCheckerIntegrationTest.php
Expand Up @@ -64,10 +64,13 @@ public function testsSaveBelongsToWithValidationError()
$table->association('authors')
->target()
->rulesChecker()
->add(function (Entity $author, array $options) use ($table) {
$this->assertSame($options['repository'], $table->association('authors')->target());
return false;
}, ['errorField' => 'name', 'message' => 'This is an error']);
->add(
function (Entity $author, array $options) use ($table) {
$this->assertSame($options['repository'], $table->association('authors')->target());
return false;
},
['errorField' => 'name', 'message' => 'This is an error']
);

$this->assertFalse($table->save($entity));
$this->assertTrue($entity->isNew());
Expand Down Expand Up @@ -99,9 +102,12 @@ public function testSaveHasOneWithValidationError()
$table->association('articles')
->target()
->rulesChecker()
->add(function (Entity $entity) {
return false;
}, ['errorField' => 'title', 'message' => 'This is an error']);
->add(
function (Entity $entity) {
return false;
},
['errorField' => 'title', 'message' => 'This is an error']
);

$this->assertFalse($table->save($entity));
$this->assertTrue($entity->isNew());
Expand Down Expand Up @@ -140,10 +146,13 @@ public function testSaveHasManyWithErrorsAtomic()
$table->association('articles')
->target()
->rulesChecker()
->add(function (Entity $entity, $options) use ($table) {
$this->assertSame($table, $options['_sourceTable']);
return $entity->title === '1';
}, ['errorField' => 'title', 'message' => 'This is an error']);
->add(
function (Entity $entity, $options) use ($table) {
$this->assertSame($table, $options['_sourceTable']);
return $entity->title === '1';
},
['errorField' => 'title', 'message' => 'This is an error']
);

$this->assertFalse($table->save($entity));
$this->assertTrue($entity->isNew());
Expand Down Expand Up @@ -185,9 +194,12 @@ public function testSaveHasManyWithErrorsNonAtomic()
$table->association('articles')
->target()
->rulesChecker()
->add(function (Entity $article) {
return is_numeric($article->title);
}, ['errorField' => 'title', 'message' => 'This is an error']);
->add(
function (Entity $article) {
return is_numeric($article->title);
},
['errorField' => 'title', 'message' => 'This is an error']
);

$result = $table->save($entity, ['atomic' => false]);
$this->assertSame($entity, $result);
Expand Down
19 changes: 13 additions & 6 deletions tests/TestCase/Validation/ValidationTest.php
Expand Up @@ -2104,12 +2104,19 @@ public function testExtension()
$this->assertFalse(Validation::extension('extension.jpg', ['GIF']));
$this->assertTrue(Validation::extension(['extension.JPG', 'extension.gif', 'extension.png']));
$this->assertTrue(Validation::extension(['file' => ['name' => 'file.jpg']]));
$this->assertTrue(Validation::extension(['file1' => ['name' => 'file.jpg'],
'file2' => ['name' => 'file.jpg'],
'file3' => ['name' => 'file.jpg']]));
$this->assertFalse(Validation::extension(['file1' => ['name' => 'file.jpg'],
'file2' => ['name' => 'file.jpg'],
'file3' => ['name' => 'file.jpg']], ['gif']));
$this->assertTrue(Validation::extension([
'file1' => ['name' => 'file.jpg'],
'file2' => ['name' => 'file.jpg'],
'file3' => ['name' => 'file.jpg']
]));
$this->assertFalse(Validation::extension(
[
'file1' => ['name' => 'file.jpg'],
'file2' => ['name' => 'file.jpg'],
'file3' => ['name' => 'file.jpg']
],
['gif']
));

$this->assertFalse(Validation::extension(['noextension', 'extension.JPG', 'extension.gif', 'extension.png']));
$this->assertFalse(Validation::extension(['extension.pdf', 'extension.JPG', 'extension.gif', 'extension.png']));
Expand Down
30 changes: 15 additions & 15 deletions tests/TestCase/View/Helper/FormHelperTest.php
Expand Up @@ -3716,11 +3716,11 @@ public function testErrorMultipleMessages()
]);
$expected = [
'div' => ['class' => 'error-message'],
'ul' => [],
'<li', 'Cannot be empty', '/li',
'<li', 'No good!', '/li',
'<li', 'Something else', '/li',
'/ul',
'ul' => [],
'<li', 'Cannot be empty', '/li',
'<li', 'No good!', '/li',
'<li', 'Something else', '/li',
'/ul',
'/div'
];
$this->assertHtml($expected, $result);
Expand Down Expand Up @@ -6173,23 +6173,23 @@ public function testTextAreaMaxLength()
$result = $this->Form->input('other', ['type' => 'textarea']);
$expected = [
'div' => ['class' => 'input textarea'],
'label' => ['for' => 'other'],
'Other',
'/label',
'textarea' => ['name' => 'other', 'id' => 'other', 'rows' => 5],
'/textarea',
'label' => ['for' => 'other'],
'Other',
'/label',
'textarea' => ['name' => 'other', 'id' => 'other', 'rows' => 5],
'/textarea',
'/div'
];
$this->assertHtml($expected, $result);

$result = $this->Form->input('stuff', ['type' => 'textarea']);
$expected = [
'div' => ['class' => 'input textarea'],
'label' => ['for' => 'stuff'],
'Stuff',
'/label',
'textarea' => ['name' => 'stuff', 'maxlength' => 10, 'id' => 'stuff', 'rows' => 5],
'/textarea',
'label' => ['for' => 'stuff'],
'Stuff',
'/label',
'textarea' => ['name' => 'stuff', 'maxlength' => 10, 'id' => 'stuff', 'rows' => 5],
'/textarea',
'/div'
];
$this->assertHtml($expected, $result);
Expand Down

0 comments on commit b80de12

Please sign in to comment.