Skip to content
Permalink
Browse files

Adjust tests for notEmpty to notBlank.

  • Loading branch information...
dereuromark committed May 17, 2015
1 parent 35f7408 commit ebd44de59784ef6804c2e7fa0f54c336e764fc10
@@ -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);
}
@@ -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']);
}
/**
@@ -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);
@@ -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']));
@@ -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'];
@@ -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']));
@@ -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);
@@ -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);
@@ -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']));
@@ -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);
@@ -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');
@@ -921,8 +921,8 @@ public function testAddMulitple()
{
$validator = new Validator;
$validator->add('title', [
'notEmpty' => [
'rule' => 'notEmpty'
'notBlank' => [
'rule' => 'notBlank'
],
'length' => [
'rule' => ['minLength', 10],
@@ -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 = [

0 comments on commit ebd44de

Please sign in to comment.
You can’t perform that action at this time.