This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
drupalcampbristol/vendor/drupal/console/Test/Generator/ControllerGeneratorTest.php
2018-11-23 12:29:20 +00:00

69 lines
1.8 KiB
PHP

<?php
/**
* @file
* Contains Drupal\Console\Test\Generator\ControllerGeneratorTest.
*/
namespace Drupal\Console\Test\Generator;
use Drupal\Console\Generator\ControllerGenerator;
use Drupal\Console\Test\DataProvider\ControllerDataProviderTrait;
class ControllerGeneratorTest extends GeneratorTest
{
use ControllerDataProviderTrait;
/**
* Controller generator test
*
* @param $module
* @param $class_name
* @param $routes
* @param $test
* @param $build_services
* @param $class_machine_name
*
* @dataProvider commandData
*/
public function testGenerateController(
$module,
$class_name,
$routes,
$test,
$build_services
) {
$generator = new ControllerGenerator();
$this->getRenderHelper()->setSkeletonDirs($this->getSkeletonDirs());
$this->getRenderHelper()->setTranslator($this->getTranslatorHelper());
$generator->setHelperSet($this->getHelperSet());
$generator->generate(
$module,
$class_name,
$routes,
$test,
$build_services
);
$files = [
$generator->getSite()->getControllerPath($module).'/'.$class_name.'.php',
$generator->getSite()->getModulePath($module).'/'.$module.'.routing.yml'
];
foreach ($files as $file) {
$this->assertTrue(
file_exists($file),
sprintf('%s does not exist', $file)
);
}
if ($test) {
$this->assertTrue(
file_exists($generator->getSite()->getTestPath($module, 'Controller') . '/' . $class_name.'Test.php'),
sprintf('%s does not exist', $class_name.'Test.php')
);
}
}
}