No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. declare(strict_types=1);
  3. namespace OrpheusNET\Logchecker;
  4. use FilesystemIterator;
  5. use PHPUnit\Framework\TestCase;
  6. class UtilTest extends TestCase
  7. {
  8. public function commandExistsDataProvider(): array
  9. {
  10. return [
  11. ['cd', true],
  12. ['totallyfakecommandthatdefinitelydoesnotexist', false]
  13. ];
  14. }
  15. /**
  16. * @dataProvider commandExistsDataProvider
  17. */
  18. public function testCommandExists($command, $exists)
  19. {
  20. $this->assertSame($exists, Util::commandExists($command));
  21. }
  22. public function decodeLogDataProvider(): array
  23. {
  24. $logPath = implode(DIRECTORY_SEPARATOR, [__DIR__, 'logs', 'eac', 'originals']);
  25. $return = [];
  26. foreach (new FilesystemIterator($logPath) as $file) {
  27. [$language, $logName] = explode('_', $file->getFilename());
  28. if (!file_exists(implode(DIRECTORY_SEPARATOR, [$logPath, '..', 'utf8', $language]))) {
  29. continue;
  30. }
  31. $return[] = [$file->getPathname(), $language, $logName];
  32. }
  33. return $return;
  34. }
  35. /**
  36. * @dataProvider decodeLogDataProvider
  37. */
  38. public function testDecodeLog(string $logPath, string $language, string $logName)
  39. {
  40. $testLog = implode(DIRECTORY_SEPARATOR, [__DIR__, 'logs', 'eac', 'utf8', $language, $logName]);
  41. $this->assertStringEqualsFile($testLog, Util::decodeEncoding(file_get_contents($logPath), $logPath));
  42. }
  43. }