|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Kunstmaan\FormBundle\Tests\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Kunstmaan\FormBundle\Entity\FormSubmission; |
|
6
|
|
|
use Kunstmaan\FormBundle\Entity\FormSubmissionField; |
|
7
|
|
|
use Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\StringFormSubmissionField; |
|
8
|
|
|
use PHPUnit\Framework\TestCase; |
|
9
|
|
|
|
|
10
|
|
|
class Plain extends FormSubmissionField |
|
11
|
|
|
{ |
|
12
|
|
|
} |
|
13
|
|
|
|
|
14
|
|
|
class FormSubmissionFieldTest extends TestCase |
|
|
|
|
|
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @var StringFormSubmissionField |
|
18
|
|
|
*/ |
|
19
|
|
|
protected $object; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Sets up the fixture, for example, opens a network connection. |
|
23
|
|
|
* This method is called before a test is executed. |
|
24
|
|
|
*/ |
|
25
|
|
|
protected function setUp() |
|
26
|
|
|
{ |
|
27
|
|
|
$this->object = new StringFormSubmissionField(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function testSetGetId() |
|
31
|
|
|
{ |
|
32
|
|
|
$object = $this->object; |
|
33
|
|
|
$id = 123; |
|
34
|
|
|
$object->setId($id); |
|
35
|
|
|
$this->assertEquals($id, $object->getId()); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function testSetGetFieldName() |
|
39
|
|
|
{ |
|
40
|
|
|
$object = $this->object; |
|
41
|
|
|
$fieldName = 'someFieldName'; |
|
42
|
|
|
$object->setFieldName($fieldName); |
|
43
|
|
|
$this->assertEquals($fieldName, $object->getFieldName()); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function testSetGetLabel() |
|
47
|
|
|
{ |
|
48
|
|
|
$object = $this->object; |
|
49
|
|
|
$label = 'Some label'; |
|
50
|
|
|
$object->setLabel($label); |
|
51
|
|
|
$this->assertEquals($label, $object->getLabel()); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function testSetGetSequence() |
|
55
|
|
|
{ |
|
56
|
|
|
$object = $this->object; |
|
57
|
|
|
$label = 'Some label'; |
|
58
|
|
|
$object->setSequence($label); |
|
59
|
|
|
$this->assertEquals($label, $object->getSequence()); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function testSetGetSubmission() |
|
63
|
|
|
{ |
|
64
|
|
|
$object = $this->object; |
|
65
|
|
|
$submission = new FormSubmission(); |
|
66
|
|
|
$submission->setId(123); |
|
67
|
|
|
$object->setSubmission($submission); |
|
68
|
|
|
$retrievedSubmission = $object->getSubmission(); |
|
69
|
|
|
$this->assertEquals($submission, $retrievedSubmission); |
|
70
|
|
|
$this->assertEquals($submission->getId(), $retrievedSubmission->getId()); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function testToString() |
|
74
|
|
|
{ |
|
75
|
|
|
$plainObject = new Plain(); |
|
76
|
|
|
$stringValue = $plainObject->__toString(); |
|
77
|
|
|
$this->assertEquals('FormSubmission Field', $stringValue); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.