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

HtmlTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testAddClass() 0 19 1
A testTag() 0 11 1
1
<?php
2
3
  namespace Tests\Form\Form\Element;
4
5
  /**
6
   * @author Ivan Shcherbak <[email protected]> 9/17/14
7
   */
8
  class HtmlTest extends \Tests\Form\MainTestCase {
9
10
    public function testAddClass() {
11
      $htmlElement = new \Fiv\Form\Element\Html();
12
13
      $currentClassName = $htmlElement->getAttribute('class');
14
15
      $this->assertEmpty($currentClassName);
16
17
      $htmlElement->addClass('test');
18
      $this->assertEquals('test', $htmlElement->getAttribute('class'));
19
20
      $htmlElement->setAttribute('class', '');
21
      $this->assertEmpty($htmlElement->getAttribute('class'));
22
23
      $htmlElement->setAttribute('class', 'custom_class');
24
      $this->assertEquals("custom_class", $htmlElement->getAttribute('class'));
25
26
      $htmlElement->addClass('other_class');
27
      $this->assertEquals('custom_class other_class', $htmlElement->getAttribute('class'));
28
    }
29
30
31
    public function testTag() {
32
33
      $imgHtml = \Fiv\Form\Element\Html::tag('img', [
34
        'src' => "/images/logo.png",
35
        'title' => "logo",
36
      ]);
37
38
      $this->assertTrue((boolean) preg_match("!/>!", $imgHtml));
39
      $this->assertTrue((boolean) preg_match("!title=!", $imgHtml));
40
      $this->assertTrue((boolean) preg_match("!src=!", $imgHtml));
41
    }
42
43
  }
44