File tree Expand file tree Collapse file tree 11 files changed +88
-21
lines changed Expand file tree Collapse file tree 11 files changed +88
-21
lines changed Original file line number Diff line number Diff line change 3
3
/.travis.yml export-ignore
4
4
/examples / export-ignore
5
5
/phpunit.xml.dist export-ignore
6
+ /phpunit.xml.legacy export-ignore
6
7
/tests / export-ignore
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ language: php
3
3
# lock distro so new future defaults will not break the build
4
4
dist : trusty
5
5
6
- matrix :
6
+ jobs :
7
7
include :
8
8
- php : 5.3
9
9
dist : precise
@@ -24,9 +24,10 @@ install:
24
24
- sudo apt-get --no-install-recommends -qq install -y asterisk
25
25
- sudo cp tests/username.conf /etc/asterisk/manager.d/username.conf
26
26
- sudo /etc/init.d/asterisk reload
27
- - composer install --no-interaction
27
+ - composer install
28
28
29
29
script :
30
30
- sudo /etc/init.d/asterisk status || sudo /etc/init.d/asterisk start
31
31
- 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 19
19
},
20
20
"require-dev" : {
21
21
"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"
23
23
},
24
24
"autoload" : {
25
25
"psr-4" : { "Clue\\ React\\ Ami\\ " : " src/" }
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" UTF-8" ?>
2
2
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" >
4
9
<testsuites >
5
10
<testsuite name =" Asterisk AMI Test Suite" >
6
11
<directory >./tests/</directory >
7
12
</testsuite >
8
13
</testsuites >
9
- <filter >
10
- <whitelist >
14
+ <coverage >
15
+ <include >
11
16
<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()
53
53
{
54
54
$ stream = $ this ->getMockBuilder ('React\Socket\Connection ' )->disableOriginalConstructor ()->getMock ();
55
55
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
+ }
57
63
58
64
return $ client ;
59
65
}
Original file line number Diff line number Diff line change @@ -45,6 +45,12 @@ public function testUnexpectedResponseEmitsErrorAndClosesClient()
45
45
46
46
private function createStreamMock ()
47
47
{
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
+ }
49
55
}
50
56
}
Original file line number Diff line number Diff line change @@ -11,7 +11,10 @@ class FactoryTest extends TestCase
11
11
private $ tcp ;
12
12
private $ factory ;
13
13
14
- public function setUp ()
14
+ /**
15
+ * @before
16
+ */
17
+ public function setUpFactory ()
15
18
{
16
19
$ this ->loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
17
20
$ 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
13
13
private static $ address = false ;
14
14
private static $ loop ;
15
15
16
- public static function setUpBeforeClass ()
16
+ /**
17
+ * @beforeClass
18
+ */
19
+ public static function setUpLoopBeforeClass ()
17
20
{
18
21
self ::$ address = getenv ('LOGIN ' );
19
22
self ::$ loop = \React \EventLoop \Factory::create ();
20
23
}
21
24
22
- public function setUp ()
25
+ /**
26
+ * @before
27
+ */
28
+ public function setUpSkipTest ()
23
29
{
24
30
if (self ::$ address === false ) {
25
31
$ this ->markTestSkipped ('No ENV named LOGIN found. Please use "export LOGIN= \'user:pass@host \'. ' );
@@ -54,10 +60,10 @@ public function testPing(Client $client)
54
60
/**
55
61
* @depends testConnection
56
62
* @param Client $client
57
- * @expectedException Exception
58
63
*/
59
64
public function testInvalidCommandGetsRejected (Client $ client )
60
65
{
66
+ $ this ->setExpectedException ('Exception ' );
61
67
$ this ->waitFor ($ client ->request ($ client ->createAction ('Invalid ' )));
62
68
}
63
69
@@ -85,10 +91,10 @@ public function testActionSenderLogoffDisconnects(Client $client)
85
91
/**
86
92
* @depends testActionSenderLogoffDisconnects
87
93
* @param Client $client
88
- * @expectedException Exception
89
94
*/
90
95
public function testSendRejectedAfterClose (Client $ client )
91
96
{
97
+ $ this ->setExpectedException ('Exception ' );
92
98
$ this ->waitFor ($ client ->request ($ client ->createAction ('Ping ' )));
93
99
}
94
100
Original file line number Diff line number Diff line change @@ -132,14 +132,12 @@ public function testParsingResponseIsNotCommandResponse()
132
132
$ this ->assertEquals ('Some message--END COMMAND-- ' , $ first ->getFieldValue ('Message ' ));
133
133
}
134
134
135
- /**
136
- * @expectedException UnexpectedValueException
137
- */
138
135
public function testParsingInvalidResponseFails ()
139
136
{
140
137
$ parser = new Parser ();
141
138
$ this ->assertEquals (array (), $ parser ->push ("Asterisk Call Manager/1.3 \r\n" ));
142
139
140
+ $ this ->setExpectedException ('UnexpectedValueException ' );
143
141
$ parser ->push ("invalid response \r\n\r\n" );
144
142
}
145
143
You can’t perform that action at this time.
0 commit comments