Skip to content

Commit

Permalink
Adjust tests for notEmpty to notBlank.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Scherer committed May 17, 2015
1 parent 35f7408 commit ebd44de
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
42 changes: 21 additions & 21 deletions tests/TestCase/Validation/ValidationSetTest.php
Expand Up @@ -35,10 +35,10 @@ class ValidationSetTest extends TestCase
public function testGetRule()
{
$field = new ValidationSet;
$field->add('notEmpty', ['rule' => 'notEmpty', 'message' => 'Can not be empty']);
$result = $field->rule('notEmpty');
$field->add('notBlank', ['rule' => 'notBlank', 'message' => 'Can not be empty']);
$result = $field->rule('notBlank');
$this->assertInstanceOf('Cake\Validation\ValidationRule', $result);
$expected = new ValidationRule(['rule' => 'notEmpty', 'message' => 'Can not be empty']);
$expected = new ValidationRule(['rule' => 'notBlank', 'message' => 'Can not be empty']);
$this->assertEquals($expected, $result);
}

Expand All @@ -50,11 +50,11 @@ public function testGetRule()
public function testGetRules()
{
$field = new ValidationSet;
$field->add('notEmpty', ['rule' => 'notEmpty', 'message' => 'Can not be empty']);
$field->add('notBlank', ['rule' => 'notBlank', 'message' => 'Can not be empty']);

$result = $field->rules();
$this->assertEquals(['notEmpty'], array_keys($result));
$this->assertInstanceOf('Cake\Validation\ValidationRule', $result['notEmpty']);
$this->assertEquals(['notBlank'], array_keys($result));
$this->assertInstanceOf('Cake\Validation\ValidationRule', $result['notBlank']);
}

