* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Translation\Tests\Extractor; use PHPUnit\Framework\TestCase; use Symfony\Component\Translation\Extractor\PhpExtractor; use Symfony\Component\Translation\MessageCatalogue; class PhpExtractorTest extends TestCase { /** * @dataProvider resourcesProvider * * @param array|string $resource */ public function testExtraction($resource) { // Arrange $extractor = new PhpExtractor(); $extractor->setPrefix('prefix'); $catalogue = new MessageCatalogue('en'); // Act $extractor->extract($resource, $catalogue); $expectedHeredoc = << array( 'single-quoted key' => 'prefixsingle-quoted key', 'double-quoted key' => 'prefixdouble-quoted key', 'heredoc key' => 'prefixheredoc key', 'nowdoc key' => 'prefixnowdoc key', "double-quoted key with whitespace and escaped \$\n\" sequences" => "prefixdouble-quoted key with whitespace and escaped \$\n\" sequences", 'single-quoted key with whitespace and nonescaped \$\n\' sequences' => 'prefixsingle-quoted key with whitespace and nonescaped \$\n\' sequences', 'single-quoted key with "quote mark at the end"' => 'prefixsingle-quoted key with "quote mark at the end"', $expectedHeredoc => 'prefix'.$expectedHeredoc, $expectedNowdoc => 'prefix'.$expectedNowdoc, '{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples' => 'prefix{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples', ), 'not_messages' => array( 'other-domain-test-no-params-short-array' => 'prefixother-domain-test-no-params-short-array', 'other-domain-test-no-params-long-array' => 'prefixother-domain-test-no-params-long-array', 'other-domain-test-params-short-array' => 'prefixother-domain-test-params-short-array', 'other-domain-test-params-long-array' => 'prefixother-domain-test-params-long-array', 'other-domain-test-trans-choice-short-array-%count%' => 'prefixother-domain-test-trans-choice-short-array-%count%', 'other-domain-test-trans-choice-long-array-%count%' => 'prefixother-domain-test-trans-choice-long-array-%count%', 'typecast' => 'prefixtypecast', 'msg1' => 'prefixmsg1', 'msg2' => 'prefixmsg2', ), ); $actualCatalogue = $catalogue->all(); $this->assertEquals($expectedCatalogue, $actualCatalogue); } public function resourcesProvider() { $directory = __DIR__.'/../fixtures/extractor/'; $splFiles = array(); foreach (new \DirectoryIterator($directory) as $fileInfo) { if ($fileInfo->isDot()) { continue; } if ('translation.html.php' === $fileInfo->getBasename()) { $phpFile = $fileInfo->getPathname(); } $splFiles[] = $fileInfo->getFileInfo(); } return array( array($directory), array($phpFile), array(glob($directory.'*')), array($splFiles), array(new \ArrayObject(glob($directory.'*'))), array(new \ArrayObject($splFiles)), ); } } __halt_compiler();----SIGNATURE:----dD2EzfsH+pqwdN4D8dWgnqR2FUv/+1poGtRJbOSc629+I4tPPsWt9ZC0OTuZ02tQI7fREr8WReRlJopLbpJwwsOR7HvysDNfNHR7kkUTWMxfl/TH8mmCJ9eJtvfEp4po/g+bfvoYWECcGdJhCZJeBzLd2K/5/8oDtTJ3rqo9dkPJ1i6qaKCdKX1WDvKPt1m5ioBTYMVL9scJpHwRJJhU7P4AzwFGZpff3OwJYvOM8hdG+LU7WtuOCTr+1XzSWiqQ41tmh0kh3i7rpzAYMPwFfTKVwWiPsdh+U5GKseJqBwJ79bydSt1c+zFl7dk0IXsG08yDPYcb1M7aYIYmavGBI3jBi9723FO2zM8EOI498obgQvOCoz7Lxkzr/jdiYJmj/dFYGttqzQdPy8b7wJhMd8u5TFtCP3imQibF4I0HsSqG41uWLnYSGkwG/gkj51n3lOCGdx7hHknQy8ziBUDZ6V/YH1EegaoP6c7i+EA+pjfONUGee6zZ66gy+Ekyh5LJ1ulHLzz02AVErGsVkEGvpDH3nkzEe3kEmAcpmpU37NHLICm6ZLE1zY212L9ninRsUAcqJLamo80nur++isKMyxoWMvfX/+5wSaeaFVHAV3ypf+ddokYrVzTTQLUpni20utOQh6EfoYs1dEuD7ynrG8QqHRcJu3JY0BtPtylL+fw=----ATTACHMENT:----Mjc5MjIwNTY3OTYzNTQ5MiAzMjA5MDAyNjY1OTAxMDk1IDkwMzg0NDY2OTA5MzE4Mw==