ParserYamlTest.php

  1. 8.0.x tests/Drush/Tests/Make/Parser/ParserYamlTest.php
  2. 7.x tests/Drush/Tests/Make/Parser/ParserYamlTest.php
  3. master tests/Drush/Tests/Make/Parser/ParserYamlTest.php

Namespace

Drush\Tests\Make\Parser

Classes

Namesort descending Description
ParserYamlTest @coversDefaultClass \Drush\Make\Parser\ParserYaml

File

tests/Drush/Tests/Make/Parser/ParserYamlTest.php
View source
  1. <?php
  2. namespace Drush\Tests\Make\Parser;
  3. use Drush\Make\Parser\ParserYaml;
  4. /**
  5. * @coversDefaultClass \Drush\Make\Parser\ParserYaml
  6. */
  7. class ParserYamlTest extends \PHPUnit_Framework_TestCase {
  8. /**
  9. * @covers ::supportedFile
  10. */
  11. public function testSupportedFile() {
  12. // @todo allow stdin support for Yaml files as well.
  13. $this->assertFalse(ParserYaml::supportedFile('-'));
  14. $this->assertTrue(ParserYaml::supportedFile('/tmp/foo/bar/baz.make.yml'));
  15. $this->assertFalse(ParserYaml::supportedFile('./baz/foo.make'));
  16. }
  17. /**
  18. * @dataProvider providerParse
  19. * @covers ::parse
  20. */
  21. public function testParse($yaml, $expected) {
  22. $parsed = ParserYaml::parse($yaml);
  23. $this->assertSame($expected, $parsed);
  24. }
  25. /**
  26. * Provides YAML snippets to test the parser.
  27. */
  28. public function providerParse() {
  29. $yaml = <<<'YAML'
  30. foo:
  31. bar:
  32. baz: one
  33. YAML;
  34. $snippets[] = array($yaml, array('foo' => array('bar' => array('baz' => 'one'))));
  35. $yaml = <<<'YAML'
  36. projects:
  37. drupal: ~
  38. views:
  39. version: '3.0'
  40. YAML;
  41. $snippets[] = array($yaml, array('projects' => array('drupal' => NULL, 'views' => array('version' => '3.0'))));
  42. // @todo make more tests.
  43. return $snippets;
  44. }
  45. }