Commit 35bd97bf authored by zYne's avatar zYne

--no commit message

--no commit message
parent e73f9fe5
...@@ -46,9 +46,6 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase ...@@ -46,9 +46,6 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
parent::prepareTables(); parent::prepareTables();
} }
/**
* Tests correct type detection.
*/
public function testIsValidType() public function testIsValidType()
{ {
$var = '123'; $var = '123';
...@@ -115,9 +112,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase ...@@ -115,9 +112,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
$this->assertTrue(Doctrine_Validator::isValidType($var, 'object')); $this->assertTrue(Doctrine_Validator::isValidType($var, 'object'));
} }
/**
* Tests Doctrine_Validator::validateRecord()
*/
public function testValidate2() public function testValidate2()
{ {
$test = new ValidatorTest(); $test = new ValidatorTest();
...@@ -142,9 +137,6 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase ...@@ -142,9 +137,6 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
$test->save(); $test->save();
} }
/**
* Tests Doctrine_Validator::validateRecord()
*/
public function testValidate() public function testValidate()
{ {
$user = $this->connection->getTable('User')->find(4); $user = $this->connection->getTable('User')->find(4);
...@@ -208,8 +200,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase ...@@ -208,8 +200,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
*/ */
public function testSave() public function testSave()
{ {
$this->manager->setAttribute(Doctrine::ATTR_VLD, true); $this->manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
$this->manager->setAttribute(Doctrine::ATTR_AUTO_LENGTH_VLD, true);
$user = $this->connection->getTable("User")->find(4); $user = $this->connection->getTable("User")->find(4);
try { try {
$user->name = "this is an example of too long name not very good example but an example nevertheless"; $user->name = "this is an example of too long name not very good example but an example nevertheless";
...@@ -240,8 +231,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase ...@@ -240,8 +231,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
$this->assertTrue(in_array('length', $userStack['name'])); $this->assertTrue(in_array('length', $userStack['name']));
} }
$this->manager->setAttribute(Doctrine::ATTR_VLD, false); $this->manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_NONE);
$this->manager->setAttribute(Doctrine::ATTR_AUTO_LENGTH_VLD, false);
} }
/** /**
...@@ -250,7 +240,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase ...@@ -250,7 +240,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
*/ */
public function testValidationHooks() public function testValidationHooks()
{ {
$this->manager->setAttribute(Doctrine::ATTR_VLD, true); $this->manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
// Tests validate() and validateOnInsert() // Tests validate() and validateOnInsert()
$user = new User(); $user = new User();
...@@ -288,7 +278,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase ...@@ -288,7 +278,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
$this->assertTrue(in_array('notNobody', $stack['loginname'])); // validateOnUpdate() hook constraint $this->assertTrue(in_array('notNobody', $stack['loginname'])); // validateOnUpdate() hook constraint
} }
$this->manager->setAttribute(Doctrine::ATTR_VLD, false); $this->manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_NONE);
} }
/** /**
...@@ -297,7 +287,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase ...@@ -297,7 +287,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
*/ */
public function testHookValidateOnInsert() public function testHookValidateOnInsert()
{ {
$this->manager->setAttribute(Doctrine::ATTR_VLD, true); $this->manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
$user = new User(); $user = new User();
$user->password = "1234"; $user->password = "1234";
...@@ -310,7 +300,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase ...@@ -310,7 +300,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
$this->assertTrue(in_array('pwNotTopSecret', $errors['password'])); $this->assertTrue(in_array('pwNotTopSecret', $errors['password']));
} }
$this->manager->setAttribute(Doctrine::ATTR_VLD, false); $this->manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_NONE);
} }
/* /*
...@@ -338,14 +328,11 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase ...@@ -338,14 +328,11 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
} }
*/ */
/** // @todo move to a separate test file (tests/Validator/UniqueTestCase) .
* Enter description here...
*
* @todo move to a separate test file (tests/Validator/UniqueTestCase) .
*/
public function testSetSameUniqueValueOnSameRecordThrowsNoException() public function testSetSameUniqueValueOnSameRecordThrowsNoException()
{ {
$this->manager->setAttribute(Doctrine::ATTR_VLD, true); $this->manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
$r = new ValidatorTest_Person(); $r = new ValidatorTest_Person();
$r->identifier = '1234'; $r->identifier = '1234';
...@@ -362,12 +349,12 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase ...@@ -362,12 +349,12 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
$r->delete(); // clean up $r->delete(); // clean up
$this->manager->setAttribute(Doctrine::ATTR_VLD, false); $this->manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_NONE);
} }
public function testSetSameUniqueValueOnDifferentRecordThrowsException() public function testSetSameUniqueValueOnDifferentRecordThrowsException()
{ {
$this->manager->setAttribute(Doctrine::ATTR_VLD, true); $this->manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
$r = new ValidatorTest_Person(); $r = new ValidatorTest_Person();
$r->identifier = '1234'; $r->identifier = '1234';
...@@ -383,12 +370,12 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase ...@@ -383,12 +370,12 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
} }
$r->delete(); // clean up $r->delete(); // clean up
$this->manager->setAttribute(Doctrine::ATTR_VLD, false); $this->manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_NONE);
} }
public function testValidationOnManyToManyRelations() public function testValidationOnManyToManyRelations()
{ {
$this->manager->setAttribute(Doctrine::ATTR_VLD, true); $this->manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
try { try {
$client = new ValidatorTest_ClientModel(); $client = new ValidatorTest_ClientModel();
$client->short_name = 'test'; $client->short_name = 'test';
...@@ -396,8 +383,10 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase ...@@ -396,8 +383,10 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
$client->save(); $client->save();
$this->fail(); $this->fail();
} catch (Doctrine_Validator_Exception $dve) { } catch (Doctrine_Validator_Exception $dve) {
$s = $dve->getInvalidRecords();
$this->assertEqual(1, count($dve->getInvalidRecords())); $this->assertEqual(1, count($dve->getInvalidRecords()));
$stack = $client->ValidatorTest_AddressModel[0]->getErrorStack(); $stack = $client->ValidatorTest_AddressModel[0]->getErrorStack();
$this->assertTrue(in_array('notnull', $stack['address1'])); $this->assertTrue(in_array('notnull', $stack['address1']));
$this->assertTrue(in_array('notblank', $stack['address1'])); $this->assertTrue(in_array('notblank', $stack['address1']));
$this->assertTrue(in_array('notnull', $stack['address2'])); $this->assertTrue(in_array('notnull', $stack['address2']));
...@@ -408,6 +397,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase ...@@ -408,6 +397,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
$this->assertTrue(in_array('notblank', $stack['zip'])); $this->assertTrue(in_array('notblank', $stack['zip']));
} }
$this->manager->setAttribute(Doctrine::ATTR_VLD, false); $this->manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_NONE);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment