Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build to use stages (adding PHPCS to check for CS violations) #2849

Merged
merged 5 commits into from
Sep 10, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Upgrade to PHPUnit 6.3
  • Loading branch information
lcobucci committed Sep 9, 2017
commit 5ad704e9be92e8a62a613f13fa7eb6d23aec7f3e
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"doctrine/common": "^2.7.1"
},
"require-dev": {
"phpunit/phpunit": "^5.4.6",
"phpunit/phpunit": "^6.3",
"phpunit/phpunit-mock-objects": "!=3.2.4,!=3.2.5",
"symfony/console": "2.*||^3.0"
},
Expand Down
11 changes: 7 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
Example: phpunit -c mysqlconf.xml
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
backupGlobals="false"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
verbose="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
>
<php>
<ini name="error_reporting" value="-1" />
Expand All @@ -30,7 +32,7 @@
<var name="db_port" value="3306"/>
-->
<!--<var name="db_event_subscribers" value="Doctrine\DBAL\Event\Listeners\OracleSessionInit">-->

<!-- Database for temporary connections (i.e. to drop/create the main database) -->
<var name="tmpdb_type" value="pdo_mysql"/>
<var name="tmpdb_host" value="localhost" />
Expand All @@ -49,6 +51,7 @@
<directory>./tests/Doctrine/Tests/DBAL/Performance</directory>
</testsuite>
</testsuites>

<listeners>
<listener class="Doctrine\Tests\DbalPerformanceTestListener"/>
</listeners>
Expand Down
17 changes: 10 additions & 7 deletions tests/Doctrine/Tests/DBAL/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@

use Doctrine\Common\Cache\Cache;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Cache\ArrayStatement;
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ConnectionException;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\Tests\Mocks\DriverConnectionMock;
use Doctrine\Tests\Mocks\DriverMock;
use Doctrine\DBAL\Cache\ArrayStatement;
use Doctrine\Tests\Mocks\VersionAwarePlatformDriverMock;

class ConnectionTest extends \Doctrine\Tests\DbalTestCase
Expand Down Expand Up @@ -64,25 +66,25 @@ public function testNoTransactionActiveByDefault()

public function testCommitWithNoActiveTransaction_ThrowsException()
{
$this->setExpectedException('Doctrine\DBAL\ConnectionException');
$this->expectException(ConnectionException::class);
$this->_conn->commit();
}

public function testRollbackWithNoActiveTransaction_ThrowsException()
{
$this->setExpectedException('Doctrine\DBAL\ConnectionException');
$this->expectException(ConnectionException::class);
$this->_conn->rollBack();
}

public function testSetRollbackOnlyNoActiveTransaction_ThrowsException()
{
$this->setExpectedException('Doctrine\DBAL\ConnectionException');
$this->expectException(ConnectionException::class);
$this->_conn->setRollbackOnly();
}

public function testIsRollbackOnlyNoActiveTransaction_ThrowsException()
{
$this->setExpectedException('Doctrine\DBAL\ConnectionException');
$this->expectException(ConnectionException::class);
$this->_conn->isRollbackOnly();
}

