Skip to content

Commit

Permalink
Upgrade to PHPUnit 8
Browse files Browse the repository at this point in the history
  • Loading branch information
mbonneau committed Dec 14, 2019
1 parent b3b7a8a commit 7be3263
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ before_script:
- sh docker/waitForPostgres.sh

script:
- vendor/bin/phpunit
- vendor/bin/phpunit --testdox
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"evenement/evenement": "^2.0 | ^3.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"phpunit/phpunit": "^8",
"react/dns": "^1.0"
}
}
4 changes: 2 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
Expand All @@ -8,7 +9,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php">
<testsuites>
<testsuite name="PgAsync Tests">
Expand Down
27 changes: 20 additions & 7 deletions tests/Integration/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,31 +205,44 @@ function () {

public function testCancellationUsingDispose()
{
$this->markTestSkipped('We have disabled cancellation for the time being.');
$conn = new Connection([
"user" => $this->getDbUser(),
"database" => $this::getDbName()
"database" => $this::getDbName(),
"auto_disconnect" => true
], $this->getLoop());

$testQuery = $conn->query("SELECT pg_sleep(10)")->mapTo(1);
$disposed = false;

$testQuery->takeUntil(Observable::timer(500))->subscribe(
$testQuery = $conn->query("SELECT pg_sleep(10)")
->mapTo(1)
->finally(function () use (&$disposed) {
$disposed = true;
});

//$disposable = $testQuery->takeUntil(Observable::timer(500))->subscribe(
$disposable = $testQuery->subscribe(
function ($results) {
$this->fail('Expected no value');
$this->stopLoop();
$this->fail('Expected no value');
},
function (\Throwable $e) {
$this->fail('Expected no error');
$this->stopLoop();
$this->fail('Expected no error');
},
function () {
$this->stopLoop();
$this->fail('Expected no completion');
}
);

$this->getLoop()->addTimer(500, function () use ($disposable) {
$disposable->dispose();
});

$this->runLoopWithTimeout(2);

$conn->disconnect();
$this->getLoop()->run();
$this->assertTrue($disposed);
}

public function testCancellationUsingInternalFunctions()
Expand Down
12 changes: 3 additions & 9 deletions tests/Unit/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,21 @@

class ConnectionTest extends TestCase
{
/**
* @expectedException \InvalidArgumentException
*/
public function testInvalidParametersThrows()
{
$this->expectException(\InvalidArgumentException::class);
$conn = new Connection(['something' => ''], $this->getLoop());
}

/**
* @expectedException \InvalidArgumentException
*/
public function testNoUserThrows()
{
$this->expectException(\InvalidArgumentException::class);
$conn = new Connection(["database" => "some_database"], $this->getLoop());
}

/**
* @expectedException \InvalidArgumentException
*/
public function testNoDatabaseThrows()
{
$this->expectException(\InvalidArgumentException::class);
$conn = new Connection(["user" => "some_user"], $this->getLoop());
}
}
4 changes: 3 additions & 1 deletion tests/Unit/Message/MessageTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

class MessageTest extends PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class MessageTest extends TestCase
{
public function testInt32()
{
Expand Down

0 comments on commit 7be3263

Please sign in to comment.