From 03f362a40a8dd39f8c8b4bf816334922b7b264e4 Mon Sep 17 00:00:00 2001 From: wei <> Date: Tue, 9 Jan 2007 10:42:06 +0000 Subject: add TActiveRecord::findAllByPks() --- .../simple_unit/ActiveRecord/FindByPksTestCase.php | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/simple_unit/ActiveRecord/FindByPksTestCase.php (limited to 'tests/simple_unit') diff --git a/tests/simple_unit/ActiveRecord/FindByPksTestCase.php b/tests/simple_unit/ActiveRecord/FindByPksTestCase.php new file mode 100644 index 00000000..e7f3e3d0 --- /dev/null +++ b/tests/simple_unit/ActiveRecord/FindByPksTestCase.php @@ -0,0 +1,58 @@ +setDbConnection($conn); + } + + function test_find_by_1pk() + { + $dep = DepartmentRecord::finder()->findByPk(1); + $this->assertNotNull($dep); + $this->assertEqual($dep->department_id, 1); + } + + function test_find_by_pks() + { + $deps = DepartmentRecord::finder()->findAllByPks(1,2,4); + $this->assertEqual(count($deps), 3); + + $this->assertEqual($deps[0]->department_id, 1); + $this->assertEqual($deps[1]->department_id, 2); + $this->assertEqual($deps[2]->department_id, 4); + } + + function test_find_by_pks_with_invalid() + { + $deps = DepartmentRecord::finder()->findAllByPks(4,2,14); + $this->assertEqual(count($deps), 2); + + $this->assertEqual($deps[0]->department_id, 2); + $this->assertEqual($deps[1]->department_id, 4); + } + + function test_find_by_composite_pks() + { + $ds = DepSections::finder()->findAllByPks(array(1,1), array(2,5)); + $this->assertEqual(count($ds), 2); + + $this->assertIsDepSection($ds[0], 1, 1); + $this->assertIsDepSection($ds[1], 2, 5); + } + + function assertIsDepSection($dep, $dep_id, $sec_id) + { + $this->assertTrue($dep instanceof DepSections); + $this->assertEqual($dep->department_id, $dep_id); + $this->assertEqual($dep->section_id, $sec_id); + } +} + +?> \ No newline at end of file -- cgit v1.2.3