array('next'=>'next')); var $useDbConfig = 'test_suite'; } class StackTestCase extends CakeTestCase { var $fixtures = array('app.stack'); var $Stack = null; function start() { parent::start(); } function testSetup() { $this->Stack = new TestStack(); $expected = array('TestStack'=>array( 'id'=>3, 'name'=>'C', 'next'=>null, )); $this->assertEqual($expected, $this->Stack->top()); } function testLength() { $this->Stack = new TestStack(); $this->assertEqual(3, $this->Stack->length()); } function testPush() { $this->Stack = new TestStack(); $data = array('TestStack'=>array( 'name'=>'D', 'next'=>null, )); $this->Stack->push($data); $expected = array('TestStack'=>array( 'id'=>4, 'name'=>'D', 'next'=>null, )); $top = $this->Stack->top(); $this->assertEqual($expected, $top); $this->assertEqual(4, $this->Stack->length()); $belowTop = $this->Stack->find('first', array('conditions'=>array('TestStack.next'=>$top['TestStack']['id']))); $expected = array('TestStack'=>array( 'id'=>3, 'name'=>'C', 'next'=>4, )); $this->assertEqual($expected, $belowTop); } function testPop() { $this->Stack = new TestStack(); $expected = array('TestStack'=>array( 'id'=>3, 'name'=>'C', 'next'=>null, )); $this->assertEqual($expected, $this->Stack->pop()); $expected = array('TestStack'=>array( 'id'=>2, 'name'=>'B', 'next'=>null, )); $this->assertEqual($expected, $this->Stack->top()); } } ?>