Completed
Push — updateZf3 ( 3c9737...c74b15 )
by Andreas
01:40
created

ContactFormTest::testForValidForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Org_Heigl\ContactTest\Form;
4
5
use PHPUnit\Framework\TestCase;
6
use Org_Heigl\Contact\Form\ContactForm;
7
8
/**
9
 * ContactForm test case.
10
 */
11
class ContactFormTest extends TestCase
12
{
13
	
14
	/**
15
	 *
16
	 * @var ContactForm
17
	 */
18
	private $ContactForm;
19
	
20
	/**
21
	 * Prepares the environment before running a test.
22
	 */
23
	protected function setUp() {
24
		parent::setUp ();
25
		
26
		// TODO Auto-generated ContactFormTest::setUp()
27
		
28
		$this->ContactForm = new ContactForm(/* parameters */);
29
		$this->ContactForm->init();
30
		
31
	}
32
	
33
	/**
34
	 * Cleans up the environment after running a test.
35
	 */
36
	protected function tearDown() {
37
		// TODO Auto-generated ContactFormTest::tearDown()
38
		$this->ContactForm = null;
39
		
40
		parent::tearDown ();
41
	}
42
	
43
	/**
44
	 * test Validation of Form
45
	 * 
46
	 * @dataProvider provider
47
	 * @return void
48
	 */
49
    public function testFormValidation($res, $val)
50
    {
51
	    $val['csrf'] = $this->ContactForm->get('csrf')->getValue();
52
        $this->ContactForm->setData($val);
53
        $this->assertEquals($res, $this->ContactForm->isValid());
54
    }
55
56
	public function provider()
57
	{
58
		return array(
59
		        array(true, array(
60
					'from'=>'[email protected]',
61
					'subject' => 'my subject',
62
					'body' => 'My Message',
63
					'country' => '',
64
				)),
65
			    array(false, array(
66
					'from'=>'foo',
67
					'subject' => 'my subject',
68
					'body' => 'My Message',
69
					'country' => '',
70
				)),	
71
			array(false, array(
72
					'from'=>'[email protected]',
73
					'subject' => '',
74
					'body' => 'My Message',
75
					'country' => '',
76
				)),	
77
			array(false, array(
78
					'from'=>'[email protected]',
79
					'subject' => 'my subject',
80
					'body' => '',
81
					'country' => '',
82
				)),	
83
			array(false, array(
84
					'from'=>'[email protected]',
85
					'subject' => 'my subject',
86
					'body' => 'My message',
87
					'country' => 'foo',
88
				)),	
89
			array(false, array(
90
					'subject' => 'my subject',
91
					'body' => 'My message',
92
					'country' => 'foo',
93
				)),	
94
			array(false, array(
95
					'from'=>'[email protected]',
96
					'subject' => 'my subject',
97
					'body' => 'My message',
98
				)),	
99
		);//*/
100
	}
101
}
102
103