class ParserYamlTest

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

@coversDefaultClass \Drush\Make\Parser\ParserYaml

Namespace

Drush\Tests\Make\Parser

Hierarchy

Expanded class hierarchy of ParserYamlTest

Members

Contains filters are case sensitive
Namesort ascending Modifiers Type Description
ParserYamlTest::testSupportedFile public function @covers ::supportedFile
ParserYamlTest::testParse public function @dataProvider providerParse @covers ::parse
ParserYamlTest::providerParse public function Provides YAML snippets to test the parser.

File

tests/Drush/Tests/Make/Parser/ParserYamlTest.php, line 10

View source
class ParserYamlTest extends \PHPUnit_Framework_TestCase {

  /**
   * @covers ::supportedFile
   */
  public function testSupportedFile() {
    // @todo allow stdin support for Yaml files as well.
    $this->assertFalse(ParserYaml::supportedFile('-'));
    $this->assertTrue(ParserYaml::supportedFile('/tmp/foo/bar/baz.make.yml'));
    $this->assertFalse(ParserYaml::supportedFile('./baz/foo.make'));
  }

  /**
   * @dataProvider providerParse
   * @covers ::parse
   */
  public function testParse($yaml, $expected) {
    $parsed = ParserYaml::parse($yaml);
    $this->assertSame($expected, $parsed);
  }

  /**
   * Provides YAML snippets to test the parser.
   */
  public function providerParse() {
    $yaml = <<<'YAML'
foo:
  bar:
    baz: one
YAML;
    $snippets[] = array($yaml, array('foo' => array('bar' => array('baz' => 'one'))));

    $yaml = <<<'YAML'
projects:
  drupal: ~
  views:
    version: '3.0'
YAML;

    $snippets[] = array($yaml, array('projects' => array(
      'drupal' => NULL,
      'views' => array('version' => '3.0'),
    )));

    // @todo make more tests.
    return $snippets;
  }

}