33namespace Test ;
44
55use Gui \Application ;
6+ use Gui \Components \Window ;
67
78class ApplicationTest extends \PHPUnit_Framework_TestCase
89{
@@ -15,4 +16,65 @@ public function testGetNextObjectId()
1516 $ this ->assertEquals (2 , $ application ->getNextObjectId ());
1617 $ this ->assertEquals (3 , $ application ->getNextObjectId ());
1718 }
19+
20+ public function testGetWindow ()
21+ {
22+ $ application = new Application ();
23+
24+ $ this ->assertInstanceOf ('Gui\Components\Window ' , $ application ->getWindow ());
25+ }
26+
27+ public function testGetLoop ()
28+ {
29+ $ application = new Application ();
30+
31+ $ this ->assertInstanceOf ('React\EventLoop\LoopInterface ' , $ application ->getLoop ());
32+ }
33+
34+ public function testPing ()
35+ {
36+ $ mock = $ this ->getMockBuilder ('Gui\Application ' )
37+ ->setMethods (['waitCommand ' ])
38+ ->getMock ();
39+
40+ $ mock ->expects ($ this ->once ())
41+ ->method ('waitCommand ' )
42+ ->willReturn (null );
43+
44+ $ this ->assertTrue (is_float ($ mock ->ping ()));
45+ }
46+
47+ public function testAddObject ()
48+ {
49+ $ application = new Application ();
50+
51+ $ this ->assertNull ($ application ->getObject (1 ));
52+
53+ $ application ->addObject (new Window ([], null , $ application ));
54+
55+ $ this ->assertInstanceOf ('Gui\Components\Window ' , $ application ->getObject (1 ));
56+ }
57+
58+ public function testOnAndFire ()
59+ {
60+ $ application = new Application ();
61+
62+ $ bar = 0 ;
63+ $ application ->on ('foo ' , function () use (&$ bar ) {
64+ $ bar ++;
65+ });
66+
67+ $ application ->fire ('foo ' );
68+
69+ $ this ->assertEquals (1 , $ bar );
70+ }
71+
72+ public function testGetAndSetVerboseLevel ()
73+ {
74+ $ application = new Application ();
75+
76+ $ this ->assertEquals (2 , $ application ->getVerboseLevel ());
77+ $ application ->setVerboseLevel (1 );
78+ $ this ->assertEquals (1 , $ application ->getVerboseLevel ());
79+ }
1880}
0 commit comments