Exemplo n.º 1
0
 /**
  * Tests rebuild the theme data with theme parents.
  */
 public function testRebuildThemeDataWithThemeParents()
 {
     $this->extensionDiscovery->expects($this->at(0))->method('scan')->with('theme')->will($this->returnValue(array('test_subtheme' => new Extension($this->root, 'theme', $this->root . '/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml', 'test_subtheme.info.yml'), 'test_basetheme' => new Extension($this->root, 'theme', $this->root . '/core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml', 'test_basetheme.info.yml'))));
     $this->extensionDiscovery->expects($this->at(1))->method('scan')->with('theme_engine')->will($this->returnValue(array('twig' => new Extension($this->root, 'theme_engine', $this->root . '/core/themes/engines/twig/twig.info.yml', 'twig.engine'))));
     $this->infoParser->expects($this->at(0))->method('parse')->with($this->root . '/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml')->will($this->returnCallback(function ($file) {
         $info_parser = new InfoParser();
         return $info_parser->parse($file);
     }));
     $this->infoParser->expects($this->at(1))->method('parse')->with($this->root . '/core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml')->will($this->returnCallback(function ($file) {
         $info_parser = new InfoParser();
         return $info_parser->parse($file);
     }));
     $this->moduleHandler->expects($this->once())->method('buildModuleDependencies')->will($this->returnArgument(0));
     $theme_data = $this->themeHandler->rebuildThemeData();
     $this->assertCount(2, $theme_data);
     $info_basetheme = $theme_data['test_basetheme'];
     $info_subtheme = $theme_data['test_subtheme'];
     // Ensure some basic properties.
     $this->assertInstanceOf('Drupal\\Core\\Extension\\Extension', $info_basetheme);
     $this->assertEquals('test_basetheme', $info_basetheme->getName());
     $this->assertInstanceOf('Drupal\\Core\\Extension\\Extension', $info_subtheme);
     $this->assertEquals('test_subtheme', $info_subtheme->getName());
     // Test the parent/child-theme properties.
     $info_subtheme->info['base theme'] = 'test_basetheme';
     $info_basetheme->sub_themes = array('test_subtheme');
     $this->assertEquals($this->root . '/core/themes/engines/twig/twig.engine', $info_basetheme->owner);
     $this->assertEquals('twig', $info_basetheme->prefix);
     $this->assertEquals($this->root . '/core/themes/engines/twig/twig.engine', $info_subtheme->owner);
     $this->assertEquals('twig', $info_subtheme->prefix);
 }