Skip to content

Commit

Permalink
OXDEV-7513 Upgrade phpunit from 9 to 10
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniil Tkachev committed Nov 9, 2023
1 parent 6e4baeb commit a914c98
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 66 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: git clone --depth 1 https://github.com/OXID-eSales/docker-eshop-sdk.git --branch master --single-branch .

- name: Clone Migration Wrapper (on default branch - ${{ github.event.repository.default_branch }})
run: git clone --branch ${{ github.ref_name }} https://github.com/OXID-eSales/oxideshop-doctrine-migration-wrapper.git source/$INSTALL_DIR
run: git clone --branch b-7.1.x-odmw-phpunit10-OXDEV-7518 https://github.com/OXID-eSales/oxideshop-doctrine-migration-wrapper.git source/$INSTALL_DIR

- name: Prepare container configuration
run: |
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
composer config allow-plugins.oxid-esales/oxideshop-unified-namespace-generator true
docker-compose exec -T -w /var/www/$INSTALL_DIR php \
composer config allow-plugins.oxid-esales/oxideshop-composer-plugin true
docker-compose exec -T -w /var/www/$INSTALL_DIR -e COMPOSER_ROOT_VERSION=dev-b-7.0.x php \
docker-compose exec -T -w /var/www/$INSTALL_DIR -e COMPOSER_ROOT_VERSION=dev-b-7.1.x-odmw-phpunit10-OXDEV-7518 php \
composer install --no-interaction
- name: Install Shop
Expand All @@ -63,7 +63,7 @@ jobs:
- name: Run tests
run: |
docker-compose exec -T -e ACTIONS_RUNNER_DEBUG=true -w /var/www/$INSTALL_DIR php \
php vendor/bin/phpunit --testdox --debug -v --bootstrap /var/www/$INSTALL_DIR/source/bootstrap.php tests/
php vendor/bin/phpunit --bootstrap /var/www/$INSTALL_DIR/source/bootstrap.php tests/
- name: Stop containers
run: |
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log for OXID eShop doctrine migration integration

## v5.1.0 - unreleased

### Added
- PHPUnit v10 support

### Removed
- PHPUnit v9 support

## v5.1.0 - 2023-04-20

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"require-dev": {
"ext-pdo": "*",
"mikey179/vfsstream": "^1.6",
"oxid-esales/oxideshop-ce": "^7.0.0",
"oxid-esales/oxideshop-ce": "dev-b-7.1.x-phpunit10-OXDEV-7513",
"phpspec/prophecy-phpunit": "^v2.0",
"phpunit/phpunit": "^9",
"phpunit/phpunit": "^10.4",
"symfony/filesystem": "*",
"symfony/yaml": "*"
},
Expand Down
2 changes: 2 additions & 0 deletions tests/Integration/MigrationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function testMigrateSuccess(): void
$this->removeMigrationFixturesFromShop();
$this->undoMigrationChangesInDatabase();
}

public function testExecuteWithMigrationsGenerateWillAddSuiteInfoToOutput(): void
{
$suiteCode = 'CE';
Expand All @@ -80,6 +81,7 @@ public function testExecuteWithMigrationsGenerateWillAddSuiteInfoToOutput(): voi

$this->assertStringContainsString($suiteCode, $output->getWriteLnContents());
}