Expand Down Expand Up @@ -156,7 +158,8 @@ public function testEventManagerPassedToPlatform()
*/
public function testDriverExceptionIsWrapped($method)
{
$this->setExpectedException('Doctrine\DBAL\DBALException', "An exception occurred while executing 'MUUHAAAAHAAAA':\n\nSQLSTATE[HY000]: General error: 1 near \"MUUHAAAAHAAAA\"");
$this->expectException(DBALException::class);
$this->expectExceptionMessage("An exception occurred while executing 'MUUHAAAAHAAAA':\n\nSQLSTATE[HY000]: General error: 1 near \"MUUHAAAAHAAAA\"");

$con = \Doctrine\DBAL\DriverManager::getConnection(array(
'driver' => 'pdo_sqlite',
Expand Down Expand Up @@ -666,7 +669,7 @@ public function testCallingDeleteWithNoDeletionCriteriaResultsInInvalidArgumentE

$conn = new Connection(array('pdo' => $pdoMock), $driver);

$this->setExpectedException('Doctrine\DBAL\Exception\InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);
$conn->delete('kittens', array());
}

Expand Down
11 changes: 7 additions & 4 deletions tests/Doctrine/Tests/DBAL/DriverManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Doctrine\Tests\DBAL;

use Doctrine\DBAL\DBALException;
use Doctrine\Tests\Mocks\PDOMock;

class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
{
/**
Expand Down Expand Up @@ -82,7 +85,7 @@ public function testCustomWrapper()

public function testInvalidWrapperClass()
{
$this->setExpectedException('\Doctrine\DBAL\DBALException');
$this->expectException(DBALException::class);

$options = array(
'pdo' => new \PDO('sqlite::memory:'),
Expand All @@ -94,7 +97,7 @@ public function testInvalidWrapperClass()

public function testInvalidDriverClass()
{
$this->setExpectedException('\Doctrine\DBAL\DBALException');
$this->expectException(DBALException::class);

$options = array(
'driverClass' => 'stdClass'
Expand Down Expand Up @@ -123,7 +126,7 @@ public function testDatabaseUrl($url, $expected)
);

if ($expected === false) {
$this->setExpectedException('Doctrine\DBAL\DBALException');
$this->expectException(DBALException::class);
}

$conn = \Doctrine\DBAL\DriverManager::getConnection($options);
Expand All @@ -140,7 +143,7 @@ public function testDatabaseUrl($url, $expected)

public function databaseUrls()
{
$pdoMock = $this->getMock('Doctrine\Tests\Mocks\PDOMock');
$pdoMock = $this->createMock(PDOMock::class);

return array(
'simple URL' => array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
namespace Doctrine\Tests\DBAL\Exception;

use Doctrine\DBAL\Exception\InvalidArgumentException;
use PHPUnit_Framework_TestCase;

/**
* Tests for {@see \Doctrine\DBAL\Exception\InvalidArgumentException}
Expand All @@ -29,7 +28,7 @@
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
class InvalidArgumentExceptionTest extends PHPUnit_Framework_TestCase
class InvalidArgumentExceptionTest extends \PHPUnit\Framework\TestCase
{
public function testFromEmptyCriteria()
{
Expand Down
15 changes: 10 additions & 5 deletions tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function testCommitWithRollbackOnlyThrowsException()
{
$this->_conn->beginTransaction();
$this->_conn->setRollbackOnly();
$this->setExpectedException('Doctrine\DBAL\ConnectionException');

$this->expectException(ConnectionException::class);
$this->_conn->commit();
}

Expand Down Expand Up @@ -121,7 +122,8 @@ public function testSetNestedTransactionsThroughSavepointsNotSupportedThrowsExce
$this->markTestSkipped('This test requires the platform not to support savepoints.');
}

$this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver.");
$this->expectException(ConnectionException::class);
$this->expectExceptionMessage("Savepoints are not supported by this driver.");

$this->_conn->setNestTransactionsWithSavepoints(true);
}
Expand All @@ -132,7 +134,8 @@ public function testCreateSavepointsNotSupportedThrowsException()
$this->markTestSkipped('This test requires the platform not to support savepoints.');
}

$this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver.");
$this->expectException(ConnectionException::class);
$this->expectExceptionMessage("Savepoints are not supported by this driver.");

$this->_conn->createSavepoint('foo');
}
Expand All @@ -143,7 +146,8 @@ public function testReleaseSavepointsNotSupportedThrowsException()
$this->markTestSkipped('This test requires the platform not to support savepoints.');
}

$this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver.");
$this->expectException(ConnectionException::class);
$this->expectExceptionMessage("Savepoints are not supported by this driver.");

$this->_conn->releaseSavepoint('foo');
}
Expand All @@ -154,7 +158,8 @@ public function testRollbackSavepointsNotSupportedThrowsException()
$this->markTestSkipped('This test requires the platform not to support savepoints.');
}

$this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver.");
$this->expectException(ConnectionException::class);
$this->expectExceptionMessage("Savepoints are not supported by this driver.");

$this->_conn->rollbackSavepoint('foo');
}
Expand Down
43 changes: 21 additions & 22 deletions tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional;

use Doctrine\DBAL\Driver\ExceptionConverterDriver;
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Schema\Table;

class ExceptionTest extends \Doctrine\Tests\DbalFunctionalTestCase
Expand All @@ -26,16 +26,15 @@ public function testPrimaryConstraintViolationException()

$this->_conn->insert("duplicatekey_table", array('id' => 1));

$this->setExpectedException(
'\Doctrine\DBAL\Exception\UniqueConstraintViolationException');
$this->expectException(Exception\UniqueConstraintViolationException::class);
$this->_conn->insert("duplicatekey_table", array('id' => 1));
}

public function testTableNotFoundException()
{
$sql = "SELECT * FROM unknown_table";

$this->setExpectedException('\Doctrine\DBAL\Exception\TableNotFoundException');
$this->expectException(Exception\TableNotFoundException::class);
$this->_conn->executeQuery($sql);
}

Expand All @@ -46,7 +45,7 @@ public function testTableExistsException()
$table->addColumn('id', 'integer', array());
$table->setPrimaryKey(array('id'));

$this->setExpectedException('\Doctrine\DBAL\Exception\TableExistsException');
$this->expectException(Exception\TableExistsException::class);
$schemaManager->createTable($table);
$schemaManager->createTable($table);
}
Expand All @@ -68,11 +67,11 @@ public function testForeignKeyConstraintViolationExceptionOnInsert()
throw $exception;
}

$this->setExpectedException('\Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException');
$this->expectException(Exception\ForeignKeyConstraintViolationException::class);

try {
$this->_conn->insert('owning_table', array('id' => 2, 'constraint_id' => 2));
} catch (ForeignKeyConstraintViolationException $exception) {
} catch (Exception\ForeignKeyConstraintViolationException $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();

throw $exception;
Expand Down Expand Up @@ -102,11 +101,11 @@ public function testForeignKeyConstraintViolationExceptionOnUpdate()
throw $exception;
}

$this->setExpectedException('\Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException');
$this->expectException(Exception\ForeignKeyConstraintViolationException::class);

try {
$this->_conn->update('constraint_error_table', array('id' => 2), array('id' => 1));
} catch (ForeignKeyConstraintViolationException $exception) {
} catch (Exception\ForeignKeyConstraintViolationException $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();

throw $exception;
Expand Down Expand Up @@ -136,11 +135,11 @@ public function testForeignKeyConstraintViolationExceptionOnDelete()
throw $exception;
}

$this->setExpectedException('\Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException');
$this->expectException(Exception\ForeignKeyConstraintViolationException::class);

try {
$this->_conn->delete('constraint_error_table', array('id' => 1));
} catch (ForeignKeyConstraintViolationException $exception) {
} catch (Exception\ForeignKeyConstraintViolationException $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();

throw $exception;
Expand Down Expand Up @@ -172,11 +171,11 @@ public function testForeignKeyConstraintViolationExceptionOnTruncate()
throw $exception;
}

$this->setExpectedException('\Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException');
$this->expectException(Exception\ForeignKeyConstraintViolationException::class);

try {
$this->_conn->executeUpdate($platform->getTruncateTableSQL('constraint_error_table'));
} catch (ForeignKeyConstraintViolationException $exception) {
} catch (Exception\ForeignKeyConstraintViolationException $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();

throw $exception;
Expand All @@ -202,7 +201,7 @@ public function testNotNullConstraintViolationException()
$this->_conn->exec($sql);
}

$this->setExpectedException('\Doctrine\DBAL\Exception\NotNullConstraintViolationException');
$this->expectException(Exception\NotNullConstraintViolationException::class);
$this->_conn->insert("notnull_table", array('id' => 1, 'value' => null));
}

Expand All @@ -217,7 +216,7 @@ public function testInvalidFieldNameException()
$this->_conn->exec($sql);
}

$this->setExpectedException('\Doctrine\DBAL\Exception\InvalidFieldNameException');
$this->expectException(Exception\InvalidFieldNameException::class);
$this->_conn->insert("bad_fieldname_table", array('name' => 5));
}

Expand All @@ -236,7 +235,7 @@ public function testNonUniqueFieldNameException()
}

$sql = 'SELECT id FROM ambiguous_list_table, ambiguous_list_table_2';
$this->setExpectedException('\Doctrine\DBAL\Exception\NonUniqueFieldNameException');
$this->expectException(Exception\NonUniqueFieldNameException::class);
$this->_conn->executeQuery($sql);
}

Expand All @@ -253,7 +252,7 @@ public function testUniqueConstraintViolationException()
}

$this->_conn->insert("unique_field_table", array('id' => 5));
$this->setExpectedException('\Doctrine\DBAL\Exception\UniqueConstraintViolationException');
$this->expectException(Exception\UniqueConstraintViolationException::class);
$this->_conn->insert("unique_field_table", array('id' => 5));
}

Expand All @@ -266,7 +265,7 @@ public function testSyntaxErrorException()
$this->_conn->getSchemaManager()->createTable($table);

$sql = 'SELECT id FRO syntax_error_table';
$this->setExpectedException('\Doctrine\DBAL\Exception\SyntaxErrorException');
$this->expectException(Exception\SyntaxErrorException::class);
$this->_conn->executeQuery($sql);
}

Expand Down Expand Up @@ -299,7 +298,7 @@ public function testConnectionExceptionSqLite($mode, $exceptionClass)
$table = $schema->createTable("no_connection");
$table->addColumn('id', 'integer');

$this->setExpectedException($exceptionClass);
$this->expectException($exceptionClass);
foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
$conn->exec($sql);
}
Expand All @@ -309,8 +308,8 @@ public function getSqLiteOpenConnection()
{
return array(
// mode 0 is considered read-only on Windows
array(0000, defined('PHP_WINDOWS_VERSION_BUILD') ? '\Doctrine\DBAL\Exception\ReadOnlyException' : '\Doctrine\DBAL\Exception\ConnectionException'),
array(0444, '\Doctrine\DBAL\Exception\ReadOnlyException'),
array(0000, defined('PHP_WINDOWS_VERSION_BUILD') ? Exception\ReadOnlyException::class : Exception\ConnectionException::class),
array(0444, Exception\ReadOnlyException::class),
);
}

Expand Down Expand Up @@ -340,7 +339,7 @@ public function testConnectionException($params)
$table = $schema->createTable("no_connection");
$table->addColumn('id', 'integer');

$this->setExpectedException('Doctrine\DBAL\Exception\ConnectionException');
$this->expectException(Exception\ConnectionException::class);

foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
$conn->exec($sql);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* @group DBAL-461
*/
class DBAL461Test extends \PHPUnit_Framework_TestCase
class DBAL461Test extends \PHPUnit\Framework\TestCase
{
public function testIssue()
{
Expand Down
Loading