Skip to content

Commit 7b08a34

Browse files
committed
Re-add pluginTest and mark as skipped
1 parent f04833c commit 7b08a34

1 file changed

Lines changed: 303 additions & 0 deletions

File tree

tests/pluginTest.php

Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,303 @@
1+
<?php
2+
3+
/* This file is part of Jeedom.
4+
*
5+
* Jeedom is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* Jeedom is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with Jeedom. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
use PHPUnit\Framework\TestCase;
20+
21+
class pluginTest extends TestCase {
22+
public function getSources() {
23+
return array(
24+
array('market', array(
25+
'version' => 'stable',
26+
))
27+
);
28+
}
29+
30+
/**
31+
* @dataProvider getSources
32+
*/
33+
public function testInstall($source, $config) {
34+
$this->markTestSkipped('Side effect');
35+
echo "\n" . __CLASS__ . '::' . __FUNCTION__ . ' : ';
36+
config::save('github::enable', 1);
37+
config::save('market::enable', 1);
38+
try {
39+
$plugin = plugin::byId('virtual');
40+
} catch (Exception $e) {
41+
$update = new update();
42+
$update->setLogicalId('virtual');
43+
$update->setSource($source);
44+
foreach ($config as $key => $value) {
45+
$update->setConfiguration($key, $value);
46+
}
47+
$update->save();
48+
$update->doUpdate();
49+
$plugin = plugin::byId('virtual');
50+
}
51+
if (!$plugin->isActive()) {
52+
$plugin->setIsEnable(1);
53+
}
54+
$this->assertSame('1', $plugin->isActive());
55+
}
56+
57+
/**
58+
* @depends testInstall
59+
*/
60+
public function testCreateEqVirtual() {
61+
$this->markTestSkipped('Side effect');
62+
echo "\n" . __CLASS__ . '::' . __FUNCTION__ . ' : ';
63+
require_once __DIR__ .'/../plugins/virtual/core/class/virtual.class.php';
64+
$virtual = virtual::byLogicalId('virtual_test', 'virtual');
65+
if (is_object($virtual)) {
66+
$virtual->remove();
67+
}
68+
$virtual = new virtual();
69+
$virtual->setEqType_name('virtual');
70+
$virtual->setName('virtual_test');
71+
$virtual->setLogicalId('virtual_test');
72+
$virtual->setIsEnable(1);
73+
$virtual->save();
74+
$this->assertTrue((is_numeric($virtual->getId()) && $virtual->getId() != ''));
75+
return $virtual;
76+
}
77+
78+
/**
79+
* @depends testCreateEqVirtual
80+
*/
81+
public function testCreateCmdVirtualBinary($virtual) {
82+
$this->markTestSkipped('Side effect');
83+
echo "\n" . __CLASS__ . '::' . __FUNCTION__ . ' : ';
84+
$cmd = new virtualCmd();
85+
$cmd->setName('test_calcul_binary');
86+
$cmd->setType('info');
87+
$cmd->setSubtype('binary');
88+
$cmd->setLogicalId('virtual_test_1');
89+
$cmd->setEqLogic_id($virtual->getId());
90+
$cmd->setConfiguration('calcul', 1);
91+
$cmd->save();
92+
$this->assertTrue((is_numeric($cmd->getId()) && $cmd->getId() != ''));
93+
}
94+
95+
/**
96+
* @depends testCreateEqVirtual
97+
*/
98+
public function testCreateCmdVirtualNumeric($virtual) {
99+
$this->markTestSkipped('Side effect');
100+
echo "\n" . __CLASS__ . '::' . __FUNCTION__ . ' : ';
101+
$cmd = new virtualCmd();
102+
$cmd->setName('test_calcul_numeric');
103+
$cmd->setType('info');
104+
$cmd->setSubtype('numeric');
105+
$cmd->setLogicalId('virtual_test_2');
106+
$cmd->setEqLogic_id($virtual->getId());
107+
$cmd->setConfiguration('calcul', '1+1');
108+
$cmd->save();
109+
$this->assertTrue((is_numeric($cmd->getId()) && $cmd->getId() != ''));
110+
}
111+
112+
/**
113+
* @depends testCreateEqVirtual
114+
*/
115+
public function testCmdVirtualNumeric($virtual) {
116+
$this->markTestSkipped('Side effect');
117+
echo "\n" . __CLASS__ . '::' . __FUNCTION__ . ' : ';
118+
$cmd = $virtual->getCmd(null, 'virtual_test_2');
119+
$this->assertSame(2.0, $cmd->execCmd());
120+
}
121+
122+
/**
123+
* @depends testCreateEqVirtual
124+
*/
125+
public function testCreateCmdVirtualString($virtual) {
126+
$this->markTestSkipped('Side effect');
127+
echo "\n" . __CLASS__ . '::' . __FUNCTION__ . ' : ';
128+
$cmd = new virtualCmd();
129+
$cmd->setName('test_calcul_string');
130+
$cmd->setType('info');
131+
$cmd->setSubtype('string');
132+
$cmd->setLogicalId('virtual_test_3');
133+
$cmd->setEqLogic_id($virtual->getId());
134+
$cmd->setConfiguration('calcul', 'toto');
135+
$cmd->save();
136+
$this->assertTrue((is_numeric($cmd->getId()) && $cmd->getId() != ''));
137+
}
138+
139+
/**
140+
* @depends testCreateEqVirtual
141+
*/
142+
public function testCmdVirtualString($virtual) {
143+
$this->markTestSkipped('Side effect');
144+
echo "\n" . __CLASS__ . '::' . __FUNCTION__ . ' : ';
145+
$cmd = $virtual->getCmd(null, 'virtual_test_3');
146+
$this->assertSame('toto', $cmd->execCmd());
147+
$cmd->event('tata');
148+
$this->assertSame('tata', $cmd->execCmd());
149+
}
150+
151+
/**
152+
* @depends testCreateEqVirtual
153+
*/
154+
public function testCreateCmdVirtualActionOther($virtual) {
155+
$this->markTestSkipped('Side effect');
156+
echo "\n" . __CLASS__ . '::' . __FUNCTION__ . ' : ';
157+
$cmd = new virtualCmd();
158+
$cmd->setName('test_action_other_on');
159+
$cmd->setType('action');
160+
$cmd->setSubtype('other');
161+
$cmd->setLogicalId('virtual_test_4');
162+
$cmd->setEqLogic_id($virtual->getId());
163+
$cmd->setConfiguration('infoName', 'test_action_other_info');
164+
$cmd->setConfiguration('value', 1);
165+
$cmd->save();
166+
$this->assertTrue((is_numeric($cmd->getId()) && $cmd->getId() != ''));
167+
168+
$virtual = virtual::byLogicalId('virtual_test', 'virtual');
169+
$cmd = new virtualCmd();
170+
$cmd->setName('test_action_other_off');
171+
$cmd->setType('action');
172+
$cmd->setSubtype('other');
173+
$cmd->setLogicalId('virtual_test_5');
174+
$cmd->setEqLogic_id($virtual->getId());
175+
$cmd->setConfiguration('infoName', 'test_action_other_info');
176+
$cmd->setConfiguration('value', 0);
177+
$cmd->save();
178+
$this->assertTrue((is_numeric($cmd->getId()) && $cmd->getId() != ''));
179+
180+
$virtual = virtual::byLogicalId('virtual_test', 'virtual');
181+
$cmd = new virtualCmd();
182+
$cmd->setName('test_action_other_string');
183+
$cmd->setType('action');
184+
$cmd->setSubtype('other');
185+
$cmd->setLogicalId('virtual_test_6');
186+
$cmd->setEqLogic_id($virtual->getId());
187+
$cmd->setConfiguration('infoName', 'test_action_other_info');
188+
$cmd->setConfiguration('value', 'plop');
189+
$cmd->save();
190+
$this->assertTrue((is_numeric($cmd->getId()) && $cmd->getId() != ''));
191+
192+
$info = virtualCmd::byEqLogicIdCmdName($virtual->getId(), 'test_action_other_info');
193+
$virtual = virtual::byLogicalId('virtual_test', 'virtual');
194+
$cmd = new virtualCmd();
195+
$cmd->setName('test_action_other_toggle');
196+
$cmd->setType('action');
197+
$cmd->setSubtype('other');
198+
$cmd->setLogicalId('virtual_test_7');
199+
$cmd->setEqLogic_id($virtual->getId());
200+
$cmd->setConfiguration('infoName', 'test_action_other_info');
201+
$cmd->setConfiguration('value', 'not(#' . $info->getId() . '#)');
202+
$cmd->save();
203+
$this->assertTrue((is_numeric($cmd->getId()) && $cmd->getId() != ''));
204+
}
205+
206+
/**
207+
* @depends testCreateEqVirtual
208+
*/
209+
public function testCmdVirtualActionOther($virtual) {
210+
$this->markTestSkipped('Side effect');
211+
echo "\n" . __CLASS__ . '::' . __FUNCTION__ . ' : ';
212+
$info = virtualCmd::byEqLogicIdCmdName($virtual->getId(), 'test_action_other_info');
213+
$action_on = $virtual->getCmd(null, 'virtual_test_4');
214+
$action_on->execCmd();
215+
$this->assertSame(1, intval($info->execCmd()));
216+
217+
$action_off = $virtual->getCmd(null, 'virtual_test_5');
218+
$action_off->execCmd();
219+
$this->assertSame(0, intval($info->execCmd()));
220+
221+
$action_toggle = $virtual->getCmd(null, 'virtual_test_7');
222+
$action_toggle->execCmd();
223+
$this->assertSame(1, intval($info->execCmd()));
224+
225+
$action_other = $virtual->getCmd(null, 'virtual_test_6');
226+
$action_other->execCmd();
227+
$this->assertSame('plop', $info->execCmd());
228+
}
229+
230+
/**
231+
* @depends testCreateEqVirtual
232+
*/
233+
public function testCreateCmdVirtualActionNumeric($virtual) {
234+
$this->markTestSkipped('Side effect');
235+
echo "\n" . __CLASS__ . '::' . __FUNCTION__ . ' : ';
236+
$cmd = new virtualCmd();
237+
$cmd->setName('test_action_slider');
238+
$cmd->setType('action');
239+
$cmd->setSubtype('slider');
240+
$cmd->setLogicalId('virtual_test_8');
241+
$cmd->setEqLogic_id($virtual->getId());
242+
$cmd->setConfiguration('infoName', 'test_action_slider_info');
243+
$cmd->save();
244+
$this->assertTrue((is_numeric($cmd->getId()) && $cmd->getId() != ''));
245+
}
246+
247+
/**
248+
* @depends testCreateEqVirtual
249+
*/
250+
public function testCmdVirtualActionNumeric($virtual) {
251+
$this->markTestSkipped('Side effect');
252+
echo "\n" . __CLASS__ . '::' . __FUNCTION__ . ' : ';
253+
$action = $virtual->getCmd(null, 'virtual_test_8');
254+
$info = virtualCmd::byEqLogicIdCmdName($virtual->getId(), 'test_action_slider_info');
255+
$action->execCmd(array('slider' => 12));
256+
$this->assertSame(12, intval($info->execCmd()));
257+
$action->execCmd(array('slider' => 95));
258+
$this->assertSame(95, intval($info->execCmd()));
259+
}
260+
261+
/**
262+
* @depends testCreateEqVirtual
263+
*/
264+
public function testCreateCmdVirtualActionColor($virtual) {
265+
$this->markTestSkipped('Side effect');
266+
echo "\n" . __CLASS__ . '::' . __FUNCTION__ . ' : ';
267+
$cmd = new virtualCmd();
268+
$cmd->setName('test_action_color');
269+
$cmd->setType('action');
270+
$cmd->setSubtype('color');
271+
$cmd->setLogicalId('virtual_test_9');
272+
$cmd->setEqLogic_id($virtual->getId());
273+
$cmd->setConfiguration('infoName', 'test_action_color_info');
274+
$cmd->save();
275+
$this->assertTrue((is_numeric($cmd->getId()) && $cmd->getId() != ''));
276+
}
277+
278+
/**
279+
* @depends testCreateEqVirtual
280+
*/
281+
public function testCmdVirtualActionColor($virtual) {
282+
$this->markTestSkipped('Side effect');
283+
echo "\n" . __CLASS__ . '::' . __FUNCTION__ . ' : ';
284+
$action = $virtual->getCmd(null, 'virtual_test_9');
285+
$info = virtualCmd::byEqLogicIdCmdName($virtual->getId(), 'test_action_color_info');
286+
$action->execCmd(array('color' => '#451256'));
287+
$this->assertSame('#451256', $info->execCmd());
288+
$action->execCmd(array('color' => '#895475'));
289+
$this->assertSame('#895475', $info->execCmd());
290+
}
291+
292+
/**
293+
* @depends testCreateEqVirtual
294+
*/
295+
public function testRemove($virtual) {
296+
$this->markTestSkipped('Side effect');
297+
echo "\n" . __CLASS__ . '::' . __FUNCTION__ . ' : ';
298+
$id = $virtual->getId();
299+
$virtual->remove();
300+
$this->assertEquals(null,virtual::byId($id));
301+
}
302+
303+
}

0 commit comments

Comments
 (0)