private function copyMigrationFixturesToShop(): void
{
$shopSource = (new Facts())->getSourcePath();
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/MigrationArgumentParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

final class MigrationArgumentParserTest extends TestCase
{
public function provideArgumentData(): array
public static function provideArgumentData(): array
{
return [
[
Expand Down
80 changes: 20 additions & 60 deletions tests/Unit/MigrationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ final class MigrationsTest extends TestCase
{
use ProphecyTrait;

/**
* Check if Doctrine Application mock is called
* when migrations are available.
*/
public function testCallsDoctrineMigrations(): void
{
$doctrineApplication = $this->getDoctrineMock(true);
Expand All @@ -52,10 +48,6 @@ public function testCallsDoctrineMigrations(): void
$this->assertSame(0, $migrations->execute('migrations:migrate'));
}

/**
* Check if Doctrine Application mock is called with right parameters
* when migrations are available.
*/
public function testExecuteCEMigration(): void
{
$command = 'migrations:migrate';
Expand Down Expand Up @@ -87,10 +79,6 @@ public function testExecuteCEMigration(): void
$migrations->execute($command);
}

/**
* Tests that all migrations are called what's defined in a Shop facts
* with an order from Facts.
*/
public function testExecuteAllMigrations(): void
{
$command = 'migrations:migrate';
Expand Down Expand Up @@ -126,11 +114,23 @@ public function testExecuteAllMigrations(): void
]);

$doctrineApplication = $this->createPartialMock(Application::class, ['run', 'get']);
$doctrineApplication->expects($this->exactly(3))->method('run')->withConsecutive(
[$inputCE, null],
[$inputPE, null],
[$inputEE, null]
);

$doctrineApplication
->expects($this->exactly(3))
->method('run')
->with(
$this->callback(function ($argument) use ($inputCE, $inputPE, $inputEE) {
static $count = 0;
$count++;
return match ($count) {
1 => $argument == $inputCE,
2 => $argument == $inputPE,
3 => $argument == $inputEE,
default => false,
};
})
);

$doctrineApplication->method('get')
->willReturn($this->createMock(Command::class));

Expand All @@ -150,10 +150,6 @@ public function testExecuteAllMigrations(): void
$migrations->execute($command);
}

/**
* Tests that only requested migration is called even when more migrations exist.
* Does testing by calling migration in different case sensitivity.
*/
public function testExecuteOnlyRequestedMigration(): void
{
$command = 'migrations:migrate';
Expand Down Expand Up @@ -191,9 +187,6 @@ public function testExecuteOnlyRequestedMigration(): void
$migrations->execute($command, 'Ee');
}

/**
* Tests that no error appears when no migrations exist for requested edition.
*/
public function testNoErrorWhenNoMigrationExistForRequestedEdition(): void
{
$command = 'migrations:migrate';
Expand Down Expand Up @@ -223,10 +216,6 @@ public function testNoErrorWhenNoMigrationExistForRequestedEdition(): void
$migrations->execute($command, 'PR');
}

/**
* Check if Doctrine Application mock is NOT called
* when migrations are NOT available.
*/
public function testSkipMigrationWhenItDoesNotExist(): void
{
$command = 'migrations:migrate';
Expand All @@ -251,9 +240,6 @@ public function testSkipMigrationWhenItDoesNotExist(): void
$migrations->execute($command);
}

/**
* Check if migrations availability checker is called with a right parameter.
*/
public function testMigrationAvailabilityCheckerCalledWithCorrectPath(): void
{
$command = 'migrations:migrate';
Expand Down Expand Up @@ -284,9 +270,6 @@ public function testMigrationAvailabilityCheckerCalledWithCorrectPath(): void
$migrations->execute($command);
}

/**
* Check if generates new migration when no migration exist in a folder.
*/
public function testRunGenerateMigrationCommandEvenIfNoMigrationExist(): void
{
$command = 'migrations:generate';
Expand All @@ -311,9 +294,6 @@ public function testRunGenerateMigrationCommandEvenIfNoMigrationExist(): void
$migrations->execute($command);
}

/**
* Test to check if error code is passed from Doctrine to upper caller.
*/
public function testReturnErrorCodeWhenMigrationFail(): void
{
$errorCode = 1;
Expand Down Expand Up @@ -478,7 +458,7 @@ public function testExecuteWithMissingMigrationClassWillRethrowMentioningSuiteIn
->execute($command);
}

public function badFlagsDataProvider(): array
public static function badFlagsDataProvider(): array
{
return [
[
Expand All @@ -492,11 +472,7 @@ public function badFlagsDataProvider(): array
];
}

/**
* @param $runsAtLeastOnce
* @param null $callWith
* @return MockObject|Application
*/

private function getDoctrineMock($runsAtLeastOnce, $callWith = null): MockObject
{
$doctrineApplication = $this->createPartialMock(Application::class, ['run', 'get']);
Expand All @@ -516,10 +492,6 @@ private function getDoctrineMock($runsAtLeastOnce, $callWith = null): MockObject
return $doctrineApplication;
}

/**
* @param int $result
* @return MockObject|Application
*/
private function getDoctrineStub($result = null): MockObject
{
$doctrineApplication = $this->createPartialMock(Application::class, ['run', 'get']);
Expand All @@ -530,10 +502,6 @@ private function getDoctrineStub($result = null): MockObject
return $doctrineApplication;
}

/**
* @param $doctrineApplication
* @return MockObject|DoctrineApplicationBuilder
*/
private function getDoctrineApplicationBuilderStub($doctrineApplication): MockObject
{
$doctrineApplicationBuilder = $this->createPartialMock(DoctrineApplicationBuilder::class, ['build']);
Expand All @@ -542,14 +510,10 @@ private function getDoctrineApplicationBuilderStub($doctrineApplication): MockOb
return $doctrineApplicationBuilder;
}

/**
* @param $migrationPaths
* @return MockObject|Facts
*/
private function getMigrationsPathProviderStub($migrationPaths): MockObject
{
$migrationsPathProvider = $this->getMockBuilder(MigrationsPathProvider::class)
->setMethods(['getMigrationsPath'])
->onlyMethods(['getMigrationsPath'])
->setConstructorArgs([new Facts()])
->getMock();

Expand All @@ -558,10 +522,6 @@ private function getMigrationsPathProviderStub($migrationPaths): MockObject
return $migrationsPathProvider;
}

/**
* @param $ifMigrationsAvailable
* @return MockObject
*/
private function getMigrationAvailabilityStub($ifMigrationsAvailable): MockObject
{
$migrationAvailabilityChecker = $this->createPartialMock(
Expand Down

0 comments on commit a914c98

Please sign in to comment.