diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-01-14 20:18:13 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-01-14 20:18:13 -0500 |
commit | 805be7d33155478ef32c4bd3643dcf4025d85a05 (patch) | |
tree | 4ee858d96f3e3bf2b630471db148446c3c56b693 /tests/units/Validator/LinkValidatorTest.php | |
parent | dc35a78374e9b091505cfc56eefcd0c631c56e3a (diff) |
Move validator methods
Diffstat (limited to 'tests/units/Validator/LinkValidatorTest.php')
-rw-r--r-- | tests/units/Validator/LinkValidatorTest.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/units/Validator/LinkValidatorTest.php b/tests/units/Validator/LinkValidatorTest.php new file mode 100644 index 00000000..8b7b182c --- /dev/null +++ b/tests/units/Validator/LinkValidatorTest.php @@ -0,0 +1,54 @@ +<?php + +require_once __DIR__.'/../Base.php'; + +use Kanboard\Validator\LinkValidator; + +class LinkValidatorTest extends Base +{ + public function testValidateCreation() + { + $validator = new LinkValidator($this->container); + + $r = $validator->validateCreation(array('label' => 'a')); + $this->assertTrue($r[0]); + + $r = $validator->validateCreation(array('label' => 'a', 'opposite_label' => 'b')); + $this->assertTrue($r[0]); + + $r = $validator->validateCreation(array('label' => 'relates to')); + $this->assertFalse($r[0]); + + $r = $validator->validateCreation(array('label' => 'a', 'opposite_label' => 'a')); + $this->assertFalse($r[0]); + + $r = $validator->validateCreation(array('label' => '')); + $this->assertFalse($r[0]); + } + + public function testValidateModification() + { + $validator = new LinkValidator($this->container); + + $r = $validator->validateModification(array('id' => 20, 'label' => 'a', 'opposite_id' => 0)); + $this->assertTrue($r[0]); + + $r = $validator->validateModification(array('id' => 20, 'label' => 'a', 'opposite_id' => '1')); + $this->assertTrue($r[0]); + + $r = $validator->validateModification(array('id' => 20, 'label' => 'relates to', 'opposite_id' => '1')); + $this->assertFalse($r[0]); + + $r = $validator->validateModification(array('id' => 20, 'label' => '', 'opposite_id' => '1')); + $this->assertFalse($r[0]); + + $r = $validator->validateModification(array('label' => '', 'opposite_id' => '1')); + $this->assertFalse($r[0]); + + $r = $validator->validateModification(array('id' => 20, 'opposite_id' => '1')); + $this->assertFalse($r[0]); + + $r = $validator->validateModification(array('label' => 'test')); + $this->assertFalse($r[0]); + } +} |