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; }
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')); }
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); }
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); }
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); }
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); }
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); }