Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"vlucas/phpdotenv": "^5.6.1",
"yiisoft/aliases": "^2.0",
"yiisoft/log-target-file": "^2.0.1",
"yiisoft/cache-file": "^3.2",
"yiisoft/psr-dummy-provider": "^1.0",
"yiisoft/test-support": "^3.0",
"yiisoft/var-dumper": "^1.7"
},
"provide": {
Expand Down
6 changes: 2 additions & 4 deletions tests/BatchQueryResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@

namespace Yiisoft\Db\Mysql\Tests;

use Yiisoft\Db\Mysql\Tests\Support\TestTrait;
use Yiisoft\Db\Mysql\Tests\Support\IntegrationTestTrait;
use Yiisoft\Db\Tests\Common\CommonBatchQueryResultTest;

/**
* @group mysql
*
* @psalm-suppress PropertyNotSetInConstructor
*/
final class BatchQueryResultTest extends CommonBatchQueryResultTest
{
use TestTrait;
use IntegrationTestTrait;
}
8 changes: 4 additions & 4 deletions tests/ColumnBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

use PHPUnit\Framework\Attributes\DataProviderExternal;
use Yiisoft\Db\Mysql\Tests\Provider\ColumnBuilderProvider;
use Yiisoft\Db\Mysql\Tests\Support\TestTrait;
use Yiisoft\Db\Tests\AbstractColumnBuilderTest;
use Yiisoft\Db\Mysql\Tests\Support\IntegrationTestTrait;
use Yiisoft\Db\Tests\Common\CommonColumnBuilderTest;

/**
* @group mysql
*/
class ColumnBuilderTest extends AbstractColumnBuilderTest
class ColumnBuilderTest extends CommonColumnBuilderTest
{
use TestTrait;
use IntegrationTestTrait;

#[DataProviderExternal(ColumnBuilderProvider::class, 'buildingMethods')]
public function testBuildingMethods(
Expand Down
12 changes: 5 additions & 7 deletions tests/ColumnFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
use Yiisoft\Db\Expression\Expression;
use Yiisoft\Db\Mysql\Column\ColumnFactory;
use Yiisoft\Db\Mysql\Tests\Provider\ColumnFactoryProvider;
use Yiisoft\Db\Mysql\Tests\Support\TestTrait;
use Yiisoft\Db\Mysql\Tests\Support\IntegrationTestTrait;
use Yiisoft\Db\Schema\Column\ColumnInterface;
use Yiisoft\Db\Tests\AbstractColumnFactoryTest;
use Yiisoft\Db\Tests\Common\CommonColumnFactoryTest;

/**
* @group mysql
*/
final class ColumnFactoryTest extends AbstractColumnFactoryTest
final class ColumnFactoryTest extends CommonColumnFactoryTest
{
use TestTrait;
use IntegrationTestTrait;

#[DataProviderExternal(ColumnFactoryProvider::class, 'dbTypes')]
public function testFromDbType(string $dbType, string $expectedType, string $expectedInstanceOf): void
Expand Down Expand Up @@ -52,14 +52,12 @@ public function testFromTypeDefaultValueRaw(string $type, ?string $defaultValueR

public function testExpressionDefaultValueRaw(): void
{
$db = $this->getConnection();
$db = $this->getSharedConnection();
$columnFactory = $db->getColumnFactory();

$column = $columnFactory->fromType(ColumnType::DATETIME, ['defaultValueRaw' => 'now()', 'extra' => 'DEFAULT_GENERATED']);

$this->assertEquals(new Expression('now()'), $column->getDefaultValue());

$db->close();
}

protected function getColumnFactoryClass(): string
Expand Down
16 changes: 9 additions & 7 deletions tests/ColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Yiisoft\Db\Mysql\Column\ColumnBuilder;
use Yiisoft\Db\Mysql\Column\StringColumn;
use Yiisoft\Db\Mysql\Tests\Provider\ColumnProvider;
use Yiisoft\Db\Mysql\Tests\Support\TestTrait;
use Yiisoft\Db\Mysql\Tests\Support\IntegrationTestTrait;
use Yiisoft\Db\Query\Query;
use Yiisoft\Db\Schema\Column\BinaryColumn;
use Yiisoft\Db\Schema\Column\BooleanColumn;
Expand All @@ -30,11 +30,11 @@
*/
final class ColumnTest extends CommonColumnTest
{
use TestTrait;
use IntegrationTestTrait;

public function testSelectWithPhpTypecasting(): void
{
$db = $this->getConnection();
$db = $this->getSharedConnection();

$sql = <<<SQL
SELECT
Expand Down Expand Up @@ -91,7 +91,8 @@ public function testSelectWithPhpTypecasting(): void
#[DataProviderExternal(ColumnProvider::class, 'bigIntValue')]
public function testColumnBigInt(string $bigint): void
{
$db = $this->getConnection(true);
$db = $this->getSharedConnection();
$this->loadFixture();

$command = $db->createCommand();
$command->insert('negative_default_values', ['bigint_col' => $bigint]);
Expand All @@ -105,7 +106,8 @@ public function testColumnBigInt(string $bigint): void

public function testColumnInstance(): void
{
$db = $this->getConnection(true);
$db = $this->getSharedConnection();
$this->loadFixture();
$schema = $db->getSchema();
$tableSchema = $schema->getTableSchema('type');

Expand All @@ -121,7 +123,7 @@ public function testColumnInstance(): void

public function testLongtextType(): void
{
$db = $this->getConnection();
$db = $this->getSharedConnection();
$command = $db->createCommand();

try {
Expand Down Expand Up @@ -151,7 +153,7 @@ public function testLongtextType(): void

public function testTimestampColumnOnDifferentTimezones(): void
{
$db = $this->getConnection();
$db = $this->createConnection();
$schema = $db->getSchema();
$command = $db->createCommand();
$tableName = 'timestamp_column_test';
Expand Down
32 changes: 20 additions & 12 deletions tests/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,22 @@

namespace Yiisoft\Db\Mysql\Tests;

use Closure;
use PHPUnit\Framework\Attributes\DataProviderExternal;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Mysql\Tests\Provider\CommandProvider;
use Yiisoft\Db\Mysql\Tests\Support\TestTrait;
use Yiisoft\Db\Mysql\Tests\Support\IntegrationTestTrait;
use Yiisoft\Db\Mysql\Tests\Support\TestConnection;
use Yiisoft\Db\Query\Query;
use Yiisoft\Db\Tests\Common\CommonCommandTest;

/**
* @group mysql
*
* @psalm-suppress PropertyNotSetInConstructor
*/
final class CommandTest extends CommonCommandTest
{
use TestTrait;

protected string $upsertTestCharCast = 'CONVERT([[address]], CHAR)';
use IntegrationTestTrait;

public function testAddCheck(): void
{
Expand All @@ -41,7 +39,8 @@ public function testAddDefaultValue(): void

public function testAlterColumn(): void
{
$db = $this->getConnection(true);
$db = $this->getSharedConnection();
$this->loadFixture();

$command = $db->createCommand();
$command->alterColumn('{{customer}}', 'email', 'text')->execute();
Expand Down Expand Up @@ -84,7 +83,7 @@ public function testDropDefaultValue(): void

public function testDropTableCascade(): void
{
$db = $this->getConnection();
$db = $this->getSharedConnection();
$command = $db->createCommand();

$this->expectException(NotSupportedException::class);
Expand All @@ -102,7 +101,9 @@ public function testGetRawSql(string $sql, array $params, string $expectedRawSql

public function testInsertReturningPksWithSubqueryAndNoAutoincrement(): void
{
$db = $this->getConnection(true);
$db = $this->getSharedConnection();
$this->loadFixture();

$command = $db->createCommand();

$query = (new Query($db))->select(['order_id' => 1, 'item_id' => 2, 'quantity' => 3, 'subtotal' => 4]);
Expand All @@ -120,7 +121,7 @@ public function testUpdate(
string $table,
array $columns,
array|ExpressionInterface|string $conditions,
array|ExpressionInterface|string|null $from,
Closure|array|ExpressionInterface|string|null $from,
array $params,
array $expectedValues,
int $expectedCount,
Expand All @@ -129,19 +130,26 @@ public function testUpdate(
}

#[DataProviderExternal(CommandProvider::class, 'upsert')]
public function testUpsert(array $firstData, array $secondData): void
public function testUpsert(Closure|array $firstData, Closure|array $secondData): void
{
parent::testUpsert($firstData, $secondData);
}

public function testShowDatabases(): void
{
$this->assertSame([self::getDatabaseName()], self::getDb()->createCommand()->showDatabases());
$db = $this->getSharedConnection();

$this->assertSame([TestConnection::databaseName()], $db->createCommand()->showDatabases());
}

#[DataProviderExternal(CommandProvider::class, 'createIndex')]
public function testCreateIndex(array $columns, array $indexColumns, ?string $indexType, ?string $indexMethod): void
{
parent::testCreateIndex($columns, $indexColumns, $indexType, $indexMethod);
}

protected function getUpsertTestCharCast(): string
{
return 'CONVERT([[address]], CHAR)';
}
}
Loading
Loading