getCreationTimestamp example

$this->ids = new IdsCollection([
            'id' => Uuid::randomHex(),
            'referenced_id' => Uuid::randomHex(),
            'referenced_version_id' => Uuid::randomHex(),
            'empty_id' => '00000000000000000000000000000000',
        ]);
    }

    public function testGetCreationTimestamp(): void
    {
        static::assertEquals('1673426317', $this->migration->getCreationTimestamp());
    }

    public function testUpdate(): void
    {
        $this->migration->update($this->connection);

        static::assertStringContainsString('`referenced_id` binary(16)', $this->getSchema());
        static::assertStringContainsString('`referenced_version_id` binary(16)', $this->getSchema());
    }

    public function testUpdateTwice(): void
    {

class Migration1692254551FixMailTranslationTest extends TestCase
{
    use MigrationTestTrait;

    public function testCreationTimestamp(): void
    {
        $migration = new Migration1692254551FixMailTranslation();
        static::assertSame(1692254551, $migration->getCreationTimestamp());
    }

    public function testMailTemplatesUpdated(): void
    {
        $connection = KernelLifecycleManager::getConnection();

        $migration = new Migration1692254551FixMailTranslation();
        $migration->update($connection);

        $deLangId = $this->fetchLanguageId($connection, 'de-DE');
        $enLandId = $this->fetchLanguageId($connection, 'en-GB');
        
foreach ($migrationCollections as $migrations) {
            foreach ($migrations->getMigrationSteps() as $className => $migration) {
                $matches = [];
                $result = preg_match('/\\\\(?<name>Migration(?<timestamp>\d+)\w+)$/', (string) $className$matches);

                static::assertEquals(1, $resultsprintf(
                    'Invalid migration name "%s". Example for a valid format: Migration1536232684Order',
                    $className
                ));

                $timestamp = (int) $matches['timestamp'];
                static::assertEquals($migration->getCreationTimestamp()$timestampsprintf(
                    'Timestamp in migration name "%s" does not match timestamp of method "getCreationTimestamp"',
                    $className
                ));
            }
        }
    }
}
protected function setUp(): void
    {
        Feature::skipTestIfInActive('v6.6.0.0', $this);

        $this->migration = new Migration1673964565MigrateToReferencedColumns();
        $this->connection = KernelLifecycleManager::getConnection();
    }

    public function testGetCreationTimestamp(): void
    {
        static::assertEquals('1673964565', $this->migration->getCreationTimestamp());
    }

    public function testUpdate(): void
    {
        $this->migration->update($this->connection);

        static::assertStringContainsString('`referenced_id` binary(16) NOT NULL', $this->getSchema());
        static::assertStringContainsString('`referenced_version_id` binary(16) NOT NULL', $this->getSchema());
        static::assertStringNotContainsString('`entity_id`', $this->getSchema());
    }

    
return $this->migrationSteps ?? [];
    }

    /** * @return list<int> */
    public function getActiveMigrationTimestamps(): array
    {
        $activeMigrations = [];

        foreach ($this->getMigrationSteps() as $migration) {
            $activeMigrations[] = $migration->getCreationTimestamp();
        }

        return $activeMigrations;
    }

    /** * @param class-string<MigrationStep> $className * * @return array{class: class-string<MigrationStep>, creation_timestamp: int, update?: string, update_destructive?: string, message?: string} */
    private function getMigrationData(string $className, MigrationStep $migrationStep): array
    {

class Migration1662533751AddCustomEntityTypeIdToCategoryTest extends TestCase
{
    public function testGetCreationTimestamp(): void
    {
        $expectedTimestamp = 1662533751;
        $migration = new Migration1662533751AddCustomEntityTypeIdToCategory();

        static::assertEquals($expectedTimestamp$migration->getCreationTimestamp());
    }

    public function testMultipleExecutions(): void
    {
        $connection = KernelLifecycleManager::getConnection();
        $migration = new Migration1662533751AddCustomEntityTypeIdToCategory();

        $migration->update($connection);
        $migration->update($connection);

        static::assertTrue(EntityDefinitionQueryHelper::columnExists($connection, 'category', 'custom_entity_type_id'));
    }

        if (Feature::isActive('v6.6.0.0')) {
            static::markTestSkipped('This test is not compatible with v6.6.0.0. Re-enable when migration refactoring is complete or remove the unit test with next major.');
        }

        $this->connection = KernelLifecycleManager::getConnection();
    }

    public function testGetCreationTimestamp(): void
    {
        $migration = new Migration1673946817FixMediaFolderAssociationFields();
        static::assertEquals('1673946817', $migration->getCreationTimestamp());
    }

    public function testFieldsAreMigrated(): void
    {
        $migration = new Migration1673946817FixMediaFolderAssociationFields();
        $migration->update($this->connection);

        $fields = $this->connection->fetchOne('SELECT association_fields FROM media_default_folder WHERE entity = :user', ['user' => 'user']);

        static::assertJson($fields);
        $fields = \json_decode($fields, true);

        
$migrationsObjects = [];
        foreach ($migrations as $migration) {
            $migrationsObjects[] = new $migration['class']();
        }

        static::assertCount(2, $migrationsObjects);
        static::assertNull($migrations[0]['update']);
        static::assertNull($migrations[0]['update_destructive']);
        static::assertNull($migrations[0]['message']);
        static::assertNotNull($migrations[0]['class']);
        static::assertNotNull($migrations[0]['creation_timestamp']);
        static::assertEquals(1, $migrationsObjects[0]->getCreationTimestamp());
        static::assertEquals(2, $migrationsObjects[1]->getCreationTimestamp());
    }

    public function testItGetsCorrectMigrationTimestamps(): void
    {
        $collection = $this->loader->collect('_test_migrations_valid');
        $migrations = $collection->getActiveMigrationTimestamps();

        static::assertCount(2, $migrations);
        static::assertEquals(1, $migrations[0]);
        static::assertEquals(2, $migrations[1]);
    }
protected function tearDown(): void
    {
        $profile = $this->fetchProfile();
        if (!$profile) {
            $this->createProfile();
        }
    }

    public function testTimestampIsCorrect(): void
    {
        $migration = new Migration1676272001AddAccountTypeToCustomerProfileImportExport();
        static::assertEquals('1676272001', $migration->getCreationTimestamp());
    }

    public function testPreventUpdateIfProfileNotExists(): void
    {
        $this->prepare();

        $this->connection->executeQuery(
            'DELETE FROM `import_export_profile` WHERE `source_entity` =:source_entity and `name` = :name AND `system_default` = 1',
            [
                'source_entity' => CustomerDefinition::ENTITY_NAME,
                'name' => 'Default customer',
            ]
$templateTypeId = $this->connection->fetchOne('SELECT HEX(id) FROM mail_template_type WHERE technical_name = :name', ['name' => Migration1688106315AddMissingTransactionMailTemplates::UNCONFIRMED_TYPE]);

        if (\is_string($templateTypeId)) {
            $this->connection->executeStatement('DELETE FROM `mail_template` WHERE `mail_template_type_id` = :id', ['id' => $templateTypeId]);
            $this->connection->executeStatement('DELETE FROM `mail_template_type` WHERE `id` = :id', ['id' => $templateTypeId]);
        }
    }

    public function testCreationTimestamp(): void
    {
        $migration = new Migration1690874168FixPaymentStatusUnconfirmedMail();
        static::assertSame(1690874168, $migration->getCreationTimestamp());
    }

    public function testMigration(): void
    {
        $migration = new Migration1690874168FixPaymentStatusUnconfirmedMail();
        $migration->update($this->connection);
        $migration->update($this->connection);
        $this->assertMailTemplate();
    }

    public function assertMailTemplate(): void
    {


    protected function tearDown(): void
    {
        $this->connection->executeStatement('DELETE FROM `customer_address`');
        $this->connection->executeStatement('DELETE FROM `customer`');
    }

    public function testTimestampIsCorrect(): void
    {
        $migration = new Migration1676272000AddAccountTypeToCustomer();
        static::assertEquals('1676272000', $migration->getCreationTimestamp());
    }

    public function testAddAccountType(): void
    {
        $this->dropAccountType();

        $migration = new Migration1676272000AddAccountTypeToCustomer();
        $migration->update($this->connection);

        static::assertTrue(EntityDefinitionQueryHelper::columnExists($this->connection, 'customer', 'account_type'));
    }

    
Home | Imprint | This part of the site doesn't use cookies.