Completed
Pull Request — master (#28)
by Vitaliy
03:13
created

InputTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testElementRendering() 0 6 1
A testHandleRequest() 0 9 1
1
<?php
2
3
4
  namespace Tests\Fiv\Form\Element;
5
6
7
  use Fiv\Form\Element\Input;
8
  use Fiv\Form\RequestContext;
9
10
  class InputTest extends \PHPUnit_Framework_TestCase {
11
12
13
    public function testElementRendering() {
14
      $input = new Input();
15
      $input->setType('text');
16
      $input->setValue('value');
17
      $this->assertContains('<input type="text" value="value" ', $input->render());
18
    }
19
20
21
    public function testHandleRequest() {
22
      $input = new Input();
23
      $input->setName('email');
24
25
      $input->handleRequestContext(new RequestContext(RequestContext::METHOD_POST, ['email' => '[email protected]']));
26
      $this->assertEquals('[email protected]', $input->getValue());
27
      $input->handleRequestContext(new RequestContext(RequestContext::METHOD_POST, []));
28
      $this->assertNull($input->getValue());
29
    }
30
  }