* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); class FormFormatterStub extends sfWidgetFormSchemaFormatter { public function __construct() {} public function translate($subject, $parameters = array()) { return sprintf('translation[%s]', $subject); } } $t = new lime_test(22); $dom = new DomDocument('1.0', 'utf-8'); $dom->validateOnParse = true; // ->render() $t->diag('->render()'); $w = new sfWidgetFormSelect(array('choices' => array('foo' => 'bar', 'foobar' => 'foo'))); $dom->loadHTML($w->render('foo', 'foobar')); $css = new sfDomCssSelector($dom); $t->is($css->matchSingle('#foo option[value="foobar"][selected="selected"]')->getValue(), 'foo', '->render() renders a select tag with the value selected'); $t->is(count($css->matchAll('#foo option')->getNodes()), 2, '->render() renders all choices as option tags'); // value attribute is always mandatory $w = new sfWidgetFormSelect(array('choices' => array('' => 'bar'))); $t->like($w->render('foo', 'foobar'), '/