ResetBehaviorTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. App::uses('ResetBehavior', 'Tools.Model/Behavior');
  3. App::uses('MyCakeTestCase', 'Tools.TestSuite');
  4. App::uses('AppModel', 'Model');
  5. class ResetBehaviorTest extends MyCakeTestCase {
  6. public $ResetBehavior;
  7. public $Model;
  8. public $fixtures = array('core.comment');
  9. public function setUp() {
  10. parent::setUp();
  11. $this->ResetBehavior = new ResetBehavior();
  12. $this->Model = ClassRegistry::init('MyComment');
  13. $this->Model->Behaviors->attach('Tools.Reset');
  14. }
  15. public function testObject() {
  16. $this->assertTrue(is_object($this->ResetBehavior));
  17. $this->assertInstanceOf('ResetBehavior', $this->ResetBehavior);
  18. }
  19. public function testResetRecords() {
  20. $x = $this->Model->find('first', array('order' => array('updated'=>'DESC')));
  21. $this->assertTrue($x['MyComment']['updated'] < '2007-12-31');
  22. $result = $this->Model->resetRecords();
  23. $this->assertTrue($result);
  24. $x = $this->Model->find('first', array('order' => array('updated'=>'ASC')));
  25. $this->assertTrue($x['MyComment']['updated'] > (date('Y')-1) . '-12-31');
  26. }
  27. }
  28. class MyComment extends AppModel {
  29. public $fixture = 'core.comment';
  30. public $useTable = 'comments';
  31. }