/**
Expand All @@ -65,13 +65,13 @@ public function testGetRules()
public function testArrayAccessGet()
{
$set = (new ValidationSet)
->add('notEmpty', ['rule' => 'notEmpty'])
->add('notBlank', ['rule' => 'notBlank'])
->add('numeric', ['rule' => 'numeric'])
->add('other', ['rule' => 'email']);

$rule = $set['notEmpty'];
$rule = $set['notBlank'];
$this->assertInstanceOf('Cake\Validation\ValidationRule', $rule);
$this->assertEquals(new ValidationRule(['rule' => 'notEmpty']), $rule);
$this->assertEquals(new ValidationRule(['rule' => 'notBlank']), $rule);

$rule = $set['numeric'];
$this->assertInstanceOf('Cake\Validation\ValidationRule', $rule);
Expand All @@ -90,11 +90,11 @@ public function testArrayAccessGet()
public function testArrayAccessExists()
{
$set = (new ValidationSet)
->add('notEmpty', ['rule' => 'notEmpty'])
->add('notBlank', ['rule' => 'notBlank'])
->add('numeric', ['rule' => 'numeric'])
->add('other', ['rule' => 'email']);

$this->assertTrue(isset($set['notEmpty']));
$this->assertTrue(isset($set['notBlank']));
$this->assertTrue(isset($set['numeric']));
$this->assertTrue(isset($set['other']));
$this->assertFalse(isset($set['fail']));
Expand All @@ -108,7 +108,7 @@ public function testArrayAccessExists()
public function testArrayAccessSet()
{
$set = (new ValidationSet)
->add('notEmpty', ['rule' => 'notEmpty']);
->add('notBlank', ['rule' => 'notBlank']);

$this->assertFalse(isset($set['other']));
$set['other'] = ['rule' => 'email'];
Expand All @@ -125,12 +125,12 @@ public function testArrayAccessSet()
public function testArrayAccessUnset()
{
$set = (new ValidationSet)
->add('notEmpty', ['rule' => 'notEmpty'])
->add('notBlank', ['rule' => 'notBlank'])
->add('numeric', ['rule' => 'numeric'])
->add('other', ['rule' => 'email']);

unset($set['notEmpty']);
$this->assertFalse(isset($set['notEmpty']));
unset($set['notBlank']);
$this->assertFalse(isset($set['notBlank']));

unset($set['numeric']);
$this->assertFalse(isset($set['numeric']));
Expand All @@ -147,14 +147,14 @@ public function testArrayAccessUnset()
public function testIterator()
{
$set = (new ValidationSet)
->add('notEmpty', ['rule' => 'notEmpty'])
->add('notBlank', ['rule' => 'notBlank'])
->add('numeric', ['rule' => 'numeric'])
->add('other', ['rule' => 'email']);

$i = 0;
foreach ($set as $name => $rule) {
if ($i === 0) {
$this->assertEquals('notEmpty', $name);
$this->assertEquals('notBlank', $name);
}
if ($i === 1) {
$this->assertEquals('numeric', $name);
Expand All @@ -176,7 +176,7 @@ public function testIterator()
public function testCount()
{
$set = (new ValidationSet)
->add('notEmpty', ['rule' => 'notEmpty'])
->add('notBlank', ['rule' => 'notBlank'])
->add('numeric', ['rule' => 'numeric'])
->add('other', ['rule' => 'email']);
$this->assertCount(3, $set);
Expand All @@ -194,13 +194,13 @@ public function testRemoveRule()
{
$set = new ValidationSet('title', [
'_validatePresent' => true,
'notEmpty' => ['rule' => 'notEmpty'],
'notBlank' => ['rule' => 'notBlank'],
'numeric' => ['rule' => 'numeric'],
'other' => ['rule' => ['other', 1]],
]);

$set->remove('notEmpty');
$this->assertFalse(isset($set['notEmpty']));
$set->remove('notBlank');
$this->assertFalse(isset($set['notBlank']));

$set->remove('numeric');
$this->assertFalse(isset($set['numeric']));
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Validation/ValidatorTest.php
Expand Up @@ -33,7 +33,7 @@ class ValidatorTest extends TestCase
public function testAddingRulesToField()
{
$validator = new Validator;
$validator->add('title', 'not-empty', ['rule' => 'notEmpty']);
$validator->add('title', 'not-blank', ['rule' => 'notBlank']);
$set = $validator->field('title');
$this->assertInstanceOf('Cake\Validation\ValidationSet', $set);
$this->assertCount(1, $set);
Expand Down Expand Up @@ -155,14 +155,14 @@ public function testFieldSetter()
public function testRemove()
{
$validator = new Validator;
$validator->add('title', 'not-empty', ['rule' => 'notEmpty']);
$validator->add('title', 'not-blank', ['rule' => 'notBlank']);
$validator->add('title', 'foo', ['rule' => 'bar']);
$this->assertCount(2, $validator->field('title'));
$validator->remove('title');
$this->assertCount(0, $validator->field('title'));
$validator->remove('title');

$validator->add('title', 'not-empty', ['rule' => 'notEmpty']);
$validator->add('title', 'not-blank', ['rule' => 'notBlank']);
$validator->add('title', 'foo', ['rule' => 'bar']);
$this->assertCount(2, $validator->field('title'));
$validator->remove('title', 'foo');
Expand Down Expand Up @@ -921,8 +921,8 @@ public function testAddMulitple()
{
$validator = new Validator;
$validator->add('title', [
'notEmpty' => [
'rule' => 'notEmpty'
'notBlank' => [
'rule' => 'notBlank'
],
'length' => [
'rule' => ['minLength', 10],
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/View/Helper/FormHelperTest.php
Expand Up @@ -3633,12 +3633,12 @@ public function testErrorMessages()
public function testErrorMultipleMessages()
{
$this->article['errors'] = [
'field' => ['notEmpty', 'email', 'Something else']
'field' => ['notBlank', 'email', 'Something else']
];
$this->Form->create($this->article);

$result = $this->Form->error('field', [
'notEmpty' => 'Cannot be empty',
'notBlank' => 'Cannot be empty',
'email' => 'No good!'
]);
$expected = [
Expand Down

0 comments on commit ebd44de

Please sign in to comment.