예제 #1
0
파일: modelTest.php 프로젝트: cnzin/think
 public function testMagicMethods()
 {
     $model = new Model('user', $this->getConfig());
     $model->data("first=a&last=z");
     $model->username = '******';
     $data = ['first' => 'a', 'last' => 'z', 'username' => 'test'];
     $this->assertEquals($data, $model->data());
     $this->assertEquals('a', $model->first);
     $this->assertTrue(isset($model->last));
     unset($model->username);
     $this->assertTrue(!isset($model->username));
     $this->assertEquals(2, $model->count());
     $info = $model->getByUsername('test');
     $this->assertEquals(1, $info['id']);
     $id = $model->getFieldByUsername('test', 'id');
     $this->assertEquals(1, $id);
     $id = $model->getFieldByUsername('test', 'id');
     $this->assertEquals(1, $id);
 }