6
6
7
7
class DefaultControllerFunctionalTest extends WebTestCase
8
8
{
9
- public function testStatus () {
10
- $ client = static ::createClient ();
9
+ public function testStatus ()
10
+ {
11
+ $ client = static ::createClient ();
11
12
12
- $ client ->request ('GET ' , '/status ' );
13
+ $ client ->request ('GET ' , '/status ' );
13
14
14
- $ this ->assertEquals ($ client ->getResponse ()->getContent (), '{"success":true,"status":"OK"} ' );
15
+ $ this ->assertEquals ($ client ->getResponse ()->getContent (), '{"success":true,"status":"OK"} ' );
15
16
16
- }
17
+ }
17
18
18
- public function testInvalidKey () {
19
- $ client = static ::createClient ();
19
+ public function testInvalidKey ()
20
+ {
21
+ $ client = static ::createClient ();
20
22
21
- $ client ->request ('GET ' , '/inValidKey/v1 ' );
23
+ $ client ->request ('GET ' , '/inValidKey/v1 ' );
22
24
23
- $ this ->assertEquals ($ client ->getResponse ()->getContent (), '{"success":false,"step":0,"message":"Invalid authorization key."} ' );
25
+ $ this ->assertEquals ($ client ->getResponse ()->getContent (), '{"success":false,"step":0,"message":"Invalid authorization key."} ' );
24
26
25
- }
27
+ }
26
28
27
- public function testInvalidAPI () {
28
- $ client = static ::createClient ();
29
+ public function testInvalidAPI ()
30
+ {
31
+ $ client = static ::createClient ();
29
32
30
- $ authorizationKey = $ client ->getContainer ()->getParameter ("authorizationKey " );
33
+ $ authorizationKey = $ client ->getContainer ()->getParameter ("authorizationKey " );
31
34
32
- $ client ->request ('GET ' , '/ ' . $ authorizationKey. '/v666 ' );
35
+ $ client ->request ('GET ' , '/ ' . $ authorizationKey . '/v666 ' );
33
36
34
- $ this ->assertEquals ($ client ->getResponse ()->getContent (), '{"success":false,"step":0,"message":"Invalid API version."} ' );
37
+ $ this ->assertEquals ($ client ->getResponse ()->getContent (), '{"success":false,"step":0,"message":"Invalid API version."} ' );
35
38
36
- }
39
+ }
37
40
38
- public function testInvalidInput () {
39
- $ client = static ::createClient ();
41
+ public function testInvalidInput ()
42
+ {
43
+ $ client = static ::createClient ();
40
44
41
- $ authorizationKey = $ client ->getContainer ()->getParameter ("authorizationKey " );
45
+ $ authorizationKey = $ client ->getContainer ()->getParameter ("authorizationKey " );
42
46
43
- $ client ->request ('GET ' , '/ ' . $ authorizationKey. '/v1 ' );
47
+ $ client ->request ('GET ' , '/ ' . $ authorizationKey . '/v1 ' );
44
48
45
- $ this ->assertEquals ($ client ->getResponse ()->getContent (), '{"success":false,"step":0,"message":"Invalid input."} ' );
49
+ $ this ->assertEquals ($ client ->getResponse ()->getContent (), '{"success":false,"step":0,"message":"Invalid input."} ' );
46
50
47
- }
51
+ }
48
52
49
- public function testBlinkUnoSyntaxCheck () {
50
- $ files = array (array ("filename " => "Blink.ino " , "content " => "int led = 13; \nvoid setup() {pinMode(led, OUTPUT);} \nvoid loop() { \ndigitalWrite(led, HIGH); \ndelay(1000); \ndigitalWrite(led, LOW); \ndelay(1000); \n} \n" ));
51
- $ format = "syntax " ;
52
- $ version = "105 " ;
53
- $ libraries = array ();
54
- $ build = array ("mcu " => "atmega328p " , "f_cpu " => "16000000 " , "core " => "arduino " , "variant " => "standard " );
53
+ public function testBlinkUnoSyntaxCheck ()
54
+ {
55
+ $ files = array (array ("filename " => "Blink.ino " , "content " => "int led = 13; \nvoid setup() {pinMode(led, OUTPUT);} \nvoid loop() { \ndigitalWrite(led, HIGH); \ndelay(1000); \ndigitalWrite(led, LOW); \ndelay(1000); \n} \n" ));
56
+ $ format = "syntax " ;
57
+ $ version = "105 " ;
58
+ $ libraries = array ();
59
+ $ build = array ("mcu " => "atmega328p " , "f_cpu " => "16000000 " , "core " => "arduino " , "variant " => "standard " );
55
60
56
- $ data = json_encode (array ("files " => $ files , "format " => $ format , "version " => $ version , "libraries " => $ libraries , "build " => $ build ));
61
+ $ data = json_encode (array ("files " => $ files , "format " => $ format , "version " => $ version , "libraries " => $ libraries , "build " => $ build ));
57
62
58
- $ client = static ::createClient ();
63
+ $ client = static ::createClient ();
59
64
60
- $ authorizationKey = $ client ->getContainer ()->getParameter ("authorizationKey " );
65
+ $ authorizationKey = $ client ->getContainer ()->getParameter ("authorizationKey " );
61
66
62
- $ client ->request ('POST ' , '/ ' . $ authorizationKey. '/v1 ' , array (),array (),array (),$ data );
67
+ $ client ->request ('POST ' , '/ ' . $ authorizationKey . '/v1 ' , array (), array (), array (), $ data );
63
68
64
- $ response = json_decode ($ client ->getResponse ()->getContent (), true );
69
+ $ response = json_decode ($ client ->getResponse ()->getContent (), true );
65
70
66
- $ this ->assertEquals ($ response ["success " ], true );
67
- $ this ->assertTrue (is_numeric ($ response ["time " ]));
71
+ $ this ->assertEquals ($ response ["success " ], true );
72
+ $ this ->assertTrue (is_numeric ($ response ["time " ]));
68
73
69
- }
74
+ }
70
75
71
- public function testBlinkUnoCompile () {
72
- $ files = array (array ("filename " => "Blink.ino " , "content " => "\nint led = 13; \nvoid setup() { \npinMode(led, OUTPUT); \n} \nvoid loop() { \ndigitalWrite(led, HIGH); \ndelay(1000); \ndigitalWrite(led, LOW); \ndelay(1000); \n} \n" ));
73
- $ format = "binary " ;
74
- $ version = "105 " ;
75
- $ libraries = array ();
76
- $ build = array ("mcu " => "atmega328p " , "f_cpu " => "16000000 " , "core " => "arduino " , "variant " => "standard " );
76
+ public function testBlinkUnoCompile ()
77
+ {
78
+ $ files = array (array ("filename " => "Blink.ino " , "content " => "\nint led = 13; \nvoid setup() { \npinMode(led, OUTPUT); \n} \nvoid loop() { \ndigitalWrite(led, HIGH); \ndelay(1000); \ndigitalWrite(led, LOW); \ndelay(1000); \n} \n" ));
79
+ $ format = "binary " ;
80
+ $ version = "105 " ;
81
+ $ libraries = array ();
82
+ $ build = array ("mcu " => "atmega328p " , "f_cpu " => "16000000 " , "core " => "arduino " , "variant " => "standard " );
77
83
78
- $ data = json_encode (array ("files " => $ files , "format " => $ format , "version " => $ version , "libraries " => $ libraries , "build " => $ build ));
84
+ $ data = json_encode (array ("files " => $ files , "format " => $ format , "version " => $ version , "libraries " => $ libraries , "build " => $ build ));
79
85
80
- $ client = static ::createClient ();
86
+ $ client = static ::createClient ();
81
87
82
- $ authorizationKey = $ client ->getContainer ()->getParameter ("authorizationKey " );
88
+ $ authorizationKey = $ client ->getContainer ()->getParameter ("authorizationKey " );
83
89
84
- $ client ->request ('POST ' , '/ ' . $ authorizationKey. '/v1 ' , array (), array (), array (), $ data );
90
+ $ client ->request ('POST ' , '/ ' . $ authorizationKey . '/v1 ' , array (), array (), array (), $ data );
85
91
86
- $ response = json_decode ($ client ->getResponse ()->getContent (), true );
92
+ $ response = json_decode ($ client ->getResponse ()->getContent (), true );
87
93
88
- $ this ->assertEquals ($ response ["success " ], true );
89
- $ this ->assertTrue (is_numeric ($ response ["time " ]));
90
- $ this ->assertTrue (is_numeric ($ response ["size " ]));
94
+ $ this ->assertEquals ($ response ["success " ], true );
95
+ $ this ->assertTrue (is_numeric ($ response ["time " ]));
96
+ $ this ->assertTrue (is_numeric ($ response ["size " ]));
91
97
92
98
$ objectFilesPath = $ client ->getContainer ()->getParameter ('temp_dir ' ) . '/ ' . $ client ->getContainer ()->getParameter ('objdir ' );
93
99
$ coreObjectLibrary = glob ("$ objectFilesPath/*__v105__hardware__arduino__cores__arduino________atmega328p_16000000_arduino_standard_null_null_______core.a " );
94
100
$ this ->assertTrue (count ($ coreObjectLibrary ) > 0 );
95
- }
101
+ }
96
102
97
- public function testBlinkUnoSyntaxCheckError () {
98
- $ files = array (array ("filename " => "Blink.ino " , "content " => "\nint led = 13 \nvoid setup() { \npinMode(led, OUTPUT); \npinMode(led); \n} \nvoid loop() { \ndigitalWrite(led, HIGH); \ndelay(1000); \ndigitalWrite(led, LOW); \ndelay(1000); \n} \n" ));
99
- $ format = "syntax " ;
100
- $ version = "105 " ;
101
- $ libraries = array ();
102
- $ build = array ("mcu " => "atmega328p " , "f_cpu " => "16000000 " , "core " => "arduino " , "variant " => "standard " );
103
+ public function testBlinkUnoSyntaxCheckError ()
104
+ {
105
+ $ files = array (array ("filename " => "Blink.ino " , "content " => "\nint led = 13 \nvoid setup() { \npinMode(led, OUTPUT); \npinMode(led); \n} \nvoid loop() { \ndigitalWrite(led, HIGH); \ndelay(1000); \ndigitalWrite(led, LOW); \ndelay(1000); \n} \n" ));
106
+ $ format = "syntax " ;
107
+ $ version = "105 " ;
108
+ $ libraries = array ();
109
+ $ build = array ("mcu " => "atmega328p " , "f_cpu " => "16000000 " , "core " => "arduino " , "variant " => "standard " );
103
110
104
- $ data = json_encode (array ("files " => $ files , "format " => $ format , "version " => $ version , "libraries " => $ libraries , "build " => $ build ));
111
+ $ data = json_encode (array ("files " => $ files , "format " => $ format , "version " => $ version , "libraries " => $ libraries , "build " => $ build ));
105
112
106
- $ client = static ::createClient ();
113
+ $ client = static ::createClient ();
107
114
108
- $ authorizationKey = $ client ->getContainer ()->getParameter ("authorizationKey " );
115
+ $ authorizationKey = $ client ->getContainer ()->getParameter ("authorizationKey " );
109
116
110
- $ client ->request ('POST ' , '/ ' . $ authorizationKey. '/v1 ' , array (), array (), array (), $ data );
117
+ $ client ->request ('POST ' , '/ ' . $ authorizationKey . '/v1 ' , array (), array (), array (), $ data );
111
118
112
- $ response = json_decode ($ client ->getResponse ()->getContent (), true );
119
+ $ response = json_decode ($ client ->getResponse ()->getContent (), true );
113
120
114
- $ this ->assertEquals ($ response ["success " ], false );
115
- $ this ->assertEquals ($ response ["success " ], false );
116
- $ this ->assertEquals ($ response ["step " ], 4 );
117
- $ this ->assertContains ("Blink.ino:2:13: " , $ response ["message " ]);
118
- $ this ->assertContains ("expected ';' after top level declarator " , $ response ["message " ]);
119
- $ this ->assertContains ("no matching function for call to 'pinMode' " , $ response ["message " ]);
120
- $ this ->assertContains ("candidate function not viable: requires 2 arguments, but 1 was provided " , $ response ["message " ]);
121
- // $this->assertContains("2 errors generated.", $response["message"]); //unfortunately we no longer show how many errors were generated
122
- }
121
+ $ this ->assertEquals ($ response ["success " ], false );
122
+ $ this ->assertEquals ($ response ["success " ], false );
123
+ $ this ->assertEquals ($ response ["step " ], 4 );
124
+ $ this ->assertContains ("Blink.ino:2:13: " , $ response ["message " ]);
125
+ $ this ->assertContains ("expected ';' after top level declarator " , $ response ["message " ]);
126
+ $ this ->assertContains ("no matching function for call to 'pinMode' " , $ response ["message " ]);
127
+ $ this ->assertContains ("candidate function not viable: requires 2 arguments, but 1 was provided " , $ response ["message " ]);
128
+ // $this->assertContains("2 errors generated.", $response["message"]); //unfortunately we no longer show how many errors were generated
129
+ }
123
130
124
- public function testBlinkUnoCompileError () {
125
- $ files = array (array ("filename " => "Blink.ino " , "content " => "\nint led = 13 \nvoid setup() { \npinMode(led, OUTPUT); \npinMode(led); \n} \nvoid loop() { \ndigitalWrite(led, HIGH); \ndelay(1000); \ndigitalWrite(led, LOW); \n delay(1000); \n} \n" ));
126
- $ format = "binary " ;
127
- $ version = "105 " ;
128
- $ libraries = array ();
129
- $ build = array ("mcu " => "atmega328p " , "f_cpu " => "16000000 " , "core " => "arduino " , "variant " => "standard " );
131
+ public function testBlinkUnoCompileError ()
132
+ {
133
+ $ files = array (array ("filename " => "Blink.ino " , "content " => "\nint led = 13 \nvoid setup() { \npinMode(led, OUTPUT); \npinMode(led); \n} \nvoid loop() { \ndigitalWrite(led, HIGH); \ndelay(1000); \ndigitalWrite(led, LOW); \n delay(1000); \n} \n" ));
134
+ $ format = "binary " ;
135
+ $ version = "105 " ;
136
+ $ libraries = array ();
137
+ $ build = array ("mcu " => "atmega328p " , "f_cpu " => "16000000 " , "core " => "arduino " , "variant " => "standard " );
130
138
131
- $ data = json_encode (array ("files " => $ files , "format " => $ format , "version " => $ version , "libraries " => $ libraries , "build " => $ build ));
139
+ $ data = json_encode (array ("files " => $ files , "format " => $ format , "version " => $ version , "libraries " => $ libraries , "build " => $ build ));
132
140
133
- $ client = static ::createClient ();
141
+ $ client = static ::createClient ();
134
142
135
- $ authorizationKey = $ client ->getContainer ()->getParameter ("authorizationKey " );
143
+ $ authorizationKey = $ client ->getContainer ()->getParameter ("authorizationKey " );
136
144
137
- $ client ->request ('POST ' , '/ ' . $ authorizationKey. '/v1 ' , array (), array (), array (), $ data );
145
+ $ client ->request ('POST ' , '/ ' . $ authorizationKey . '/v1 ' , array (), array (), array (), $ data );
138
146
139
- $ response = json_decode ($ client ->getResponse ()->getContent (), true );
147
+ $ response = json_decode ($ client ->getResponse ()->getContent (), true );
140
148
141
- $ this ->assertEquals ($ response ["success " ], false );
142
- $ this ->assertEquals ($ response ["step " ], 4 );
143
- $ this ->assertContains ("Blink.ino:2:13: " , $ response ["message " ]);
144
- $ this ->assertContains ("expected ';' after top level declarator " , $ response ["message " ]);
145
- $ this ->assertContains ("no matching function for call to 'pinMode' " , $ response ["message " ]);
146
- $ this ->assertContains ("candidate function not viable: requires 2 arguments, but 1 was provided " , $ response ["message " ]);
147
- // $this->assertContains("2 errors generated.", $response["message"]); //unfortunately we no longer show how many errors were generated
148
- }
149
+ $ this ->assertEquals ($ response ["success " ], false );
150
+ $ this ->assertEquals ($ response ["step " ], 4 );
151
+ $ this ->assertContains ("Blink.ino:2:13: " , $ response ["message " ]);
152
+ $ this ->assertContains ("expected ';' after top level declarator " , $ response ["message " ]);
153
+ $ this ->assertContains ("no matching function for call to 'pinMode' " , $ response ["message " ]);
154
+ $ this ->assertContains ("candidate function not viable: requires 2 arguments, but 1 was provided " , $ response ["message " ]);
155
+ // $this->assertContains("2 errors generated.", $response["message"]); //unfortunately we no longer show how many errors were generated
156
+ }
149
157
150
- public function testExternalVariant () {
158
+ public function testExternalVariant ()
159
+ {
151
160
$ files = array (array ('filename ' => 'Blink.ino ' , 'content ' => "void setup(){} \nvoid loop(){} \n" ));
152
161
$ format = 'binary ' ;
153
162
$ version = '105 ' ;
@@ -159,7 +168,7 @@ public function testExternalVariant() {
159
168
160
169
$ authorizationKey = $ client ->getContainer ()->getParameter ("authorizationKey " );
161
170
162
- $ client ->request ('POST ' , '/ ' . $ authorizationKey. '/v1 ' , array (), array (), array (), $ data );
171
+ $ client ->request ('POST ' , '/ ' . $ authorizationKey . '/v1 ' , array (), array (), array (), $ data );
163
172
164
173
$ response = json_decode ($ client ->getResponse ()->getContent (), true );
165
174
@@ -170,7 +179,8 @@ public function testExternalVariant() {
170
179
$ this ->assertTrue (count ($ coreObjectLibrary ) > 0 );
171
180
}
172
181
173
- public function testExternalCore () {
182
+ public function testExternalCore ()
183
+ {
174
184
$ files = array (array ('filename ' => 'Blink.ino ' , 'content ' => "void setup(){} \nvoid loop(){} \n" ));
175
185
$ format = 'binary ' ;
176
186
$ version = '105 ' ;
@@ -182,7 +192,7 @@ public function testExternalCore() {
182
192
183
193
$ authorizationKey = $ client ->getContainer ()->getParameter ("authorizationKey " );
184
194
185
- $ client ->request ('POST ' , '/ ' . $ authorizationKey. '/v1 ' , array (), array (), array (), $ data );
195
+ $ client ->request ('POST ' , '/ ' . $ authorizationKey . '/v1 ' , array (), array (), array (), $ data );
186
196
187
197
$ response = json_decode ($ client ->getResponse ()->getContent (), true );
188
198
@@ -194,31 +204,34 @@ public function testExternalCore() {
194
204
$ this ->assertTrue (count ($ coreObjectLibrary ) > 0 );
195
205
}
196
206
197
- public function testArchiveIsCreated () {
207
+ public function testArchiveIsCreated ()
208
+ {
198
209
$ files = array (array ('filename ' => 'Blink.ino ' , 'content ' => "void setup(){} \nvoid loop(){} \n" ));
199
210
$ format = 'binary ' ;
200
211
$ version = '105 ' ;
201
212
$ libraries = array ();
202
213
$ build = array ('mcu ' => 'atmega328p ' , 'f_cpu ' => '16000000 ' , 'core ' => 'arduino ' , 'variant ' => 'standard ' );
203
- $ data = json_encode (array ('files ' => $ files , 'archive ' => true , 'format ' => $ format , 'version ' => $ version , 'libraries ' => $ libraries , 'build ' => $ build ));
214
+ $ data = json_encode (array ('files ' => $ files , 'archive ' => true , 'format ' => $ format , 'version ' => $ version , 'libraries ' => $ libraries , 'build ' => $ build ));
204
215
205
216
$ client = static ::createClient ();
206
217
207
218
$ authorizationKey = $ client ->getContainer ()->getParameter ('authorizationKey ' );
208
219
209
- $ client ->request ('POST ' , '/ ' . $ authorizationKey. '/v1 ' , array (), array (), array (), $ data );
220
+ $ client ->request ('POST ' , '/ ' . $ authorizationKey . '/v1 ' , array (), array (), array (), $ data );
210
221
211
222
$ response = json_decode ($ client ->getResponse ()->getContent (), true );
212
223
213
224
214
225
$ this ->assertTrue (file_exists ($ response ['archive ' ]));
215
226
}
216
227
217
- public function testAutocomplete () {
228
+ public function testAutocomplete ()
229
+ {
218
230
$ this ->markTestIncomplete ('No tests for the code completion feature yet. ' );
219
231
}
220
232
221
- public function testIncorrectInputs () {
222
- $ this ->markTestIncomplete ('No tests for invalid inputs yet ' );
223
- }
233
+ public function testIncorrectInputs ()
234
+ {
235
+ $ this ->markTestIncomplete ('No tests for invalid inputs yet ' );
236
+ }
224
237
}
0 commit comments