Completed
Push — master ( bd2863...897b5a )
by Shcherbak
45:04 queued 30:10
created

TextAreaTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 39
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getElement() 0 4 1
A testRender() 0 8 1
A testAttributes() 0 5 1
A testFilter() 0 12 1
1
<?php
2
3
  namespace Tests\Fiv\Form\Element;
4
5
  use Fiv\Form\Filter\Trim;
6
  use Fiv\Form\Form;
7
8
  /**
9
   * @package Tests\Form\Form
10
   */
11
  class TextAreaTest extends \PHPUnit_Framework_TestCase {
12
13
    /**
14
     * @return \Fiv\Form\Element\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
  }