LanguagesCoverageTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of the Carbon package.
  5. *
  6. * (c) Brian Nesbitt <brian@nesbot.com>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Tests\Localization;
  12. use Tests\AbstractTestCase;
  13. class LanguagesCoverageTest extends AbstractTestCase
  14. {
  15. public function testAllLanguagesAreTested()
  16. {
  17. $languages = glob(__DIR__.'/../../src/Carbon/Lang/*.php');
  18. $tests = array_map(function ($file) {
  19. return strtolower(substr(basename($file), 0, -8));
  20. }, glob(__DIR__.'/*Test.php'));
  21. $tester = $this;
  22. $missingLanguages = array_filter($languages, function ($language) use ($tester, $tests) {
  23. $file = basename($language);
  24. $covered = \in_array(
  25. str_replace(['_', '-', '@'], '', strtolower(substr($file, 0, -4))),
  26. $tests,
  27. true
  28. );
  29. $tester->assertTrue($covered, "Expect $file language file to be covered.");
  30. return !$covered;
  31. });
  32. $this->assertCount(0, $missingLanguages, 'Expect to have 0 languages uncovered.');
  33. }
  34. }