Skip to content

Commit

Permalink
fix and test
Browse files Browse the repository at this point in the history
  • Loading branch information
kfrankiewicz committed Nov 6, 2024
1 parent be177d2 commit 9f64ea0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Metadata/Storage/TableMetadataStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ private function updateMigratedVersionsFromV1orV2toV3(): void

private function isAlreadyV3Format(AvailableMigration $availableMigration, ExecutedMigration $executedMigration): bool
{
return $availableMigration->getVersion() !== $executedMigration->getVersion()
&& strpos(
return (string) $availableMigration->getVersion() === (string) $executedMigration->getVersion()
|| strpos(
(string) $availableMigration->getVersion(),
(string) $executedMigration->getVersion(),
) !== strlen((string) $availableMigration->getVersion()) -
Expand Down
20 changes: 20 additions & 0 deletions tests/Metadata/Storage/TableMetadataStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\StringType;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\Migrations\Exception\MetadataStorageError;
use Doctrine\Migrations\Metadata\AvailableMigration;
use Doctrine\Migrations\Metadata\ExecutedMigration;
use Doctrine\Migrations\Metadata\Storage\TableMetadataStorage;
use Doctrine\Migrations\Metadata\Storage\TableMetadataStorageConfiguration;
use Doctrine\Migrations\Version\AlphabeticalComparator;
Expand Down Expand Up @@ -400,4 +403,21 @@ public function testGetSql(): void

self::assertCount(0, $this->connection->fetchAllAssociative($sql));
}

public function testIsAlreadyV3FormatDoesntMissTheSameVersions()

Check failure on line 407 in tests/Metadata/Storage/TableMetadataStorageTest.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.3)

Method Doctrine\Migrations\Tests\Metadata\Storage\TableMetadataStorageTest::testIsAlreadyV3FormatDoesntMissTheSameVersions() has no return type specified.

Check failure on line 407 in tests/Metadata/Storage/TableMetadataStorageTest.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Method \Doctrine\Migrations\Tests\Metadata\Storage\TableMetadataStorageTest::testIsAlreadyV3FormatDoesntMissTheSameVersions() does not have void return type hint.
{
$availableMigration = new AvailableMigration(

Check failure on line 409 in tests/Metadata/Storage/TableMetadataStorageTest.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space
new Version('Foo\\Version1234'),
$this->createMock(AbstractMigration::class)

Check failure on line 411 in tests/Metadata/Storage/TableMetadataStorageTest.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Multi-line function calls must have a trailing comma after the last parameter.
);
$executedMigrationV3 = new ExecutedMigration(new Version('Foo\\Version1234'));

Check failure on line 413 in tests/Metadata/Storage/TableMetadataStorageTest.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space
$executedMigrationOlder = new ExecutedMigration(new Version('Version1234'));

$reflection = new \ReflectionClass(TableMetadataStorage::class);

Check failure on line 416 in tests/Metadata/Storage/TableMetadataStorageTest.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Class \ReflectionClass should not be referenced via a fully qualified name, but via a use statement.
$method = $reflection->getMethod('isAlreadyV3Format');

Check failure on line 417 in tests/Metadata/Storage/TableMetadataStorageTest.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space
$method->setAccessible(true);

self::assertTrue($method->invokeArgs($this->storage, [$availableMigration, $executedMigrationV3]));
self::assertFalse($method->invokeArgs($this->storage, [$availableMigration, $executedMigrationOlder]));
}
}

0 comments on commit 9f64ea0

Please sign in to comment.