Inheritance: extends Phalcon\Mvc\Model
Beispiel #1
0
 public function testSnapshotRenamed()
 {
     $this->specify("Renamed snapshots don't work", function () {
         $snapshots = array(1 => array('code' => '1', 'theName' => 'Robotina', 'theType' => 'mechanical', 'theYear' => '1972', 'theDatetime' => '1972-01-01 00:00:00', 'theDeleted' => null, 'theText' => 'text'), 2 => array('code' => '2', 'theName' => 'Astro Boy', 'theType' => 'mechanical', 'theYear' => '1952', 'theDatetime' => '1952-01-01 00:00:00', 'theDeleted' => null, 'theText' => 'text'), 3 => array('code' => '3', 'theName' => 'Terminator', 'theType' => 'cyborg', 'theYear' => '2029', 'theDatetime' => '2029-01-01 00:00:00', 'theDeleted' => null, 'theText' => 'text'));
         foreach (SnapshotRobotters::find(array('order' => 'code')) as $robot) {
             expect($robot->hasSnapshotData())->true();
             expect($snapshots[$robot->code])->equals($robot->getSnapshotData());
         }
         foreach (SnapshotRobotters::find(array('order' => 'code')) as $robot) {
             $robot->theName = 'Some';
             $robot->theYear = 1999;
             expect($robot->hasChanged('theName'))->true();
             expect($robot->hasChanged('theYear'))->true();
             expect($robot->hasChanged('theType'))->false();
             expect($robot->hasChanged())->true();
         }
         foreach (SnapshotRobotters::find(array('order' => 'code')) as $robot) {
             $robot->theYear = $robot->theYear;
             expect($robot->hasChanged('theYear'))->false();
             expect($robot->hasChanged())->false();
         }
         foreach (SnapshotRobotters::find(array('order' => 'code')) as $robot) {
             $robot->theName = 'Little';
             $robot->theYear = 2005;
             expect($robot->getChangedFields())->equals(array('theName', 'theYear'));
         }
     });
 }