These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 Symfony\Component\DependencyInjection\Container; |
||
9 | use Symfony\Component\Form\Form; |
||
10 | use Symfony\Component\Form\FormBuilder; |
||
11 | use Symfony\Component\HttpFoundation\Request; |
||
12 | |||
13 | class Plain extends FormSubmissionField |
||
14 | { |
||
15 | } |
||
16 | |||
17 | /** |
||
18 | * Generated by PHPUnit_SkeletonGenerator on 2012-09-20 at 15:15:06. |
||
19 | */ |
||
20 | class FormSubmissionFieldTest extends \PHPUnit_Framework_TestCase |
||
0 ignored issues
–
show
|
|||
21 | { |
||
22 | /** |
||
23 | * @var StringFormSubmissionField |
||
24 | */ |
||
25 | protected $object; |
||
26 | |||
27 | /** |
||
28 | * Sets up the fixture, for example, opens a network connection. |
||
29 | * This method is called before a test is executed. |
||
30 | */ |
||
31 | protected function setUp() |
||
32 | { |
||
33 | $this->object = new StringFormSubmissionField(); |
||
34 | } |
||
35 | |||
36 | public function testSetGetId() |
||
37 | { |
||
38 | $object = $this->object; |
||
39 | $id = 123; |
||
40 | $object->setId($id); |
||
41 | $this->assertEquals($id, $object->getId()); |
||
42 | } |
||
43 | |||
44 | public function testSetGetFieldName() |
||
45 | { |
||
46 | $object = $this->object; |
||
47 | $fieldName = 'someFieldName'; |
||
48 | $object->setFieldName($fieldName); |
||
49 | $this->assertEquals($fieldName, $object->getFieldName()); |
||
50 | } |
||
51 | |||
52 | public function testSetGetLabel() |
||
53 | { |
||
54 | $object = $this->object; |
||
55 | $label = 'Some label'; |
||
56 | $object->setLabel($label); |
||
57 | $this->assertEquals($label, $object->getLabel()); |
||
58 | } |
||
59 | |||
60 | public function testSetGetSequence() |
||
61 | { |
||
62 | $object = $this->object; |
||
63 | $label = 'Some label'; |
||
64 | $object->setSequence($label); |
||
65 | $this->assertEquals($label, $object->getSequence()); |
||
66 | } |
||
67 | |||
68 | public function testOnValidPost() |
||
69 | { |
||
70 | $object = $this->object; |
||
71 | $form = $this->getMockBuilder(Form::class) |
||
72 | ->disableOriginalConstructor() |
||
73 | ->getMock(); |
||
74 | |||
75 | $builder = $this->getMockBuilder(FormBuilder::class) |
||
76 | ->disableOriginalConstructor() |
||
77 | ->getMock(); |
||
78 | |||
79 | $request = new Request(); |
||
80 | |||
81 | $container = $this->getMockBuilder(Container::class) |
||
82 | ->disableOriginalConstructor() |
||
83 | ->getMock(); |
||
84 | |||
85 | $container->expects($this->any()) |
||
86 | ->method('getParameter') |
||
87 | ->will($this->returnValue('whatever')); |
||
88 | |||
89 | $object->onValidPost($form, $builder, $request, $container); |
||
90 | } |
||
91 | |||
92 | public function testSetGetSubmission() |
||
93 | { |
||
94 | $object = $this->object; |
||
95 | $submission = new FormSubmission(); |
||
96 | $submission->setId(123); |
||
97 | $object->setSubmission($submission); |
||
98 | $retrievedSubmission = $object->getSubmission(); |
||
99 | $this->assertEquals($submission, $retrievedSubmission); |
||
100 | $this->assertEquals($submission->getId(), $retrievedSubmission->getId()); |
||
101 | } |
||
102 | |||
103 | public function testToString() |
||
104 | { |
||
105 | $plainObject = new Plain(); |
||
106 | $stringValue = $plainObject->__toString(); |
||
107 | $this->assertEquals('FormSubmission Field', $stringValue); |
||
108 | } |
||
109 | } |
||
110 |
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.