Skip to content

Commit 7c2896b

Browse files
authored
Merge pull request #51 from clue-labs/tests
Improve test suite, support PHPUnit 7 - legacy PHPUnit 4 and test against legacy PHP 5.3 through PHP 7.3
2 parents 4b6e58d + bfc91b7 commit 7c2896b

13 files changed

Lines changed: 71 additions & 61 deletions

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ php:
77
- 5.6
88
- 7.0
99
- 7.1
10-
- hhvm # ignore errors, see below
10+
- 7.2
11+
- 7.3
1112

1213
# lock distro so new future defaults will not break the build
1314
dist: trusty
@@ -16,14 +17,13 @@ matrix:
1617
include:
1718
- php: 5.3
1819
dist: precise
19-
allow_failures:
20-
- php: hhvm
2120

2221
env:
2322
- LOGIN=username:password@localhost
2423

2524
install:
26-
- sudo apt-get -qq update && sudo apt-get --no-install-recommends -qq install -y asterisk
25+
- sudo apt-get -qq update || true # update package list and ignore temporary network errors
26+
- sudo apt-get --no-install-recommends -qq install -y asterisk
2727
- sudo cp tests/username.conf /etc/asterisk/manager.d/username.conf
2828
- sudo /etc/init.d/asterisk reload
2929
- composer install --no-interaction

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,10 @@ $ composer require clue/ami-react:^0.4
396396

397397
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
398398

399+
This project aims to run on any platform and thus does not require any PHP
400+
extensions and supports running on legacy PHP 5.3 through current PHP 7+.
401+
It's *highly recommended to use PHP 7+* for this project.
402+
399403
## Tests
400404

401405
To run the test suite, you first need to clone this repo and then install all

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
},
2020
"require-dev": {
2121
"clue/block-react": "^1.2",
22-
"phpunit/phpunit": "^5.0 || ^4.8"
22+
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.0 || ^4.8.35"
2323
},
2424
"autoload": {
2525
"psr-4": { "Clue\\React\\Ami\\": "src/" }
26+
},
27+
"autoload-dev": {
28+
"psr-4": { "Clue\\Tests\\React\\Ami\\": "tests/" }
2629
}
2730
}

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<phpunit bootstrap="tests/bootstrap.php"
3+
<phpunit bootstrap="vendor/autoload.php"
44
colors="true"
55
convertErrorsToExceptions="true"
66
convertNoticesToExceptions="true"

tests/ActionSenderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22

3+
namespace Clue\Tests\React\Ami;
4+
35
use Clue\React\Ami\ActionSender;
4-
use Clue\React\Ami\Client;
56
use Clue\React\Ami\Protocol\Action;
67
use Clue\React\Ami\Protocol\Event;
78
use Clue\React\Ami\Protocol\Response;

tests/ClientTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

3-
use React\Stream\Stream;
4-
use Clue\React\Ami\Protocol\Parser;
3+
namespace Clue\Tests\React\Ami;
4+
55
use Clue\React\Ami\Client;
6-
use React\EventLoop\Factory;
6+
use Clue\React\Ami\Protocol\Parser;
77
use Clue\React\Ami\Protocol\Response;
88

99
class ClientTest extends TestCase

tests/FactoryTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace Clue\Tests\React\Ami;
4+
35
use Clue\React\Ami\Factory;
46
use React\Promise\Promise;
57

@@ -17,6 +19,9 @@ public function setUp()
1719
$this->factory = new Factory($this->loop, $this->tcp);
1820
}
1921

22+
/**
23+
* @doesNotPerformAssertions
24+
*/
2025
public function testDefaultCtor()
2126
{
2227
$this->factory = new Factory($this->loop);

tests/FunctionalTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace Clue\Tests\React\Ami;
4+
35
use Clue\React\Ami\Factory;
46
use Clue\React\Ami\Client;
57
use Clue\React\Ami\ActionSender;
@@ -14,7 +16,7 @@ class FunctionalTest extends TestCase
1416
public static function setUpBeforeClass()
1517
{
1618
self::$address = getenv('LOGIN');
17-
self::$loop = React\EventLoop\Factory::create();
19+
self::$loop = \React\EventLoop\Factory::create();
1820
}
1921

2022
public function setUp()
@@ -45,7 +47,8 @@ public function testPing(Client $client)
4547
$sender = new ActionSender($client);
4648

4749
$pong = $this->waitFor($sender->ping());
48-
/* @var $pong Response */
50+
51+
$this->assertInstanceOf('Clue\React\Ami\Protocol\Response', $pong);
4952
}
5053

5154
/**
@@ -67,7 +70,8 @@ public function testActionSenderLogoffDisconnects(Client $client)
6770
$sender = new ActionSender($client);
6871

6972
$ret = $this->waitFor($sender->logoff());
70-
/* @var $ret Response */
73+
74+
$this->assertInstanceOf('Clue\React\Ami\Protocol\Response', $ret);
7175

7276
$this->assertFalse($client->isBusy());
7377

