示例#1
0
 /**
  * @covers ::errorSummary
  */
 public function testErrorSummary()
 {
     $model = new FakeModel();
     $model->addError('login', 'foobar');
     $output = Html::errorSummary($model);
     $this->assertTag(['tag' => 'div', 'attributes' => ['class' => 'regexp:/alert/']], $output);
 }
 public function testValidatorAllow()
 {
     $this->setResponse(1, '');
     $model = new FakeModel();
     $model->message = 'example1';
     $model->validate();
     $this->assertFalse($model->hasErrors('message'));
 }
 public function testInlineGroup()
 {
     $model = new FakeModel();
     $fieldData = 'here_will_be_field';
     $attribute = 'login';
     $model->addError($attribute, 'simple error text');
     $form = $this->makeWidget();
     $method = new ReflectionMethod($form, 'inlineGroup');
     $method->setAccessible(true);
     $rowOptions = [];
     $methodInitGroupOptions = new ReflectionMethod($form, 'initOptions');
     $methodInitGroupOptions->setAccessible(true);
     $methodInitGroupOptions->invokeArgs($form, array(&$rowOptions));
     $rowOptions['prepend'] = 'before';
     $rowOptions['prependOptions'] = array('class' => 'bar');
     $rowOptions['append'] = 'after';
     $rowOptions['appendOptions'] = array('class' => 'apple');
     ob_start();
     $method->invokeArgs($form, array(&$fieldData, &$model, &$attribute, &$rowOptions));
     $data = ob_get_clean();
     $doc = new DOMDocument();
     $doc->loadHTML($data);
     $actual = new DOMXPath($doc);
     $matches = $actual->query('//div[contains(@class, "input-group") and contains(@class, "input-group") and text()="' . $fieldData . '"]' . '/span[contains(@class,"input-group-addon") and contains(@class, "' . $rowOptions['prependOptions']['class'] . '") and text()="' . $rowOptions['prepend'] . '"]' . '/following-sibling::span[contains(@class,"input-group-addon") and contains(@class, "' . $rowOptions['appendOptions']['class'] . '") and text()="' . $rowOptions['append'] . '"]');
     $this->assertEquals(1, $matches->length);
 }
 public function isClean(FakeModel $model)
 {
     return '' !== $model->getContent() && null !== $model->getContent();
 }