Skip to content

Commit

Permalink
Merge pull request #3 from netlogix/bugfix/fix-flow-serialization
Browse files Browse the repository at this point in the history
BUGIFX: Make properties protected to fix a serialization buf with flo…
  • Loading branch information
paxuclus committed Feb 18, 2021
2 parents 02fb619 + 7d6d8f2 commit 56830df
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Classes/Domain/Job/ExecuteMigrationJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class ExecuteMigrationJob implements JobInterface
/**
* @var string
*/
private $migrationVersion;
protected $migrationVersion;

/**
* @var string
*/
private $direction;
protected $direction;

/**
* @var AsyncMigration
Expand Down
38 changes: 37 additions & 1 deletion Tests/Unit/Domain/Job/ExecuteMigrationJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Flowpack\JobQueue\Common\Queue\Message;
use Flowpack\JobQueue\Common\Queue\QueueInterface;
use Generator;
use \InvalidArgumentException;
use InvalidArgumentException;
use Neos\Flow\Log\ThrowableStorageInterface;
use Neos\Flow\Tests\UnitTestCase;
use Netlogix\Migrations\Domain\Model\DefaultMigration;
Expand Down Expand Up @@ -193,6 +193,42 @@ public function The_label_contains_the_migration_version_and_direction(string $d
$this->assertEquals(sprintf('Run async migration "foo" (Direction %s)', strtoupper($direction)), $job->getLabel());
}

/**
* @test
*/
public function The_Job_is_serializable(): void
{
$job = new ExecuteMigrationJob('foo', 'up');
$convertedJob = unserialize(serialize($job));
self::assertInstanceOf(ExecuteMigrationJob::class, $convertedJob);
assert($convertedJob instanceof ExecuteMigrationJob);
self::assertEquals($job, $convertedJob);
}

/**
* @test
*/
public function The_Job_initializes_the_migration_after_serialization(): void
{
$job = unserialize(serialize(new ExecuteMigrationJob('foo', 'up')));
$job->injectMigrationService($this->migrationService);

$this->migrationService
->expects($this->once())
->method('getMigrationByVersion')
->with('foo')
->willReturn(new class implements AsyncMigration {
public function up(): void
{
}

public function down(): void
{
}
});
$job->initializeObject();
}

public function provideDirections(): Generator
{
yield 'UP' => ['up'];
Expand Down

0 comments on commit 56830df

Please sign in to comment.