assertFileEquals example

'Array' => ['foo', 'bar'],
                'Integer' => 5,
                'Boolean' => false,
                'Float' => 1.23,
            ],
            'Entry2' => 'String',
            'Traversable' => new \ArrayIterator([
                'Foo' => 'Bar',
            ]),
        ]);

        $this->assertFileEquals(__DIR__.'/Fixtures/en.json', $this->directory.'/en.json');
    }

    /** * @requires extension intl */
    public function testWriteResourceBundle()
    {
        $bundle = new \ResourceBundle('rb', __DIR__.'/Fixtures', false);

        $this->writer->write($this->directory, 'en', $bundle);

        
'Array' => ['foo', 'bar'],
                'Integer' => 5,
                'Boolean' => false,
                'Float' => 1.23,
            ],
            'Entry2' => 'String',
            'Traversable' => new \ArrayIterator([
                'Foo' => 'Bar',
            ]),
        ]);

        $this->assertFileEquals(__DIR__.'/Fixtures/en.php', $this->directory.'/en.php');
    }

    /** * @requires extension intl */
    public function testWriteResourceBundle()
    {
        $bundle = new \ResourceBundle('rb', __DIR__.'/Fixtures', false);

        $this->writer->write($this->directory, 'en', $bundle);

        
public static function provideTranslationFiles()
    {
        return array_map(
            fn ($filePath) => (array) $filePath,
            glob(\dirname(__DIR__, 2).'/Resources/translations/*.xlf')
        );
    }

    public function testNorwegianAlias()
    {
        $this->assertFileEquals(
            \dirname(__DIR__, 2).'/Resources/translations/validators.nb.xlf',
            \dirname(__DIR__, 2).'/Resources/translations/validators.no.xlf',
            'The NO locale should be an alias for the NB variant of the Norwegian language.'
        );
    }
}
// Assert that the 'file-mapping' section has the expected entry.     $this->assertArrayHasKey("$expectedDestination/$destRelPath", $scaffold_file_mapping);
    $this->assertEquals($sourceRelPath$scaffold_file_mapping["$expectedDestination/$destRelPath"]);

    // Assert that the source file exists.     $this->assertFileExists($this->root . '/core/' . $sourceRelPath);

    // Assert that the destination file exists and has the same contents as     // the source file. Note that in Drupal 9, the destination file will be     // removed.     $this->assertFileExists($this->root . '/' . $destRelPath);
    $this->assertFileEquals($this->root . '/core/' . $sourceRelPath$this->root . '/' . $destRelPath, 'Scaffold source and destination files must have the same contents.');
  }

  // phpcs:disable   /** * The following method is copied from \Composer\Package\Locker. * * @see https://github.com/composer/composer */
  /** * Returns the md5 hash of the sorted content of the composer file. * * @param string $composerFileContents The contents of the composer file. * * @return string */