tests/Protocol/ActionTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22

3+
namespace Clue\Tests\React\Ami\Protocol;
4+
35
use Clue\React\Ami\Protocol\Action;
6+
use Clue\Tests\React\Ami\TestCase;
47

58
class ActionTest extends TestCase
69
{

tests/Protocol/ParserTest.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22

3+
namespace Clue\Tests\React\Ami\Protocol;
4+
35
use Clue\React\Ami\Protocol\Parser;
6+
use Clue\Tests\React\Ami\TestCase;
47

58
class ParserTest extends TestCase
69
{
@@ -13,7 +16,7 @@ public function testParseResponse()
1316
$this->assertCount(1, $ret);
1417

1518
$first = reset($ret);
16-
/* @var $first Clue\React\Ami\Protocol\Response */
19+
/* @var $first \Clue\React\Ami\Protocol\Response */
1720

1821
$this->assertInstanceOf('Clue\React\Ami\Protocol\Response', $first);
1922
$this->assertEquals('Success', $first->getFieldValue('Response'));
@@ -28,7 +31,7 @@ public function testParseResponseSpace()
2831
$this->assertCount(1, $ret);
2932

3033
$first = reset($ret);
31-
/* @var $first Clue\React\Ami\Protocol\Response */
34+
/* @var $first \Clue\React\Ami\Protocol\Response */
3235

3336
$this->assertInstanceOf('Clue\React\Ami\Protocol\Response', $first);
3437
$this->assertEquals(' spaces ', $first->getFieldValue('Message'));
@@ -43,7 +46,7 @@ public function testParsingMultipleEvents()
4346
$this->assertCount(2, $ret);
4447

4548
$first = reset($ret);
46-
/* @var $first Clue\React\Ami\Protocol\Event */
49+
/* @var $first \Clue\React\Ami\Protocol\Event */
4750

4851
$this->assertInstanceOf('Clue\React\Ami\Protocol\Event', $first);
4952
$this->assertEquals('TestA', $first->getName());
@@ -58,7 +61,7 @@ public function testParseResponseMultipleValues()
5861
$this->assertCount(1, $ret);
5962

6063
$first = reset($ret);
61-
/* @var $first Clue\React\Ami\Protocol\Response */
64+
/* @var $first \Clue\React\Ami\Protocol\Response */
6265

6366
$this->assertInstanceOf('Clue\React\Ami\Protocol\Response', $first);
6467
$this->assertEquals('one', $first->getFieldValue('Message'));
@@ -74,7 +77,7 @@ public function testParsingCommandResponse()
7477
$this->assertCount(1, $ret);
7578

7679
$first = reset($ret);
77-
/* @var $first Clue\React\Ami\Protocol\Response */
80+
/* @var $first \Clue\React\Ami\Protocol\Response */
7881

7982
$this->assertInstanceOf('Clue\React\Ami\Protocol\Response', $first);
8083
$this->assertEquals('Follows', $first->getFieldValue('Response'));
@@ -90,7 +93,7 @@ public function testParsingCommandResponseEmpty()
9093
$this->assertCount(1, $ret);
9194

9295
$first = reset($ret);
93-
/* @var $first Clue\React\Ami\Protocol\Response */
96+
/* @var $first \Clue\React\Ami\Protocol\Response */
9497

9598
$this->assertInstanceOf('Clue\React\Ami\Protocol\Response', $first);
9699
$this->assertEquals('Follows', $first->getFieldValue('Response'));
@@ -106,7 +109,7 @@ public function testParsingResponseIsNotCommandResponse()
106109
$this->assertCount(1, $ret);
107110

108111
$first = reset($ret);
109-
/* @var $first Clue\React\Ami\Protocol\Response */
112+
/* @var $first \Clue\React\Ami\Protocol\Response */
110113

111114
$this->assertInstanceOf('Clue\React\Ami\Protocol\Response', $first);
112115
$this->assertEquals('Success', $first->getFieldValue('Response'));
@@ -133,7 +136,7 @@ public function testParsingMissingSpaceWithValue()
133136
$this->assertCount(1, $ret);
134137

135138
$first = reset($ret);
136-
/* @var $first Clue\React\Ami\Protocol\Response */
139+
/* @var $first \Clue\React\Ami\Protocol\Response */
137140

138141
$this->assertInstanceOf('Clue\React\Ami\Protocol\Response', $first);
139142
$this->assertEquals('NoSpace', $first->getFieldValue('Response'));
@@ -148,7 +151,7 @@ public function testParsingMissingSpaceEmptyValue()
148151
$this->assertCount(1, $ret);
149152

150153
$first = reset($ret);
151-
/* @var $first Clue\React\Ami\Protocol\Response */
154+
/* @var $first \Clue\React\Ami\Protocol\Response */
152155

153156
$this->assertInstanceOf('Clue\React\Ami\Protocol\Response', $first);
154157
$this->assertEquals('', $first->getFieldValue('Response'));

0 commit comments

Comments
 (0)