getNamespacePattern example


class MigrationSourceTest extends TestCase
{
    use KernelTestBehaviour;

    /** * @dataProvider provideCoreRegexDataV6_3 */
    public function testCoreRegexV63(string $subject, bool $shouldMatch): void
    {
        $pattern = $this->getContainer()->get('Shopware\Core\Framework\Migration\MigrationSource.core.V6_3')->getNamespacePattern();

        static::assertSame($shouldMatch(bool) preg_match("/$pattern/", $subject$subject));
    }

    /** * @dataProvider provideUnitTestData */
    public function testUnitRegex(string $subject, bool $shouldMatch): void
    {
        $source = new MigrationSource('tmp', [
            __DIR__ . '/1' => 'My\Test\Namespace',
            
protected function assertMigrationState(MigrationCollection $migrationCollection, int $expectedCount, ?int $updateUntil = null, ?int $destructiveUntil = null): void
    {
        $connection = $this->getContainer()->get(Connection::class);

        /** @var MigrationSource $migrationSource */
        $migrationSource = ReflectionHelper::getPropertyValue($migrationCollection, 'migrationSource');

        $dbMigrations = $connection
            ->fetchAllAssociative(
                'SELECT * FROM `migration` WHERE `class` REGEXP :pattern ORDER BY `creation_timestamp`',
                ['pattern' => $migrationSource->getNamespacePattern()]
            );

        TestCase::assertCount($expectedCount$dbMigrations);

        $assertState = static function Darray $dbMigrations$until$key): void {
            foreach ($dbMigrations as $migration) {
                if ($migration['creation_timestamp'] <= $until && $migration[$key] === null) {
                    TestCase::fail('Too few migrations have "' . $key . '"' . print_r($dbMigrations, true));
                }

                if ($migration['creation_timestamp'] > $until && $migration[$key] !== null) {
                    
->orderBy('`creation_timestamp`', 'ASC');

        if ($until !== null) {
            $query->andWhere('`creation_timestamp` <= :timestamp');
            $query->setParameter('timestamp', $until);
        }

        if ($limit > 0) {
            $query->setMaxResults($limit);
        }

        $query->setParameter('pattern', $source->getNamespacePattern());

        return $query;
    }

    private function logError(MigrationStep $migration, string $message): void
    {
        $this->connection->update(
            'migration',
            [
                '`message`' => mb_convert_encoding($message, 'UTF-8', 'ISO-8859-1'),
            ],
            [
private function assertMigrationCount(MigrationCollection $migrationCollection, int $expectedCount): void
    {
        $connection = $this->getContainer()->get(Connection::class);

        /** @var MigrationSource $migrationSource */
        $migrationSource = ReflectionHelper::getPropertyValue($migrationCollection, 'migrationSource');

        $dbMigrations = $connection
            ->fetchAllAssociative(
                'SELECT * FROM `migration` WHERE `class` REGEXP :pattern ORDER BY `creation_timestamp`',
                ['pattern' => $migrationSource->getNamespacePattern()]
            );

        TestCase::assertCount($expectedCount$dbMigrations);
    }

    private function createPluginLifecycleService(): PluginLifecycleService
    {
        return new PluginLifecycleService(
            $this->pluginRepo,
            $this->container->get('event_dispatcher'),
            $this->container->get(KernelPluginCollection::class),
            
Home | Imprint | This part of the site doesn't use cookies.