summaryrefslogtreecommitdiffstats
path: root/Tests/TranslationSyncStatusTest.php
blob: 4b72d41d5a5e1a37246bd74df4d41b8710d0209f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Security\Tests;

use Symfony\Component\Finder\Finder;

class TranslationSyncStatusTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider getTranslationDirectoriesData
     */
    public function testTranslationFileIsNotMissingInCore($dir1, $dir2)
    {
        $finder = new Finder();
        $files = $finder->in($dir1)->files();

        foreach ($files as $file) {
            $this->assertFileExists($dir2.'/'.$file->getFilename(), 'Missing file '.$file->getFilename().' in directory '.$dir2);
        }
    }

    public function getTranslationDirectoriesData()
    {
        $legacyTranslationsDir = $this->getLegacyTranslationsDirectory();
        $coreTranslationsDir = $this->getCoreTranslationsDirectory();

        return array(
            'file-not-missing-in-core' => array($legacyTranslationsDir, $coreTranslationsDir),
            'file-not-added-in-core' => array($coreTranslationsDir, $legacyTranslationsDir),
        );
    }

    public function testFileContentsAreEqual()
    {
        $finder = new Finder();
        $files = $finder->in($this->getLegacyTranslationsDirectory())->files();

        foreach ($files as $file) {
            $coreFile = $this->getCoreTranslationsDirectory().'/'.$file->getFilename();

            $this->assertFileEquals($file->getRealPath(), $coreFile, $file.' and '.$coreFile.' have equal content.');
        }
    }

    private function getLegacyTranslationsDirectory()
    {
        return __DIR__.'/../Resources/translations';
    }

    private function getCoreTranslationsDirectory()
    {
        return __DIR__.'/../Core/Resources/translations';
    }
}