File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33/.travis.yml export-ignore
44/examples / export-ignore
55/phpunit.xml.dist export-ignore
6+ /phpunit.xml.legacy export-ignore
67/tests / export-ignore
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ language: php
33# lock distro so new future defaults will not break the build
44dist : trusty
55
6- matrix :
6+ jobs :
77 include :
88 - php : 5.3
99 dist : precise
@@ -24,9 +24,10 @@ install:
2424 - sudo apt-get --no-install-recommends -qq install -y asterisk
2525 - sudo cp tests/username.conf /etc/asterisk/manager.d/username.conf
2626 - sudo /etc/init.d/asterisk reload
27- - composer install --no-interaction
27+ - composer install
2828
2929script :
3030 - sudo /etc/init.d/asterisk status || sudo /etc/init.d/asterisk start
3131 - sudo /etc/init.d/asterisk status || sleep 2
32- - vendor/bin/phpunit --coverage-text
32+ - if [[ "$TRAVIS_PHP_VERSION" > "7.2" ]]; then vendor/bin/phpunit --coverage-text; fi
33+ - if [[ "$TRAVIS_PHP_VERSION" < "7.3" ]]; then vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy; fi
Original file line number Diff line number Diff line change 1919 },
2020 "require-dev" : {
2121 "clue/block-react" : " ^1.2" ,
22- "phpunit/phpunit" : " ^7.0 || ^6.0 || ^5.0 || ^4.8.35"
22+ "phpunit/phpunit" : " ^9.3 || ^5.7 || ^4.8.35"
2323 },
2424 "autoload" : {
2525 "psr-4" : { "Clue\\ React\\ Ami\\ " : " src/" }
Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" UTF-8" ?>
22
3- <phpunit bootstrap =" vendor/autoload.php" colors =" true" >
3+ <!-- PHPUnit configuration file with new format for PHPUnit 9.3+ -->
4+ <phpunit xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
5+ xsi : noNamespaceSchemaLocation =" https://schema.phpunit.de/9.3/phpunit.xsd"
6+ bootstrap =" vendor/autoload.php"
7+ colors =" true"
8+ cacheResult =" false" >
49 <testsuites >
510 <testsuite name =" Asterisk AMI Test Suite" >
611 <directory >./tests/</directory >
712 </testsuite >
813 </testsuites >
9- <filter >
10- <whitelist >
14+ <coverage >
15+ <include >
1116 <directory >./src/</directory >
12- </whitelist >
13- </filter >
14- </phpunit >
17+ </include >
18+ </coverage >
19+ </phpunit >
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+
3+ <!-- PHPUnit configuration file with old format for PHPUnit 9.2 or older -->
4+ <phpunit xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
5+ xsi : noNamespaceSchemaLocation =" https://schema.phpunit.de/4.8/phpunit.xsd"
6+ bootstrap =" vendor/autoload.php"
7+ colors =" true" >
8+ <testsuites >
9+ <testsuite name =" Asterisk AMI Test Suite" >
10+ <directory >./tests/</directory >
11+ </testsuite >
12+ </testsuites >
13+ <filter >
14+ <whitelist >
15+ <directory >./src/</directory >
16+ </whitelist >
17+ </filter >
18+ </phpunit >
Original file line number Diff line number Diff line change @@ -53,7 +53,13 @@ private function createClientMock()
5353 {
5454 $ stream = $ this ->getMockBuilder ('React\Socket\Connection ' )->disableOriginalConstructor ()->getMock ();
5555
56- $ client = $ this ->getMockBuilder ('Clue\React\Ami\Client ' )->setMethods (array ('createAction ' ))->setConstructorArgs (array ($ stream ))->getMock ();
56+ if (method_exists ('PHPUnit\Framework\MockObject\MockBuilder ' , 'onlyMethods ' )) {
57+ // PHPUnit 9+
58+ $ client = $ this ->getMockBuilder ('Clue\React\Ami\Client ' )->onlyMethods (array ('createAction ' ))->setConstructorArgs (array ($ stream ))->getMock ();
59+ } else {
60+ // legacy PHPUnit 4 - PHPUnit 8
61+ $ client = $ this ->getMockBuilder ('Clue\React\Ami\Client ' )->setMethods (array ('createAction ' ))->setConstructorArgs (array ($ stream ))->getMock ();
62+ }
5763
5864 return $ client ;
5965 }
Original file line number Diff line number Diff line change @@ -45,6 +45,12 @@ public function testUnexpectedResponseEmitsErrorAndClosesClient()
4545
4646 private function createStreamMock ()
4747 {
48- return $ this ->getMockBuilder ('React\Socket\Connection ' )->disableOriginalConstructor ()->setMethods (array ('write ' , 'close ' ))->getMock ();
48+ if (method_exists ('PHPUnit\Framework\MockObject\MockBuilder ' , 'onlyMethods ' )) {
49+ // PHPUnit 9+
50+ return $ this ->getMockBuilder ('React\Socket\Connection ' )->disableOriginalConstructor ()->onlyMethods (array ('write ' , 'close ' ))->getMock ();
51+ } else {
52+ // legacy PHPUnit 4 - PHPUnit 8
53+ return $ this ->getMockBuilder ('React\Socket\Connection ' )->disableOriginalConstructor ()->setMethods (array ('write ' , 'close ' ))->getMock ();
54+ }
4955 }
5056}
Original file line number Diff line number Diff line change @@ -11,7 +11,10 @@ class FactoryTest extends TestCase
1111 private $ tcp ;
1212 private $ factory ;
1313
14- public function setUp ()
14+ /**
15+ * @before
16+ */
17+ public function setUpFactory ()
1518 {
1619 $ this ->loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
1720 $ this ->tcp = $ this ->getMockBuilder ('React\Socket\ConnectorInterface ' )->getMock ();
Original file line number Diff line number Diff line change @@ -13,13 +13,19 @@ class FunctionalTest extends TestCase
1313 private static $ address = false ;
1414 private static $ loop ;
1515
16- public static function setUpBeforeClass ()
16+ /**
17+ * @beforeClass
18+ */
19+ public static function setUpLoopBeforeClass ()
1720 {
1821 self ::$ address = getenv ('LOGIN ' );
1922 self ::$ loop = \React \EventLoop \Factory::create ();
2023 }
2124
22- public function setUp ()
25+ /**
26+ * @before
27+ */
28+ public function setUpSkipTest ()
2329 {
2430 if (self ::$ address === false ) {
2531 $ this ->markTestSkipped ('No ENV named LOGIN found. Please use "export LOGIN= \'user:pass@host \'. ' );
@@ -54,10 +60,10 @@ public function testPing(Client $client)
5460 /**
5561 * @depends testConnection
5662 * @param Client $client
57- * @expectedException Exception
5863 */
5964 public function testInvalidCommandGetsRejected (Client $ client )
6065 {
66+ $ this ->setExpectedException ('Exception ' );
6167 $ this ->waitFor ($ client ->request ($ client ->createAction ('Invalid ' )));
6268 }
6369
@@ -85,10 +91,10 @@ public function testActionSenderLogoffDisconnects(Client $client)
8591 /**
8692 * @depends testActionSenderLogoffDisconnects
8793 * @param Client $client
88- * @expectedException Exception
8994 */
9095 public function testSendRejectedAfterClose (Client $ client )
9196 {
97+ $ this ->setExpectedException ('Exception ' );
9298 $ this ->waitFor ($ client ->request ($ client ->createAction ('Ping ' )));
9399 }
94100
Original file line number Diff line number Diff line change @@ -132,14 +132,12 @@ public function testParsingResponseIsNotCommandResponse()
132132 $ this ->assertEquals ('Some message--END COMMAND-- ' , $ first ->getFieldValue ('Message ' ));
133133 }
134134
135- /**
136- * @expectedException UnexpectedValueException
137- */
138135 public function testParsingInvalidResponseFails ()
139136 {
140137 $ parser = new Parser ();
141138 $ this ->assertEquals (array (), $ parser ->push ("Asterisk Call Manager/1.3 \r\n" ));
142139
140+ $ this ->setExpectedException ('UnexpectedValueException ' );
143141 $ parser ->push ("invalid response \r\n\r\n" );
144142 }
145143
You can’t perform that action at this time.
0 commit comments