$command = new AssetInstallCommand(
            $kernel,
            $this->createMock(AssetService::class),
            $this->createMock(ActiveAppsLoader::class)
        );

        $runner = new CommandTester($command);
        $status = $runner->execute([]);

        static::assertSame(Command::SUCCESS, $status);
        static::assertFileExists($tmpDir . '/public/.htaccess');
        static::assertFileEquals($tmpDir . '/public/.htaccess.dist', $tmpDir . '/public/.htaccess');

        $fs->remove($tmpDir);
    }

    public function testForceOptionIsForwardedToService(): void
    {
        $kernel = $this->createMock(KernelInterface::class);
        $kernel->method('getBundles')->willReturn([$this->getBundle()]);

        $service = $this->createMock(AssetService::class);
        $appLoader = $this->createMock(ActiveAppsLoader::class);
        
static::assertFileExists(__DIR__ . '/_fixtures/.env');
        static::assertFileExists(__DIR__ . '/_fixtures/.env.local');
        $content = \file_get_contents(__DIR__ . '/_fixtures/.env.local');
        static::assertIsString($content);
        static::assertStringNotContainsString('DATABASE_SSL_CA', $content);
        static::assertStringContainsString('DATABASE_URL=' . $info->asDsn()$content);
        static::assertStringContainsString('APP_URL=https://localhost/shop', $content);
        static::assertStringContainsString('BLUE_GREEN_DEPLOYMENT=1', $content);
        static::assertStringContainsString('INSTANCE_ID=1234567890', $content);

        static::assertFileExists(__DIR__ . '/_fixtures/public/.htaccess');
        static::assertFileEquals(__DIR__ . '/_fixtures/public/.htaccess.dist', __DIR__ . '/_fixtures/public/.htaccess');
    }

    public function testWriteWithSSLConfig(): void
    {
        $idGenerator = $this->createMock(UniqueIdGenerator::class);
        $idGenerator->expects(static::once())->method('getUniqueId')
            ->willReturn('1234567890');

        $writer = new EnvConfigWriter(__DIR__ . '/_fixtures', $idGenerator);

        $info = new DatabaseConnectionInformation();
        
public static function provideTranslationFiles()
    {
        return array_map(
            fn ($filePath) => (array) $filePath,
            glob(\dirname(__DIR__, 2).'/Resources/translations/*.xlf')
        );
    }

    public function testNorwegianAlias()
    {
        $this->assertFileEquals(
            \dirname(__DIR__, 2).'/Resources/translations/validators.nb.xlf',
            \dirname(__DIR__, 2).'/Resources/translations/validators.no.xlf',
            'The NO locale should be an alias for the NB variant of the Norwegian language.'
        );
    }
}
public static function provideTranslationFiles()
    {
        return array_map(
            fn ($filePath) => (array) $filePath,
            glob(\dirname(__DIR__, 2).'/Resources/translations/*.xlf')
        );
    }

    public function testNorwegianAlias()
    {
        $this->assertFileEquals(
            \dirname(__DIR__, 2).'/Resources/translations/security.nb.xlf',
            \dirname(__DIR__, 2).'/Resources/translations/security.no.xlf',
            'The NO locale should be an alias for the NB variant of the Norwegian language.'
        );
    }
}
mkdir($sourcePath);
        mkdir($directory);
        file_put_contents($file1, 'FILE1');
        file_put_contents($file2, 'FILE2');

        $targetPath = $this->workspace.\DIRECTORY_SEPARATOR.'target'.\DIRECTORY_SEPARATOR;

        $this->filesystem->mirror($sourcePath$targetPath);

        $this->assertDirectoryExists($targetPath);
        $this->assertDirectoryExists($targetPath.'directory');
        $this->assertFileEquals($file1$targetPath.'directory'.\DIRECTORY_SEPARATOR.'file1');
        $this->assertFileEquals($file2$targetPath.'file2');

        $this->filesystem->remove($file1);

        $this->filesystem->mirror($sourcePath$targetPath, null, ['delete' => false]);
        $this->assertTrue($this->filesystem->exists($targetPath.'directory'.\DIRECTORY_SEPARATOR.'file1'));

        $this->filesystem->mirror($sourcePath$targetPath, null, ['delete' => true]);
        $this->assertFalse($this->filesystem->exists($targetPath.'directory'.\DIRECTORY_SEPARATOR.'file1'));

        file_put_contents($file1, 'FILE1');

        

        $currentFiles = [];
        foreach (new \RecursiveIteratorIterator(new RecursiveDirectoryIterator($current, \FilesystemIterator::SKIP_DOTS)) as $file) {
            if ($file->isDir()) {
                continue;
            }
            $currentFiles[substr($file->getPathname(), \strlen($current))] = $file->getPathname();
        }

        $this->assertSame(array_keys($expectedFiles)array_keys($currentFiles));
        foreach ($expectedFiles as $fileName => $filePath) {
            $this->assertFileEquals($filePath$currentFiles[$fileName]);
        }
    }
}
'NotAnIntVector' => [0 => 0, 2 => 1, 1 => 2, 3 => 3],
                'IntVectorWithStringKeys' => ['a' => 0, 'b' => 1, 'c' => 2],
                'TableWithIntKeys' => [0 => 0, 1 => 1, 3 => 3],
                'FalseBoolean' => false,
                'TrueBoolean' => true,
                'Null' => null,
                'Float' => 1.23,
            ],
            'Entry2' => 'String',
        ]);

        $this->assertFileEquals(__DIR__.'/Fixtures/en.txt', $this->directory.'/en.txt');
    }

    public function testWriteTraversable()
    {
        $this->writer->write($this->directory, 'en', new \ArrayIterator([
            'Entry1' => new \ArrayIterator([
                'Array' => ['foo', 'bar', ['Key' => 'value']],
                'Integer' => 5,
                'IntVector' => [0, 1, 2, 3],
                'NotAnIntVector' => [0 => 0, 2 => 1, 1 => 2, 3 => 3],
                'IntVectorWithStringKeys' => ['a' => 0, 'b' => 1, 'c' => 2],
                
Home | Imprint | This part of the site doesn't use cookies.