public function test_should_fill_the_table_with_yaml_data() { $unit_tester = new AkUnitTest(); $unit_tester->installAndIncludeModels(array('TheModel' => 'id,name')); $TheModel =& $unit_tester->TheModel; $TheModel->create(array('name' => 'eins')); $TheModel->create(array('name' => 'zwei')); $TheModel->create(array('name' => 'drei')); $TheModel->create(array('name' => 'vier')); $this->assertEqual($TheModel->count(), 4); $this->assertTrue($AllRecords = $TheModel->find()); $yaml = $TheModel->toYaml($AllRecords); $yaml_path = AkConfig::getDir('fixtures') . DS . 'the_models.yml'; $this->assertFalse(file_exists($yaml_path)); AkFileSystem::file_put_contents($yaml_path, $yaml); $unit_tester->installAndIncludeModels(array('TheModel' => 'id,name')); try { $TheModel->find(); } catch (RecordNotFoundException $e) { $this->pass(); } $this->assertEqual($TheModel->count(), 0); $unit_tester->installAndIncludeModels(array('TheModel' => 'id,name'), array('populate' => true)); $this->assertEqual($TheModel->count(), 4); unlink($yaml_path); }
public function test_should_fill_the_table_with_yaml_data() { $unit_tester = new AkUnitTest(); $unit_tester->installAndIncludeModels(array('TheModel'=>'id,name')); $TheModel =& $unit_tester->TheModel; $TheModel->create(array('name'=>'eins')); $TheModel->create(array('name'=>'zwei')); $TheModel->create(array('name'=>'drei')); $TheModel->create(array('name'=>'vier')); $this->assertEqual($TheModel->count(),4); $this->assertTrue($AllRecords = $TheModel->find()); $yaml = $TheModel->toYaml($AllRecords); $this->assertFalse(file_exists(AK_TEST_DIR.DS.'fixtures'.DS.'data'.DS.'the_models.yaml')); Ak::file_put_contents(AK_TEST_DIR.DS.'fixtures'.DS.'data'.DS.'the_models.yaml',$yaml); $unit_tester->installAndIncludeModels(array('TheModel'=>'id,name')); $this->assertFalse($TheModel->find()); $this->assertEqual($TheModel->count(),0); $unit_tester->installAndIncludeModels(array('TheModel'=>'id,name'),array('populate'=>true)); $this->assertEqual($TheModel->count(),4); unlink(AK_TEST_DIR.DS.'fixtures'.DS.'data'.DS.'the_models.yaml'); }
public function test_setup() { $TestSetup = new AkUnitTest(); $TestSetup->rebaseAppPaths(); $TestSetup->installAndIncludeModels(array('DummyPost' => 'id, title, body, hip_factor int, comments_count, posted_on, expires_at', 'DummyComment' => 'id,name,body,dummy_post_id,created_at')); $this->webserver_enabled = AkConfig::getOption('webserver_enabled', false); $this->_test_script = AkConfig::getOption('testing_url') . '/action_pack/public/index.php?ak='; }
public function test_setup() { $TestSetup = new AkUnitTest(); $TestSetup->installAndIncludeModels(array('Post', 'Comment', 'Tag')); $Post =& $TestSetup->Post->create(array('title' => 'One', 'body' => 'First post')); foreach (range(1, 5) as $n) { $Post->comment->add(new Comment(array('body' => AkInflector::ordinalize($n) . ' post'))); } $Post->save(); $Post->reload(); $Post->comment->load(); $this->assertEqual($Post->comment->count(), 5); $this->post_id = $Post->id; }
public function test_setup() { $TestSetup = new AkUnitTest(); $TestSetup->rebaseAppPaths(); $TestSetup->installAndIncludeModels(array('Text' => 'id, name')); }