Skip to content

Commit

Permalink
Merge branch '3.8.x' into 4.0.x
Browse files Browse the repository at this point in the history
* 3.8.x:
  Avoid calling deprecated Type::getName() (doctrine#6359)
  Ensure correct json default value normalization (doctrine#6358)
  Document how to run integration tests locally
  Remove unused script
  • Loading branch information
derrabus committed Apr 16, 2024
2 parents c70bae9 + edbf307 commit 7fb00fd
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 30 deletions.
13 changes: 0 additions & 13 deletions ci/travis/install-mariadb.sh

This file was deleted.

25 changes: 25 additions & 0 deletions docs/en/reference/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,31 @@ multiple concurrent database connections, transactions, locking, performance-rel
In such cases, it is still important that a pull request fixing the issues is accompanied by a free-form reproducer
that demonstrates the issue being fixed.

Running Integration Tests locally
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The default ``phpunit.xml.dist`` configuration file is set up to run the
integration tests against SQLite, but you need to enable the extension
``pdo_sqlite`` in your PHP configuration.

To run the integration tests against another platform, you can use one
of the configuration files used in our continuous integration setup.
Those are stored under ``ci/github/``.

For instance, to run tests against MySQL using the PDO driver, you
should spin up a MySQL server, enable the ``pdo_mysql`` extension, and
then run the following command:

.. code-block:: console
$ phpunit -c ci/github/pdo_mysql.xml
We do not currently have specific instructions on how to run a Database
server, but we do recommend Docker as a convenient way to do so.
We do not recommend running against a particular version of the chosen
RDBMS either, as long as you pick one of the
:doc:`officially supported versions <reference/platforms>`.

Recommendations on Writing Tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
21 changes: 4 additions & 17 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,11 @@
<php>
<ini name="error_reporting" value="-1" />

<!-- Test connection parameters -->
<!-- Uncomment, otherwise SQLite runs
<var name="db_driver" value="pdo_mysql"/>
<var name="db_host" value="localhost" />
<var name="db_port" value="3306"/>
<var name="db_user" value="root" />
<var name="db_password" value="" />
<var name="db_dbname" value="doctrine_tests" />
<!--
By default, the tests are run against SQLite.
If you want to run them against another DBMS,
see https://www.doctrine-project.org/projects/doctrine-dbal/en/stable/reference/testing.html#running-integration-tests-locally
-->
<!--<var name="db_event_subscribers" value="Doctrine\DBAL\Event\Listeners\OracleSessionInit">-->

<!-- Privileged user connection parameters. Used to create and drop the test database -->
<var name="tmpdb_driver" value="pdo_mysql"/>
<var name="tmpdb_host" value="localhost" />
<var name="tmpdb_port" value="3306"/>
<var name="tmpdb_user" value="root" />
<var name="tmpdb_password" value="" />
<var name="tmpdb_dbname" value="doctrine_tests_tmp" />
</php>

<testsuites>
Expand Down
1 change: 1 addition & 0 deletions src/Schema/PostgreSQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ protected function _getPortableTableColumnDefinition(array $tableColumn): Column
$length = null;
break;

case 'json':
case 'text':
case '_varchar':
case 'varchar':
Expand Down
14 changes: 14 additions & 0 deletions tests/Functional/Schema/PostgreSQLSchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,20 @@ public function testDefaultValueCharacterVarying(): void
self::assertEquals('foo', $databaseTable->getColumn('def')->getDefault());
}

public function testJsonDefaultValue(): void
{
$testTable = new Table('test_json');
$testTable
->addColumn('foo', Types::JSON)
->setDefault('{"key": "value with a single quote \' in string value"}');
$this->dropAndCreateTable($testTable);

$columns = $this->schemaManager->listTableColumns('test_json');

self::assertSame(Type::getType(Types::JSON), $columns['foo']->getType());
self::assertSame('{"key": "value with a single quote \' in string value"}', $columns['foo']->getDefault());
}

public function testBooleanDefault(): void
{
$table = new Table('ddc2843_bools');
Expand Down

0 comments on commit 7fb00fd

Please sign in to comment.