Пример #1
0
 public function testGetWithoutResourceLog()
 {
     $result = $this->Logger->get(1, false);
     $expected = array('Logger' => array('id' => 1, 'responsible_id' => 0, 'model_alias' => 'Auditable.User', 'model_id' => 1, 'log_detail_id' => 1, 'type' => 1, 'created' => '2012-03-08 15:20:10', 'modified' => '2012-03-08 15:20:10'), 'LogDetail' => array('id' => 1, 'difference' => '{}', 'statement' => '', 'created' => '2012-03-08 15:20:10', 'modified' => '2012-03-08 15:20:10'), 'Responsible' => array());
     $this->assertEqual($result, $expected);
     AuditableConfig::$responsibleModel = null;
     $result = $this->Logger->get(1, false);
     $expected = array('Logger' => array('id' => 1, 'responsible_id' => 0, 'model_alias' => 'Auditable.User', 'model_id' => 1, 'log_detail_id' => 1, 'type' => 1, 'created' => '2012-03-08 15:20:10', 'modified' => '2012-03-08 15:20:10'), 'LogDetail' => array('id' => 1, 'difference' => '{}', 'statement' => '', 'created' => '2012-03-08 15:20:10', 'modified' => '2012-03-08 15:20:10'), 'Responsible' => array());
     $this->assertEqual($result, $expected);
 }
Пример #2
0
 public function testMofify()
 {
     AuditableConfig::$responsibleId = 2;
     $this->Model->save(array('id' => 1, 'username' => 'userChanged'));
     $log = $this->Logger->find('first', array('order' => array("Logger.{$this->Logger->primaryKey}" => 'desc'), 'fields' => array("Logger.{$this->Logger->primaryKey}")));
     $result = $this->Logger->get($log['Logger'][$this->Logger->primaryKey]);
     $this->assertEqual($result['Logger']['type'], '2');
     $difference = call_user_func(AuditableConfig::$serialize, array('username' => array('old' => 'userA', 'new' => 'userChanged')));
     $this->assertEqual($result['LogDetail']['difference'], $difference);
     if (!$this->_isNoSQL) {
         $this->assertRegExp('/^UPDATE.*/', $result['LogDetail']['statement']);
     }
 }