YamlParserTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Tests\Unit\Service\Utils\Parser;
  3. use App\Service\Utils\Parser\YamlParser;
  4. use PHPUnit\Framework\TestCase;
  5. class YamlParserTest extends TestCase
  6. {
  7. public const FIXTURES = __DIR__.'/fixtures';
  8. /**
  9. * @see YamlParser::yamlParser()
  10. */
  11. public function testParse():void
  12. {
  13. $parser = new YamlParser();
  14. $parsingArray = $parser->parse("
  15. opentalent:
  16. modulesbyconditions:
  17. CotisationCall:
  18. roles:
  19. - ROLE_COTISATION
  20. conditions:
  21. service:
  22. name: opentalent.cotisation.utils
  23. function: isLastParentAndCMF");
  24. $this->assertIsArray($parsingArray);
  25. $this->assertIsArray($parsingArray['opentalent']);
  26. $this->assertEquals('ROLE_COTISATION', $parsingArray['opentalent']['modulesbyconditions']['CotisationCall']['roles'][0]);
  27. }
  28. /**
  29. * @see YamlParser::yamlParser()
  30. */
  31. public function testParseFile():void
  32. {
  33. $parser = new YamlParser();
  34. $parsingArray = $parser->parseFile(self::FIXTURES . '/fixture.yaml');
  35. $this->assertIsArray($parsingArray);
  36. $this->assertIsArray($parsingArray['opentalent']);
  37. $this->assertEquals('ROLE_COTISATION', $parsingArray['opentalent']['modulesbyconditions']['CotisationCall']['roles'][0]);
  38. }
  39. }