1
|
|
|
<?php |
2
|
|
|
App::uses('View', 'View'); |
3
|
|
|
App::uses('Helper', 'View'); |
4
|
|
|
App::uses('VatNumberCheckHelper', 'VatNumberCheck.View/Helper'); |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* VatNumberCheckHelper Test Case |
8
|
|
|
* |
9
|
|
|
* @property VatNumberCheck.VatNumberCheckHelper $VatNumberCheck |
10
|
|
|
*/ |
|
|
|
|
11
|
|
|
class VatNumberCheckHelperTest extends CakeTestCase { |
|
|
|
|
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* setUp method |
15
|
|
|
* |
16
|
|
|
* @return void |
17
|
|
|
*/ |
18
|
|
|
public function setUp() { |
19
|
|
|
parent::setUp(); |
20
|
|
|
|
21
|
|
|
$View = new View(); |
|
|
|
|
22
|
|
|
$this->VatNumberCheck = new VatNumberCheckHelper($View); |
|
|
|
|
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* tearDown method |
27
|
|
|
* |
28
|
|
|
* @return void |
29
|
|
|
*/ |
30
|
|
|
public function tearDown() { |
31
|
|
|
unset($this->VatNumberCheck); |
32
|
|
|
|
33
|
|
|
parent::tearDown(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* testInput method |
38
|
|
|
* |
39
|
|
|
* @return void |
40
|
|
|
*/ |
41
|
|
|
public function testInput() { |
42
|
|
|
$fieldName = 'Foo.bar'; |
43
|
|
|
$result = $this->VatNumberCheck->input($fieldName); |
44
|
|
|
|
45
|
|
|
// Test name and id properties |
46
|
|
|
$this->assertPattern('/name\=\"data\[Foo\]\[bar\]\"/', $result); |
47
|
|
|
$this->assertPattern('/id\=\"FooBar\"/', $result); |
48
|
|
|
|
49
|
|
|
// Test class property -> only + append |
50
|
|
|
$options = []; |
51
|
|
|
$result = $this->VatNumberCheck->input($fieldName, $options); |
52
|
|
|
$this->assertPattern('/class\=\"vat-number-check\"/', $result); |
53
|
|
|
|
54
|
|
|
$options = ['class' => 'foo-bar']; |
55
|
|
|
$result = $this->VatNumberCheck->input($fieldName, $options); |
56
|
|
|
$this->assertPattern('/class\=\"foo-bar vat-number-check\"/', $result); |
57
|
|
|
|
58
|
|
|
// Test input type |
59
|
|
|
$options = ['type' => 'radio']; |
60
|
|
|
$result = $this->VatNumberCheck->input($fieldName, $options); |
61
|
|
|
$this->assertPattern('/type\=\"text\"/', $result); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
} |
65
|
|
|
|