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
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ composer.phar
phpunit.phar
# local phpunit config
/phpunit.xml
# phpunit cache
.phpunit.result.cache
.phpunit.cache

# Phan
analysis.txt

# PHP CS Fixer
/.php-cs-fixer.cache
/.php-cs-fixer.php
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
]);

return (new Config())
->setCacheFile(__DIR__ . '/runtime/.php-cs-fixer.cache')
->setRiskyAllowed(true)
->setParallelConfig(ParallelConfigFactory::detect())
->setRules([
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"psr-4": {
"Yiisoft\\Db\\Migration\\Tests\\": "tests",
"Yiisoft\\Db\\Migration\\Tests\\NonExistsDirectory\\": "tests/non-exists-directory",
"Yiisoft\\Db\\Migration\\Tests\\Runtime\\": "runtime/tests",
"Yiisoft\\Db\\Migration\\Tests\\ForTest\\": "tests/Support",
"Yiisoft\\Db\\Migration\\Tests\\Support\\": "tests/Support",
"Yiisoft\\Db\\Migration\\Tests\\Support\\MigrationsExtra\\": [
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
cacheDirectory="runtime/.phpunit.cache"
colors="true"
failOnRisky="true"
failOnWarning="true"
Expand Down
File renamed without changes.
20 changes: 10 additions & 10 deletions tests/Migration/BinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ protected function setUp(): void
{
FileHelper::copyFile(
dirname(__DIR__, 2) . '/bin/yii-db-migration',
dirname(__DIR__) . '/runtime/bin/vendor/yiisoft/db-migration/bin/yii-db-migration',
dirname(__DIR__, 2) . '/runtime/tests/bin/vendor/yiisoft/db-migration/bin/yii-db-migration',
);
FileHelper::copyFile(
dirname(__DIR__, 2) . '/bin/yii-db-migration.php',
dirname(__DIR__) . '/runtime/bin/yii-db-migration.php',
dirname(__DIR__, 2) . '/runtime/tests/bin/yii-db-migration.php',
);
}

protected function tearDown(): void
{
FileHelper::removeDirectory(dirname(__DIR__) . '/runtime/bin');
FileHelper::removeDirectory(dirname(__DIR__, 2) . '/runtime/tests/bin');
}

public function testBase(): void
Expand Down Expand Up @@ -62,15 +62,15 @@ public function testWithoutConnection(): void

public function testWithoutConfig(): void
{
unlink(dirname(__DIR__) . '/runtime/bin/yii-db-migration.php');
unlink(dirname(__DIR__, 2) . '/runtime/tests/bin/yii-db-migration.php');

[$output, $exitCode] = $this->runYiiDbMigration();

$this->assertSame(1, $exitCode);
$this->assertStringContainsString('not found', $output);
$this->assertStringContainsString(
'cp "' . dirname(__DIR__) . '/runtime/bin/vendor/yiisoft/db-migration/bin/yii-db-migration.php" "'
. dirname(__DIR__) . '/runtime/bin/yii-db-migration.php"',
'cp "' . dirname(__DIR__, 2) . '/runtime/tests/bin/vendor/yiisoft/db-migration/bin/yii-db-migration.php" "'
. dirname(__DIR__, 2) . '/runtime/tests/bin/yii-db-migration.php"',
$output,
);
}
Expand All @@ -95,7 +95,7 @@ public function testNamedDatabase(): void
),
],
PHP);
$directory = dirname(__DIR__) . '/runtime/bin';
$directory = dirname(__DIR__, 2) . '/runtime/tests/bin';
FileHelper::ensureDirectory($directory . '/maps');
file_put_contents($directory . '/maps/M260930000000Maps.php', <<<'PHP'
<?php
Expand All @@ -121,7 +121,7 @@ public function up(\Yiisoft\Db\Migration\MigrationBuilder $b): void

public function testNamedDefaultWithoutLegacyOptions(): void
{
$directory = dirname(__DIR__) . '/runtime/bin';
$directory = dirname(__DIR__, 2) . '/runtime/tests/bin';
FileHelper::ensureDirectory($directory . '/migrations');
file_put_contents($directory . '/yii-db-migration.php', $this->namedDefaultConfig());
[$output, $exitCode] = $this->runYiiDbMigration(['migrate:create', 'Example']);
Expand All @@ -144,7 +144,7 @@ public static function legacyOptions(): array
#[DataProvider('legacyOptions')]
public function testRejectsDuplicateDefaultConfiguration(string $option): void
{
$directory = dirname(__DIR__) . '/runtime/bin';
$directory = dirname(__DIR__, 2) . '/runtime/tests/bin';
file_put_contents($directory . '/yii-db-migration.php', str_replace(
'return [',
"return ['$option' => null,",
Expand Down Expand Up @@ -177,7 +177,7 @@ private function namedDefaultConfig(): string

private function replaceParams($search, $replace): void
{
$file = dirname(__DIR__) . '/runtime/bin/yii-db-migration.php';
$file = dirname(__DIR__, 2) . '/runtime/tests/bin/yii-db-migration.php';
file_put_contents(
$file,
str_replace($search, $replace, file_get_contents($file)),
Expand Down
2 changes: 1 addition & 1 deletion tests/Migration/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private function createConsoleContainer(array $databases = []): Container
'class' => SqLiteConnection::class,
'__construct()' => [
'driver' => new SqLiteDriver(
'sqlite:' . dirname(__DIR__, 2) . '/runtime/config-test.sq3',
'sqlite:' . dirname(__DIR__, 2) . '/runtime/tests/config-test.sq3',
),
],
],
Expand Down
2 changes: 1 addition & 1 deletion tests/Migration/bin-runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

$_composer_autoload_path = \dirname(__DIR__, 2) . '/vendor/autoload.php';

require \dirname(__DIR__) . '/runtime/bin/vendor/yiisoft/db-migration/bin/yii-db-migration';
require \dirname(__DIR__, 2) . '/runtime/tests/bin/vendor/yiisoft/db-migration/bin/yii-db-migration';
8 changes: 4 additions & 4 deletions tests/Support/Helper/MigrationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

final class MigrationHelper
{
public const NAMESPACE = 'Yiisoft\\Db\\Migration\\Tests\\runtime\\MigrationNamespace';
public const NAMESPACE = 'Yiisoft\\Db\\Migration\\Tests\\Runtime\\MigrationNamespace';

public static function getRuntimePath(): string
{
return dirname(__DIR__, 2) . '/runtime/migration-path';
return dirname(__DIR__, 3) . '/runtime/tests/migration-path';
}

/**
Expand Down Expand Up @@ -112,7 +112,7 @@ public static function createAndApplyMigration(

public static function getPathForMigrationNamespace(): string
{
return dirname(__DIR__, 2) . '/runtime/MigrationNamespace';
return dirname(__DIR__, 3) . '/runtime/tests/MigrationNamespace';
}

public static function resetPathAndNamespace(ContainerInterface $container): void
Expand All @@ -135,7 +135,7 @@ private static function preparePaths(): void
foreach ($paths as $path) {
file_exists($path)
? FileHelper::clearDirectory($path)
: mkdir($path);
: FileHelper::ensureDirectory($path);
}
}
}
Loading