Completed
Push — master ( 250c3f...5d0c73 )
by Shcherbak
15:55
created

TextAreaTest::testAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
  namespace Tests\Form\Form;
4
5
  use Fiv\Form\Filter\Trim;
6
  use Fiv\Form\Form;
7
8
  /**
9
   * @package Tests\Form\Form
10
   */
11
  class TextAreaTest extends \Tests\Form\MainTestCase {
12
13
    /**
14
     * @return \Fiv\Form\TextArea
15
     */
16
    protected function getElement() {
17
      $form = new Form();
18
      return $form->textarea("test");
19
    }
20
21
    public function testRender() {
22
      $element = $this->getElement();
23
      $this->assertContains("<textarea", (string)$element);
24
      $this->assertContains("</textarea", (string)$element);
25
26
      $element->setValue("custom data");
27
      $this->assertContains(">custom data<", $element->render());
28
    }
29
30
    public function testAttributes() {
31
      $element = $this->getElement();
32
      $element->setAttributes([]);
33
      $this->assertEquals('', $element->renderAttributes());
34
    }
35
36
    public function testFilter() {
37
      $element = $this->getElement();
38
      $element->addFilter(new Trim());
39
40
      $this->assertEmpty($element->getValue());
41
42
      $element->setValue("test_value");
43
      $this->assertEquals("test_value", $element->getValue());
44
45
      $element->setValue("  other value");
46
      $this->assertEquals("other value", $element->getValue());
47
    }
48
49
  }