1
0
mirror of synced 2024-12-13 14:56:01 +03:00

* Updating the test framework with an assertIdentical() call that uses the === operator rather then the == operator.

* Updating BooleanTestCase to use above mentioned function - and they now fail
This commit is contained in:
pookey 2007-06-12 17:05:16 +00:00
parent c417a3b3a6
commit 445d1f9c62
2 changed files with 19 additions and 9 deletions

View File

@ -41,27 +41,27 @@ class Doctrine_Boolean_TestCase extends Doctrine_UnitTestCase {
$test = new BooleanTest(); $test = new BooleanTest();
$test->is_working = false; $test->is_working = false;
$this->assertEqual($test->is_working, false); $this->assertIdentical($test->is_working, false);
$this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY);
$test->save(); $test->save();
$test->refresh(); $test->refresh();
$this->assertEqual($test->is_working, false); $this->assertIdentical($test->is_working, false);
} }
public function testSetTrue() { public function testSetTrue() {
$test = new BooleanTest(); $test = new BooleanTest();
$test->is_working = true; $test->is_working = true;
$this->assertEqual($test->is_working, true); $this->assertIdentical($test->is_working, true);
$test->save(); $test->save();
$test->refresh(); $test->refresh();
$this->assertEqual($test->is_working, true); $this->assertIdentical($test->is_working, true);
$this->connection->clear(); $this->connection->clear();
$test = $test->getTable()->find($test->id); $test = $test->getTable()->find($test->id);
$this->assertEqual($test->is_working, true); $this->assertIdentical($test->is_working, true);
} }
public function testNormalQuerying() { public function testNormalQuerying() {
$query = new Doctrine_Query($this->connection); $query = new Doctrine_Query($this->connection);
@ -97,22 +97,22 @@ class Doctrine_Boolean_TestCase extends Doctrine_UnitTestCase {
$test = new BooleanTest(); $test = new BooleanTest();
$this->is_working = null; $this->is_working = null;
$this->assertEqual($this->is_working, null); $this->assertIdentical($this->is_working, null);
$this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY);
$test->save(); $test->save();
$test->refresh(); $test->refresh();
$this->assertEqual($test->is_working, null); $this->assertIdentical($test->is_working, null);
$test = new BooleanTest(); $test = new BooleanTest();
$this->is_working_notnull = null; $this->is_working_notnull = null;
$this->assertEqual($this->is_working_notnull, false); $this->assertIdentical($this->is_working_notnull, false);
$this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY);
$test->save(); $test->save();
$test->refresh(); $test->refresh();
$this->assertEqual($test->is_working_notnull, false); $this->assertIdentical($test->is_working_notnull, false);
} }
} }

View File

@ -71,6 +71,16 @@ class UnitTestCase
$this->_fail(); $this->_fail();
} }
} }
public function assertIdentical($value, $value2)
{
if ($value === $value2) {
$this->_passed++;
} else {
$this->_fail();
}
}
public function assertNotEqual($value, $value2) public function assertNotEqual($value, $value2)
{ {
if ($value != $value2) { if ($value != $value2) {