Ejemplo n.º 1
0
 private function getTestField()
 {
     $db = new \Dewdrop\Db\Adapter\Mock();
     require_once __DIR__ . '/table/DewdropTestFruits.php';
     $table = new \DewdropViewHelperTest\DewdropTestFruits($db);
     $row = $table->createRow();
     $field = $row->field('name');
     return $field;
 }
Ejemplo n.º 2
0
 public function testCanRenderUsingAFieldObject()
 {
     $db = $GLOBALS['dewdrop_pimple']['db'];
     require_once __DIR__ . '/table/DewdropTestFruits.php';
     $table = new \DewdropViewHelperTest\DewdropTestFruits($db);
     $row = $table->createRow();
     $row->field('name')->getOptionPairs()->setTableName('dewdrop_test_animals');
     $this->view->select($row->field('name'));
 }
Ejemplo n.º 3
0
 public function testCanRenderTextareaUsingADbField()
 {
     $db = new \Dewdrop\Db\Adapter\Mock();
     require_once __DIR__ . '/table/DewdropTestFruits.php';
     $table = new \DewdropViewHelperTest\DewdropTestFruits($db);
     $row = $table->createRow();
     $field = $row->field('name');
     $out = $this->view->textarea($field);
     $this->assertMatchesDomQuery('textarea[name="' . $field->getControlName() . '"]', $out);
     $this->assertMatchesDomQuery('textarea[id="' . $field->getHtmlId() . '"]', $out);
 }
Ejemplo n.º 4
0
 public function testCanRenderUseFieldObject()
 {
     $db = new \Dewdrop\Db\Adapter\Mock();
     require_once __DIR__ . '/table/DewdropTestFruits.php';
     $table = new \DewdropViewHelperTest\DewdropTestFruits($db);
     $row = $table->createRow();
     $field = $row->field('name');
     $out = $this->view->wpEditor($field);
     $this->assertMatchesDomQuery('textarea[name="dewdrop_test_fruits:name"]', $out);
     $this->assertMatchesDomQuery('textarea[id="dewdrop_test_fruits_name"]', $out);
 }
Ejemplo n.º 5
0
 public function testCanRenderOpenWithWithFieldObject()
 {
     $db = new \Dewdrop\Db\Adapter\Mock();
     require_once __DIR__ . '/table/DewdropTestFruits.php';
     $table = new \DewdropViewHelperTest\DewdropTestFruits($db);
     $row = $table->createRow();
     $field = $row->field('name');
     $out = $this->view->wpEditRow()->open($field);
     $this->assertMatchesDomQuery('label[for="dewdrop_test_fruits_name"]', $out);
     $this->assertContains('Name', $out);
 }
Ejemplo n.º 6
0
 public function testCanRenderCheckboxUsingADbField()
 {
     $db = new \Dewdrop\Db\Adapter\Mock();
     require_once __DIR__ . '/table/DewdropTestFruits.php';
     $table = new \DewdropViewHelperTest\DewdropTestFruits($db);
     $row = $table->createRow();
     $field = $row->field('is_delicious');
     $out = $this->view->inputCheckbox($field);
     $this->assertMatchesDomQuery('input[name="' . $field->getControlName() . '"]', $out);
     $this->assertMatchesDomQuery('input[id="' . $field->getHtmlId() . '"]', $out);
     $this->assertContains($field->getLabel(), $out);
 }
Ejemplo n.º 7
0
 public function testCanRenderUsingADbFieldArgument()
 {
     $db = new \Dewdrop\Db\Adapter\Mock();
     require_once __DIR__ . '/table/DewdropTestFruits.php';
     $model = new \DewdropViewHelperTest\DewdropTestFruits($db);
     $row = $model->createRow();
     $row->set('name', '#ff0000');
     $out = $this->view->wpColorPicker($row->field('name'));
     $this->assertMatchesDomQuery('input[name="dewdrop_test_fruits:name"]', $out);
     $this->assertMatchesDomQuery('input[id="dewdrop_test_fruits_name"]', $out);
     $this->assertContains('ff0000', $out);
 }