public function testSanityCommandTest() { $projectFolder = ProjectUtil::createNewProject("CommandTest", true); $app = new Application($projectFolder, 'CommandTest'); $app->add(new TestCommand()); $result = ProjectUtil::runCommand($projectFolder, 'test:testcommand', [], $app); }
public function testSanity() { $projectFolder = ProjectUtil::createNewProject('sanity', true, false); $this->assertTrue(file_exists("{$projectFolder}/bin/sanity.php")); $this->assertTrue(file_exists("{$projectFolder}/web/css/sanity.css")); $commandTester = ProjectUtil::runCommand($projectFolder, 'list', ['-V --no-ansi'], 'Sanity\\Console\\SanityApplication'); $display = preg_replace('/\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]/', '', $commandTester->getDisplay()); $this->assertTrue(stripos($display, "Sanity Command Utility version 1.0") !== false); }
public function testJSONResponse() { $appName = 'App15'; $projectFolder = ProjectUtil::createNewProject($appName, true); list($clazz, $loader) = ProjectUtil::initProjectClassLoader($projectFolder); ProjectUtil::appendOrCreateServicesConfig($projectFolder, ['custom-exception-handler' => CustomRequestExceptionHandler::class, 'controller-test-module' => ControllerTestModule::class]); $factory = new ApplicationFactory($clazz, $projectFolder); $app = $factory->create(); $output = catch_output(function () use($app) { $request = Request::create("/api/hello/world"); $app->run($request); }); $this->assertEquals('{"hello":"world"}', $output); self::$cleanup[] = $projectFolder; }
public function testRoutingExtension() { $appName = 'TwigRouting'; $projectFolder = ProjectUtil::createNewProject($appName, true); list($clazz, $loader) = ProjectUtil::initProjectClassLoader($projectFolder); ProjectUtil::appendOrCreateServicesConfig($projectFolder, ["runtime" => 'TwigRouting\\TwigRoutingRuntime', "twig-module" => TwigModule::class, 'locale-service' => LocaleService::class, TranslatorInterface::class => TranslatorFactory::class, 'test-translations' => TestTranslationProvider::class, EngineInterface::class => TwigEngineService::class]); $factory = new ApplicationFactory($clazz, $projectFolder, true); /* @var $app TestableApplication */ $app = $factory->create(); $request = Request::create("/urltest/am"); ProjectUtil::addSession($request); $output = catch_output(function () use($app, $request) { $app->run($request); }); $this->assertEquals("http://localhost/urltest/am?hello=world", $output); self::$cleanup[] = $projectFolder; }
public function testTranslationFactory() { $appName = 'TransApp1'; $projectFolder = ProjectUtil::createNewProject($appName, true); list($clazz, $loader) = ProjectUtil::initProjectClassLoader($projectFolder); ProjectUtil::appendOrCreateServicesConfig($projectFolder, ['acme-module' => [$projectFolder . '/src/Acme', 'Acme\\Acme'], 'locale-service' => LocaleService::class, TranslatorInterface::class => TranslatorFactory::class, 'test-translations' => Stubs\TestTranslationProvider::class]); $factory = new ApplicationFactory(TestableApplication::class, $projectFolder); /* @var $app TestableApplication */ $app = $factory->create(); $request = Request::create("/am"); ProjectUtil::addSession($request); $output = catch_output(function () use($app, $request) { $app->run($request); }); $translator = $app->getContainer()->get(TranslatorInterface::class); $this->assertEquals('Bari louys Blend!', $translator->trans('Good morning :name!', [':name' => 'Blend'])); self::$cleanup[] = $projectFolder; }
public static function setUpSchema() { define('BLEND_APPLICATION_NAMESPACE', 'DALTest'); self::$currentDatabase->executeScript(file_get_contents(__DIR__ . '/scripts/schema.sql')); $projectFolder = ProjectUtil::createNewProject("DALTest", !is_windows()); self::$projectFolder = $projectFolder; }
/** * @large */ public function testCustomExceptionHandler() { $appName = 'App14'; $projectFolder = ProjectUtil::createNewProject($appName, true); list($clazz, $loader) = ProjectUtil::initProjectClassLoader($projectFolder); ProjectUtil::appendOrCreateServicesConfig($projectFolder, ['custom-exception-handler' => CustomRequestExceptionHandler::class]); $factory = new ApplicationFactory($clazz, $projectFolder); $app = $factory->create(); $request = Request::create("/notexists"); $output = catch_output(function () use($app, $request) { $app->run($request); }); $this->assertEquals('Page not found /notexists', $output); self::$cleanup[] = $projectFolder; }