Inheritance: extends lithium\data\Model
Exemple #1
0
 public function testFormDataBinding()
 {
     $this->expectException('The data connection default is not configured');
     MockFormPost::config(array('connection' => false));
     $record = new Record(array('model' => 'lithium\\tests\\mocks\\template\\helper\\MockFormPost', 'data' => array('id' => '5', 'author_id' => '2', 'title' => 'This is a saved post', 'body' => 'This is the body of the saved post')));
     $result = $this->form->create($record);
     $this->assertTags($result, array('form' => array('action' => "{$this->base}posts", 'method' => 'post')));
     $result = $this->form->text('title');
     $this->assertTags($result, array('input' => array('type' => 'text', 'name' => 'title', 'value' => 'This is a saved post')));
     $result = $this->form->end();
     $this->assertTags($result, array('/form'));
     $result = $this->form->text('title');
     $this->assertTags($result, array('input' => array('type' => 'text', 'name' => 'title')));
 }
Exemple #2
0
 public function testFormDataBinding()
 {
     try {
         MockFormPost::config(array('meta' => array('connection' => false)));
     } catch (Exception $e) {
         MockFormPost::config(array('meta' => array('connection' => false)));
     }
     $record = new Record(array('model' => $this->_model, 'data' => array('id' => '5', 'author_id' => '2', 'title' => 'This is a saved post', 'body' => 'This is the body of the saved post', 'zeroInt' => 0, 'zeroString' => "0")));
     $result = $this->form->create($record);
     $this->assertTags($result, array('form' => array('action' => "{$this->base}posts", 'method' => 'post')));
     $result = $this->form->text('title');
     $this->assertTags($result, array('input' => array('type' => 'text', 'name' => 'title', 'value' => 'This is a saved post', 'id' => 'MockFormPostTitle')));
     $result = $this->form->text('zeroInt');
     $this->assertTags($result, array('input' => array('type' => 'text', 'name' => 'zeroInt', 'value' => '0', 'id' => 'MockFormPostZeroInt')));
     $result = $this->form->text('zeroString');
     $this->assertTags($result, array('input' => array('type' => 'text', 'name' => 'zeroString', 'value' => '0', 'id' => 'MockFormPostZeroString')));
     $this->assertEqual('</form>', $this->form->end());
     $this->assertTags($this->form->text('title'), array('input' => array('type' => 'text', 'name' => 'title', 'id' => 'Title')));
 }