1
|
|
|
<?php |
2
|
|
|
namespace VatNumberCheck\Test\TestCase\View\Helper; |
3
|
|
|
|
4
|
|
|
use Cake\TestSuite\TestCase; |
5
|
|
|
use Cake\View\View; |
6
|
|
|
use VatNumberCheck\View\Helper\VatNumberCheckHelper; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* VatNumberCheckHelper Test Case. |
10
|
|
|
* |
11
|
|
|
* @property \VatNumberCheck\Test\TestCase\View\Helper $VatNumberCheck |
12
|
|
|
*/ |
13
|
|
|
class VatNumberCheckHelperTest extends TestCase |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* setUp method |
18
|
|
|
* |
19
|
|
|
* @return void |
20
|
|
|
*/ |
21
|
|
|
public function setUp() { |
22
|
|
|
parent::setUp(); |
23
|
|
|
|
24
|
|
|
$View = new View(); |
25
|
|
|
$this->VatNumberCheck = new VatNumberCheckHelper($View); |
|
|
|
|
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* tearDown method |
30
|
|
|
* |
31
|
|
|
* @return void |
32
|
|
|
*/ |
33
|
|
|
public function tearDown() { |
34
|
|
|
unset($this->VatNumberCheck); |
35
|
|
|
|
36
|
|
|
parent::tearDown(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* testInput method |
41
|
|
|
* |
42
|
|
|
* @return void |
43
|
|
|
*/ |
44
|
|
|
public function testInput() { |
45
|
|
|
$fieldName = 'Foo.bar'; |
46
|
|
|
$actual = $this->VatNumberCheck->input($fieldName); |
47
|
|
|
|
48
|
|
|
// Test name and id properties |
49
|
|
|
$this->assertContains('name="Foo[bar]"', $actual); |
50
|
|
|
$this->assertContains('id="foo-bar"', $actual); |
51
|
|
|
|
52
|
|
|
// Test class property -> only + append |
53
|
|
|
$options = []; |
54
|
|
|
$actual = $this->VatNumberCheck->input($fieldName, $options); |
55
|
|
|
$this->assertContains('class="vat-number-check"', $actual); |
56
|
|
|
|
57
|
|
|
$options = ['class' => 'foo-bar']; |
58
|
|
|
$actual = $this->VatNumberCheck->input($fieldName, $options); |
59
|
|
|
$this->assertContains('class="foo-bar vat-number-check"', $actual); |
60
|
|
|
|
61
|
|
|
// Test input type |
62
|
|
|
$options = ['type' => 'radio']; |
63
|
|
|
$actual = $this->VatNumberCheck->input($fieldName, $options); |
64
|
|
|
$this->assertContains('type="text"', $actual); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
} |
68
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..