I am beginner to Simpletest and facing an issue while creating fixtures. As I am using cakephp 1.3.14 version for my application.
Created fixture with filename complaint_fixture.php
class ComplaintFixture extends CakeTestFixture { var $name = 'Complaint'; var $import = array('table' => 'complaints', 'records' => true); // do not truncate movie_stars table between tests public function truncate($db) { return null; } // do not drop movie_stars table between tests public function drop($db) { return null; } }Created test case with name complaint.test.php
App::import('Model', 'Complaint'); class ComplaintTestCase extends CakeTestCase { var $fixtures = array('app.Complaint'); function setUp($method) { parent::setUp(); $this->Complaint = & ClassRegistry::init('Complaint'); // load data $this->loadFixtures('Complaint'); } function testFixture() { $numberOfResults = $this->Complaint->find('count'); var_dump($numberOfResults); } /* function testupdateComplaintStatus(){ $result = $this->Complaint->updateComplaintStatus(47,'ACT'); $this->assertEqual($result,1,'Status updated successfully!'); } */ }
As you can see in the above code, a fixture is created with name Complaint and then a test case is being used to load that fixture. So, what I have read on it from developer guide - we do create a fixture with specifying the fields name and a records set - load that fixture in test model class.
BUT, what I am looking for is to perform CRUD operations on test data which is being inserted into the test database. And, when I try to do the same with above given script, It starts affecting the production database records instead of test database.
If you see in the above code I have even stopped truncate and drop for test data, yet not able to sort out the issue.
Can anyone let me know what I have missed in the above code?