6
6
7
7
class DefaultControllerFunctionalTest extends WebTestCase
8
8
{
9
- public function testStatus ()
10
- {
9
+ public function testStatus () {
11
10
$ client = static ::createClient ();
12
11
13
12
$ client ->request ('GET ' , '/status ' );
@@ -16,8 +15,7 @@ public function testStatus()
16
15
17
16
}
18
17
19
- public function testInvalidKey ()
20
- {
18
+ public function testInvalidKey () {
21
19
$ client = static ::createClient ();
22
20
23
21
$ client ->request ('GET ' , '/inValidKey/v1 ' );
@@ -26,8 +24,7 @@ public function testInvalidKey()
26
24
27
25
}
28
26
29
- public function testInvalidAPI ()
30
- {
27
+ public function testInvalidAPI () {
31
28
$ client = static ::createClient ();
32
29
33
30
$ auth_key = $ client ->getContainer ()->getParameter ("auth_key " );
@@ -38,8 +35,7 @@ public function testInvalidAPI()
38
35
39
36
}
40
37
41
- public function testInvalidInput ()
42
- {
38
+ public function testInvalidInput () {
43
39
$ client = static ::createClient ();
44
40
45
41
$ auth_key = $ client ->getContainer ()->getParameter ("auth_key " );
@@ -50,8 +46,7 @@ public function testInvalidInput()
50
46
51
47
}
52
48
53
- public function testBlinkUnoSyntaxCheck ()
54
- {
49
+ public function testBlinkUnoSyntaxCheck () {
55
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" ));
56
51
$ format = "syntax " ;
57
52
$ version = "105 " ;
@@ -71,10 +66,13 @@ public function testBlinkUnoSyntaxCheck()
71
66
$ this ->assertEquals ($ response ["success " ], true );
72
67
$ this ->assertTrue (is_numeric ($ response ["time " ]));
73
68
69
+ $ objectFilesPath = $ client ->getContainer ()->getParameter ('temp_dir ' ) . '/ ' . $ client ->getContainer ()->getParameter ('objdir ' );
70
+ $ coreObjectLibrary = glob ("$ objectFilesPath/*__v105__hardware__arduino__cores__arduino________atmega328p_16000000_arduino_standard_null_null_______core.a " );
71
+ $ this ->assertTrue (count ($ coreObjectLibrary ) > 0 );
72
+
74
73
}
75
74
76
- public function testBlinkUnoCompile ()
77
- {
75
+ public function testBlinkUnoCompile () {
78
76
$ 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
77
$ format = "binary " ;
80
78
$ version = "105 " ;
@@ -96,8 +94,7 @@ public function testBlinkUnoCompile()
96
94
$ this ->assertTrue (is_numeric ($ response ["size " ]));
97
95
}
98
96
99
- public function testBlinkUnoSyntaxCheckError ()
100
- {
97
+ public function testBlinkUnoSyntaxCheckError () {
101
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" ));
102
99
$ format = "syntax " ;
103
100
$ version = "105 " ;
@@ -124,8 +121,7 @@ public function testBlinkUnoSyntaxCheckError()
124
121
// $this->assertContains("2 errors generated.", $response["message"]); //unfortunately we no longer show how many errors were generated
125
122
}
126
123
127
- public function testBlinkUnoCompileError ()
128
- {
124
+ public function testBlinkUnoCompileError () {
129
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" ));
130
126
$ format = "binary " ;
131
127
$ version = "105 " ;
@@ -151,8 +147,57 @@ public function testBlinkUnoCompileError()
151
147
// $this->assertContains("2 errors generated.", $response["message"]); //unfortunately we no longer show how many errors were generated
152
148
}
153
149
154
- public function testIncorrectInputs ()
155
- {
150
+ public function testExternalVariant () {
151
+ $ files = array (array ('filename ' => 'Blink.ino ' , 'content ' => "void setup(){} \nvoid loop(){} \n" ));
152
+ $ format = 'binary ' ;
153
+ $ version = '105 ' ;
154
+ $ libraries = array ();
155
+ $ build = array ('mcu ' => 'atmega32u4 ' , 'f_cpu ' => '8000000 ' , 'core ' => 'arduino ' , 'variant ' => 'flora ' , 'pid ' => '0x8004 ' , 'vid ' => '0x239A ' );
156
+ $ data = json_encode (array ("files " => $ files , "format " => $ format , "version " => $ version , "libraries " => $ libraries , "build " => $ build ));
157
+
158
+ $ client = static ::createClient ();
159
+
160
+ $ auth_key = $ client ->getContainer ()->getParameter ("auth_key " );
161
+
162
+ $ client ->request ('POST ' , '/ ' .$ auth_key .'/v1 ' , array (), array (), array (), $ data );
163
+
164
+ $ response = json_decode ($ client ->getResponse ()->getContent (), true );
165
+
166
+ $ this ->assertEquals ($ response ['success ' ], true );
167
+ $ objectFilesPath = $ client ->getContainer ()->getParameter ('temp_dir ' ) . '/ ' . $ client ->getContainer ()->getParameter ('objdir ' );
168
+ $ coreObjectLibrary = glob ("$ objectFilesPath/*v105__hardware__arduino__cores__arduino________atmega32u4_8000000_arduino_flora_0x239A_0x8004_______core.a " );
169
+
170
+ $ this ->assertTrue (count ($ coreObjectLibrary ) > 0 );
171
+ }
172
+
173
+ public function testExternalCore () {
174
+ $ files = array (array ('filename ' => 'Blink.ino ' , 'content ' => "void setup(){} \nvoid loop(){} \n" ));
175
+ $ format = 'binary ' ;
176
+ $ version = '105 ' ;
177
+ $ libraries = array ();
178
+ $ build = array ('mcu ' => 'attiny85 ' , 'f_cpu ' => '8000000 ' , 'core ' => 'tiny ' );
179
+ $ data = json_encode (array ("files " => $ files , "format " => $ format , "version " => $ version , "libraries " => $ libraries , "build " => $ build ));
180
+
181
+ $ client = static ::createClient ();
182
+
183
+ $ auth_key = $ client ->getContainer ()->getParameter ("auth_key " );
184
+
185
+ $ client ->request ('POST ' , '/ ' .$ auth_key .'/v1 ' , array (), array (), array (), $ data );
186
+
187
+ $ response = json_decode ($ client ->getResponse ()->getContent (), true );
188
+
189
+ $ this ->assertEquals ($ response ['success ' ], true );
190
+ $ objectFilesPath = $ client ->getContainer ()->getParameter ('temp_dir ' ) . '/ ' . $ client ->getContainer ()->getParameter ('objdir ' );
191
+ $ coreObjectLibrary = glob ("$ objectFilesPath/*__external_cores__tiny__cores__tiny________attiny85_8000000_tiny__null_null_______core.a " );
192
+
193
+ $ this ->assertTrue (count ($ coreObjectLibrary ) > 0 );
194
+ }
195
+
196
+ public function testAutocomplete () {
197
+ $ this ->markTestIncomplete ('No tests for the code completion feature yet. ' );
198
+ }
199
+
200
+ public function testIncorrectInputs () {
156
201
$ this ->markTestIncomplete ("No tests for invalid inputs yet " );
157
202
}
158
203
}
0 commit comments