From b85e7522975c9723b83476b153ff495e6bf88960 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Sun, 14 Mar 2021 17:35:21 +0000 Subject: [PATCH 1/2] Partial code reformat --- src/Options/OptionsAware.php | 8 +++----- src/Providers/AnnotationsProvider.php | 2 +- src/Providers/AssetsProvider.php | 2 +- src/Providers/AssetsResourceProvider.php | 2 +- src/Providers/DatabaseProvider.php | 2 +- src/Providers/DbUtilsProvider.php | 2 +- src/Providers/DispatcherProvider.php | 2 +- src/Providers/EventsManagerProvider.php | 2 +- src/Providers/FileSystemProvider.php | 2 +- src/Providers/LoggerProvider.php | 2 +- src/Providers/SessionProvider.php | 3 ++- src/Providers/SystemInfoProvider.php | 2 +- src/Providers/TagProvider.php | 2 +- src/Providers/UrlProvider.php | 14 +++++++------- src/Providers/ViewProvider.php | 6 +++--- src/Providers/VoltProvider.php | 12 ++++++------ src/Resources/AssetsResource.php | 2 +- src/Scanners/Config.php | 6 +++--- src/Utils/DbUtils.php | 4 ++-- src/Validation/Validator/Namespaces.php | 2 +- src/Web/Tools.php | 22 +++++++++++----------- 21 files changed, 50 insertions(+), 51 deletions(-) diff --git a/src/Options/OptionsAware.php b/src/Options/OptionsAware.php index bfa96766c..a84932050 100644 --- a/src/Options/OptionsAware.php +++ b/src/Options/OptionsAware.php @@ -30,11 +30,9 @@ class OptionsAware implements FactoryOptions /** * @param array $options */ - public function __construct(array $options = null) + public function __construct(array $options = []) { - if (!empty($options)) { - $this->options = $options; - } + $this->options = $options; } /** @@ -110,7 +108,7 @@ public function getOptions(): array public function getOption($key) { if (!isset($this->options[$key])) { - throw new InvalidArgumentException("Option " . $key . " has't been defined"); + throw new InvalidArgumentException("Option " . $key . " hasn't been defined"); } return $this->options[$key]; diff --git a/src/Providers/AnnotationsProvider.php b/src/Providers/AnnotationsProvider.php index 46ce02600..fcfdde90a 100644 --- a/src/Providers/AnnotationsProvider.php +++ b/src/Providers/AnnotationsProvider.php @@ -31,7 +31,7 @@ class AnnotationsProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - return new AnnotationsMemory; + return new AnnotationsMemory(); }); } } diff --git a/src/Providers/AssetsProvider.php b/src/Providers/AssetsProvider.php index 30003bdbe..61999abf5 100644 --- a/src/Providers/AssetsProvider.php +++ b/src/Providers/AssetsProvider.php @@ -31,7 +31,7 @@ class AssetsProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - return new AssetsManager; + return new AssetsManager(); }); } } diff --git a/src/Providers/AssetsResourceProvider.php b/src/Providers/AssetsResourceProvider.php index e1204b339..c31e3a8be 100644 --- a/src/Providers/AssetsResourceProvider.php +++ b/src/Providers/AssetsResourceProvider.php @@ -31,7 +31,7 @@ class AssetsResourceProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - return new AssetsResource; + return new AssetsResource(); }); } } diff --git a/src/Providers/DatabaseProvider.php b/src/Providers/DatabaseProvider.php index 0ff14899b..5ec089e16 100644 --- a/src/Providers/DatabaseProvider.php +++ b/src/Providers/DatabaseProvider.php @@ -38,7 +38,7 @@ public function register(DiInterface $di): void if ($this->getShared('config')->offsetExists('database')) { $config = $this->getShared('config')->get('database')->toArray(); } else { - $dbname = sys_get_temp_dir() . DS . 'phalcon.sqlite'; + $dbname = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'phalcon.sqlite'; $this->getShared('logger')->warning( 'Unable to initialize "db" service. Used Sqlite adapter at path: {path}', ['path' => $dbname] diff --git a/src/Providers/DbUtilsProvider.php b/src/Providers/DbUtilsProvider.php index 3665689ba..25976efb8 100644 --- a/src/Providers/DbUtilsProvider.php +++ b/src/Providers/DbUtilsProvider.php @@ -31,7 +31,7 @@ class DbUtilsProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - return new DbUtils; + return new DbUtils(); }); } } diff --git a/src/Providers/DispatcherProvider.php b/src/Providers/DispatcherProvider.php index 6da904187..533c9ed65 100644 --- a/src/Providers/DispatcherProvider.php +++ b/src/Providers/DispatcherProvider.php @@ -37,7 +37,7 @@ public function register(DiInterface $di): void $access = $di->getShared('access'); $di->setShared($this->providerName, function () use ($eventsManager, $access) { - $dispatcher = new MvcDispatcher; + $dispatcher = new MvcDispatcher(); $dispatcher->setDefaultNamespace('Phalcon\DevTools\Web\Tools\Controllers'); $eventsManager->attach('dispatch', $access, 1000); diff --git a/src/Providers/EventsManagerProvider.php b/src/Providers/EventsManagerProvider.php index 2c72d62ab..5a3f08871 100644 --- a/src/Providers/EventsManagerProvider.php +++ b/src/Providers/EventsManagerProvider.php @@ -31,7 +31,7 @@ class EventsManagerProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - $em = new EventsManager; + $em = new EventsManager(); $em->enablePriorities(true); return $em; diff --git a/src/Providers/FileSystemProvider.php b/src/Providers/FileSystemProvider.php index 962faf64f..5873abde2 100644 --- a/src/Providers/FileSystemProvider.php +++ b/src/Providers/FileSystemProvider.php @@ -31,7 +31,7 @@ class FileSystemProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - return new FsUtils; + return new FsUtils(); }); } } diff --git a/src/Providers/LoggerProvider.php b/src/Providers/LoggerProvider.php index 00b4a8708..65f3528c8 100644 --- a/src/Providers/LoggerProvider.php +++ b/src/Providers/LoggerProvider.php @@ -38,7 +38,7 @@ public function register(DiInterface $di): void $basePath = $application->getBasePath(); $di->setShared($this->providerName, function () use ($hostName, $basePath) { - $ptoolsPath = $basePath . DS . '.phalcon' . DS; + $ptoolsPath = $basePath . DIRECTORY_SEPARATOR . '.phalcon' . DIRECTORY_SEPARATOR; if (is_dir($ptoolsPath) && is_writable($ptoolsPath)) { $formatter = new LineFormatter("%date% {$hostName} php: [%type%] %message%", 'D j H:i:s'); $adapter = new FileLogger($ptoolsPath . 'devtools.log'); diff --git a/src/Providers/SessionProvider.php b/src/Providers/SessionProvider.php index 4685c034d..095ac496b 100644 --- a/src/Providers/SessionProvider.php +++ b/src/Providers/SessionProvider.php @@ -32,10 +32,11 @@ class SessionProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - $session = new Manager(); $files = new SessionStream([ 'savePath' => sys_get_temp_dir(), ]); + + $session = new Manager(); $session->setAdapter($files); $session->start(); diff --git a/src/Providers/SystemInfoProvider.php b/src/Providers/SystemInfoProvider.php index 06d9455c9..d488f7946 100644 --- a/src/Providers/SystemInfoProvider.php +++ b/src/Providers/SystemInfoProvider.php @@ -31,7 +31,7 @@ class SystemInfoProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - return new SystemInfo; + return new SystemInfo(); }); } } diff --git a/src/Providers/TagProvider.php b/src/Providers/TagProvider.php index 1f6f7b444..92ef90555 100644 --- a/src/Providers/TagProvider.php +++ b/src/Providers/TagProvider.php @@ -31,7 +31,7 @@ class TagProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - $tag = new Tag; + $tag = new Tag(); $tag->setDocType(Tag::HTML5); $tag->setTitleSeparator(' :: '); diff --git a/src/Providers/UrlProvider.php b/src/Providers/UrlProvider.php index 051c671f7..3c8ac3e62 100644 --- a/src/Providers/UrlProvider.php +++ b/src/Providers/UrlProvider.php @@ -35,23 +35,23 @@ public function register(DiInterface $di): void /** @var DiInterface $this */ $config = $this->getShared('config'); - $url = new UrlResolver; + $url = new UrlResolver(); - if ($config->get('application', new Config)->offsetExists('baseUri')) { - $baseUri = $config->get('application', new Config)->get('baseUri'); + if ($config->get('application', new Config())->offsetExists('baseUri')) { + $baseUri = $config->get('application', new Config())->get('baseUri'); } elseif ($config->offsetExists('baseUri')) { $baseUri = $config->get('baseUri'); } else { - // @todo Log notice here + // TODO: Log notice here $baseUri = '/'; } - if ($config->get('application', new Config)->offsetExists('staticUri')) { - $staticUri = $config->get('application', new Config)->get('staticUri'); + if ($config->get('application', new Config())->offsetExists('staticUri')) { + $staticUri = $config->get('application', new Config())->get('staticUri'); } elseif ($config->offsetExists('staticUri')) { $staticUri = $config->get('staticUri'); } else { - // @todo Log notice here + // TODO: Log notice here $staticUri = '/'; } diff --git a/src/Providers/ViewProvider.php b/src/Providers/ViewProvider.php index 662a3a3a9..03e74468f 100644 --- a/src/Providers/ViewProvider.php +++ b/src/Providers/ViewProvider.php @@ -44,11 +44,11 @@ public function register(DiInterface $di): void $view->registerEngines([ '.volt' => $this->getShared('volt', [$view, $this]), - '.phtml' => Php::class + '.phtml' => Php::class, ]); - $view->setViewsDir($registry->offsetGet('directories')->webToolsViews . DS) - ->setLayoutsDir('layouts' . DS) + $view->setViewsDir($registry->offsetGet('directories')->webToolsViews . DIRECTORY_SEPARATOR) + ->setLayoutsDir('layouts' . DIRECTORY_SEPARATOR) ->setRenderLevel(View::LEVEL_AFTER_TEMPLATE); $em = $this->getShared('eventsManager'); diff --git a/src/Providers/VoltProvider.php b/src/Providers/VoltProvider.php index fe77df2a9..5ce210b5b 100644 --- a/src/Providers/VoltProvider.php +++ b/src/Providers/VoltProvider.php @@ -49,7 +49,7 @@ public function register(DiInterface $di): void $config = $this->getShared('config'); $appCacheDir = $config->get('application', new Config)->get('cacheDir'); - $defaultCacheDir = sys_get_temp_dir() . DS . 'phalcon' . DS . 'volt'; + $defaultCacheDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'phalcon' . DIRECTORY_SEPARATOR . 'volt'; /** @var Config $voltConfig */ $voltConfig = null; @@ -80,8 +80,8 @@ public function register(DiInterface $di): void */ if (0 === strpos($templatePath, $basePath)) { $templatePath = substr($templatePath, strlen($basePath)); - } elseif (0 === strpos($templatePath, $ptoolsPath . DS . 'src')) { - $templatePath = substr($templatePath, strlen($ptoolsPath . DS . 'src')); + } elseif (0 === strpos($templatePath, $ptoolsPath . DIRECTORY_SEPARATOR . 'src')) { + $templatePath = substr($templatePath, strlen($ptoolsPath . DIRECTORY_SEPARATOR . 'src')); } $templatePath = trim($templatePath, '\\/'); @@ -90,7 +90,7 @@ public function register(DiInterface $di): void $cacheDir = $that->getCacheDir($voltConfig); - return rtrim($cacheDir, '\\/') . DS . $filename; + return rtrim($cacheDir, '\\/') . DIRECTORY_SEPARATOR . $filename; }; $options = [ @@ -112,11 +112,11 @@ public function register(DiInterface $di): void * * @return string */ - protected function getCacheDir(Config $voltConfig) + protected function getCacheDir(Config $voltConfig): string { $appCacheDir = $this->di->getShared('config')->path('application.cacheDir'); $cacheDir = $voltConfig->get('cacheDir', $appCacheDir); - $defaultCacheDir = sys_get_temp_dir() . DS . 'phalcon' . DS . 'volt'; + $defaultCacheDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'phalcon' . DIRECTORY_SEPARATOR . 'volt'; if ($cacheDir && is_dir($cacheDir) && is_writable($cacheDir)) { return $cacheDir; diff --git a/src/Resources/AssetsResource.php b/src/Resources/AssetsResource.php index 8d56a7224..c0ee48930 100644 --- a/src/Resources/AssetsResource.php +++ b/src/Resources/AssetsResource.php @@ -28,6 +28,6 @@ class AssetsResource extends Injectable */ public function path(string $path): string { - return PTOOLSPATH . DS . 'resources' . DS . $this->fs->normalize($path); + return PTOOLSPATH . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . $this->fs->normalize($path); } } diff --git a/src/Scanners/Config.php b/src/Scanners/Config.php index 3a8dbeba3..eefcaf0d4 100644 --- a/src/Scanners/Config.php +++ b/src/Scanners/Config.php @@ -66,14 +66,14 @@ public function __construct($basePath) * @param string $filename The config basename. * @return null|PhConfig */ - public function scan($filename): ?PhConfig + public function scan(string $filename): ?PhConfig { $config = null; $filename = pathinfo($filename, PATHINFO_FILENAME); foreach ($this->getConfigPaths() as $probablyPath) { foreach ($this->configAdapters as $ext => $adapter) { - $probablyConfig = $probablyPath . DS . "{$filename}.{$ext}"; + $probablyConfig = $probablyPath . DIRECTORY_SEPARATOR . "{$filename}.{$ext}"; if (is_file($probablyConfig) && is_readable($probablyConfig)) { if (in_array($ext, ['php', 'php5', 'inc'])) { @@ -102,7 +102,7 @@ public function scan($filename): ?PhConfig * @return PhConfig * @throws Exception */ - public function load($filename): PhConfig + public function load(string $filename): PhConfig { $config = $this->scan($filename); diff --git a/src/Utils/DbUtils.php b/src/Utils/DbUtils.php index b7d1e2fb1..f2b026f6c 100644 --- a/src/Utils/DbUtils.php +++ b/src/Utils/DbUtils.php @@ -60,11 +60,11 @@ public function resolveDbSchema(): ?string return $config->get('schema'); } - if ('Postgresql' == $config->get('adapter')) { + if ('Postgresql' === $config->get('adapter')) { return 'public'; } - if ('Sqlite' == $config->get('adapter')) { + if ('Sqlite' === $config->get('adapter')) { // SQLite only supports the current database, unless one is // attached. This is not the case, so don't return a schema. return null; diff --git a/src/Validation/Validator/Namespaces.php b/src/Validation/Validator/Namespaces.php index fcbea73eb..1feb84371 100644 --- a/src/Validation/Validator/Namespaces.php +++ b/src/Validation/Validator/Namespaces.php @@ -48,7 +48,7 @@ public function validate(Validation $validation, $field): bool $re = '#^(?:(?:\\\)?[a-z](?:[a-z0-9_]+)?)+(?:\\\\(?:[a-z](?:[a-z0-9_]+)?)+)*$#i'; - if (false === (bool)preg_match($re, $value)) { + if (!preg_match($re, $value)) { $label = $this->getOption('label') ?: $validation->getLabel($field); $message = $this->getOption('message') ?: 'Invalid namespace syntax!'; $replacePairs = array(':field' => $label); diff --git a/src/Web/Tools.php b/src/Web/Tools.php index e4c172846..da2877ff8 100644 --- a/src/Web/Tools.php +++ b/src/Web/Tools.php @@ -34,18 +34,18 @@ class Tools public static function install(string $path): void { $fsUtils = new FsUtils(); - $path = $fsUtils->normalize(realpath($path)) . DS; - $publicPath = $path . self::PROJECT_PUBLIC_FOLDER . DS; + $path = $fsUtils->normalize(realpath($path)) . DIRECTORY_SEPARATOR; + $publicPath = $path . self::PROJECT_PUBLIC_FOLDER . DIRECTORY_SEPARATOR; $root = new SplFileInfo($publicPath); $fsUtils->setDirectoryPermission($root, ['js' => 0777, 'css' => 0777]); - $tools = rtrim(str_replace(["\\", '/'], DS, PTOOLSPATH), DS); + $tools = rtrim(str_replace(["\\", '/'], DIRECTORY_SEPARATOR, PTOOLSPATH), DIRECTORY_SEPARATOR); - copy($tools . DS . self::WEB_TOOLS_FILE, $publicPath . self::WEB_TOOLS_FILE); + copy($tools . DIRECTORY_SEPARATOR . self::WEB_TOOLS_FILE, $publicPath . self::WEB_TOOLS_FILE); if (!file_exists($configPath = $publicPath . self::WEB_TOOLS_CONFIG_FILE)) { - $template = file_get_contents(TEMPLATE_PATH . DS . self::WEB_TOOLS_CONFIG_FILE); + $template = file_get_contents(TEMPLATE_PATH . DIRECTORY_SEPARATOR . self::WEB_TOOLS_CONFIG_FILE); $code = str_replace('@@PATH@@', $tools, $template); file_put_contents($configPath, $code); @@ -59,16 +59,16 @@ public static function install(string $path): void * @return void * @throws Exception */ - public static function uninstall($path): void + public static function uninstall(string $path): void { $fsUtils = new FsUtils(); - $path = $fsUtils->normalize(realpath($path)) . DS; + $path = $fsUtils->normalize(realpath($path)) . DIRECTORY_SEPARATOR; - $root = new SplFileInfo($path . self::PROJECT_PUBLIC_FOLDER . DS); + $root = new SplFileInfo($path . self::PROJECT_PUBLIC_FOLDER . DIRECTORY_SEPARATOR); $fsUtils->deleteFilesFromDirectory($root, [ - 'css' . DS . 'webtools.css', - 'js' . DS . 'webtools.js', - 'js' . DS . 'webtools-ie.js', + 'css' . DIRECTORY_SEPARATOR . 'webtools.css', + 'js' . DIRECTORY_SEPARATOR . 'webtools.js', + 'js' . DIRECTORY_SEPARATOR . 'webtools-ie.js', self::WEB_TOOLS_CONFIG_FILE, self::WEB_TOOLS_FILE, ]); From 56c27d908d300e4d384701f11ef1fc0efc23fdc9 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Sun, 14 Mar 2021 17:35:49 +0000 Subject: [PATCH 2/2] Correct namespaces in tests --- composer.json | 8 ++- composer.lock | 12 ++-- tests/_support/Module/UnitTest.php | 2 +- .../{phtml => }/ScaffoldPhtmlCest.php | 55 +++++++------------ .../Template/{volt => }/ScaffoldVoltCest.php | 43 +++++++-------- tests/console/GenerateMultyModelsCept.php | 18 +++++- tests/console/GenerateProjectCept.php | 22 ++++++-- tests/console/GenerateScaffoldCept.php | 18 +++++- tests/console/GenerateSingleModelCept.php | 18 +++++- .../functional/Commands/Builtin/ServeTest.php | 7 ++- tests/unit/Generator/SnippetTest.php | 2 +- tests/unit/UtilsTest.php | 16 +++--- 12 files changed, 136 insertions(+), 85 deletions(-) rename tests/acceptance/Web/Template/{phtml => }/ScaffoldPhtmlCest.php (82%) rename tests/acceptance/Web/Template/{volt => }/ScaffoldVoltCest.php (84%) diff --git a/composer.json b/composer.json index 2a5d0b84e..f3efb9a50 100644 --- a/composer.json +++ b/composer.json @@ -52,9 +52,11 @@ }, "autoload-dev": { "psr-4": { - "Phalcon\\Test\\": "tests/unit", - "Phalcon\\Test\\Models\\": "tests/_data/models", - "Phalcon\\Test\\Module\\": "tests/_support/Module" + "Phalcon\\DevTools\\Tests\\Acceptance\\": "tests/acceptance/", + "Phalcon\\DevTools\\Tests\\Console\\": "tests/console/", + "Phalcon\\DevTools\\Tests\\Functional\\": "tests/functional/", + "Phalcon\\DevTools\\Tests\\Unit\\": "tests/unit/", + "Phalcon\\DevTools\\Tests\\Support\\Module\\": "tests/_support/Module" }, "files": [ "tests/_support/helpers.php" diff --git a/composer.lock b/composer.lock index 0f3ed06b3..8692e107d 100644 --- a/composer.lock +++ b/composer.lock @@ -362,16 +362,16 @@ }, { "name": "psy/psysh", - "version": "v0.10.6", + "version": "v0.10.7", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "6f990c19f91729de8b31e639d6e204ea59f19cf3" + "reference": "a395af46999a12006213c0c8346c9445eb31640c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/6f990c19f91729de8b31e639d6e204ea59f19cf3", - "reference": "6f990c19f91729de8b31e639d6e204ea59f19cf3", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/a395af46999a12006213c0c8346c9445eb31640c", + "reference": "a395af46999a12006213c0c8346c9445eb31640c", "shasum": "" }, "require": { @@ -432,9 +432,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.10.6" + "source": "https://github.com/bobthecow/psysh/tree/v0.10.7" }, - "time": "2021-01-18T15:53:43+00:00" + "time": "2021-03-14T02:14:56+00:00" }, { "name": "symfony/console", diff --git a/tests/_support/Module/UnitTest.php b/tests/_support/Module/UnitTest.php index 4c0b2f409..ab7fbafcd 100644 --- a/tests/_support/Module/UnitTest.php +++ b/tests/_support/Module/UnitTest.php @@ -1,6 +1,6 @@ registerNamespaces(' . - $returnLine . '[ '. - '"'.$namespace.'" => $config->application->modelsDir' . - $returnLine . ' ]' . + $returnLine . '[ ' . + '"' . $namespace . '" => $config->application->modelsDir' . + $returnLine . ' ]' . $returnLine . ');'; file_put_contents($loaderFile, $content); @@ -55,6 +55,7 @@ public function before(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testGenScaffoldFileExist(AcceptanceTester $I): void { @@ -115,12 +116,13 @@ public function testGenScaffoldFileExist(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testSearchAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename')); + $I->amOnPage('/' . Fixtures::get('tablename')); $I->see(Fixtures::get('tablename')); - $I->see('Search '.Fixtures::get('tablename')); + $I->see('Search ' . Fixtures::get('tablename')); $I->see('Dateofbirth'); $I->fillField('dateofbirth', '2019-04-17'); $I->click('input[type=submit]'); @@ -130,37 +132,34 @@ public function testSearchAction(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testSearchButtonAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename').'/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); $I->click("#next"); - $I->see("K1S6X"); $I->click("#previous"); - $I->see("U7B0Q"); $I->click("#last"); - $I->see("N2Z7T"); $I->click("#first"); - $I->see("U7B0Q"); } - /** * @group mysql + * @param AcceptanceTester $I */ public function testNewAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename').'/new'); - $I->see('Create '.Fixtures::get('tablename')); + $I->amOnPage('/' . Fixtures::get('tablename') . '/new'); + $I->see('Create ' . Fixtures::get('tablename')); $I->fillField('firstname', 'jeremy'); $I->fillField('surname', 'jenovateurs'); $I->fillField('membertype', 'aaa'); @@ -170,47 +169,35 @@ public function testNewAction(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testEditAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename'). - '/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); $I->click(['link' => 'Edit']); $I->seeInField('firstname', 'Hedley'); $I->fillField('firstname', 'samedi'); $I->click('input[type=submit]'); - $I->amOnPage('/'.Fixtures::get('tablename'). + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); //Check if edit work - // $I->see('samedi'); + // $I->see('samedi'); } /** * @group mysql + * @param AcceptanceTester $I */ public function testDeleteAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename'). - '/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); $I->click(['link' => 'Delete']); $I->see('customer was deleted successfully'); - $I->amOnPage('/'.Fixtures::get('tablename'). - '/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->cantSee('Hedley'); } - - /** - * @group mysql - */ - public function after(AcceptanceTester $I): void - { - /*$I->deleteFile(Fixtures::get('controller')); - $I->deleteFile(Fixtures::get('model')); - $I->deleteFile(Fixtures::get('layout')); - $I->deleteDir(Fixtures::get('views'));*/ - } } diff --git a/tests/acceptance/Web/Template/volt/ScaffoldVoltCest.php b/tests/acceptance/Web/Template/ScaffoldVoltCest.php similarity index 84% rename from tests/acceptance/Web/Template/volt/ScaffoldVoltCest.php rename to tests/acceptance/Web/Template/ScaffoldVoltCest.php index 63c78430b..07c0d3331 100644 --- a/tests/acceptance/Web/Template/volt/ScaffoldVoltCest.php +++ b/tests/acceptance/Web/Template/ScaffoldVoltCest.php @@ -5,12 +5,12 @@ use AcceptanceTester; use Codeception\Util\Fixtures; -use Codeception\Util\Locator; final class ScaffoldVoltCest { /** * @group mysql + * @param AcceptanceTester $I */ public function before(AcceptanceTester $I): void { @@ -45,9 +45,9 @@ public function before(AcceptanceTester $I): void $content .= $returnLine . '$loader->registerNamespaces(' . - $returnLine . '[ '. - '"'.$namespace.'" => $config->application->modelsDir' . - $returnLine . ' ]' . + $returnLine . '[ ' . + '"' . $namespace . '" => $config->application->modelsDir' . + $returnLine . ' ]' . $returnLine . ');'; file_put_contents($loaderFile, $content); @@ -55,6 +55,7 @@ public function before(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testGenScaffoldFileExist(AcceptanceTester $I): void { @@ -115,12 +116,13 @@ public function testGenScaffoldFileExist(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testSearchAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename')); + $I->amOnPage('/' . Fixtures::get('tablename')); $I->see(Fixtures::get('tablename')); - $I->see('Search '.Fixtures::get('tablename')); + $I->see('Search ' . Fixtures::get('tablename')); $I->see('Dateofbirth'); $I->fillField('dateofbirth', '2019-04-17'); $I->click('input[type=submit]'); @@ -130,37 +132,34 @@ public function testSearchAction(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testSearchButtonAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename').'/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); $I->click("#next"); - $I->see("K1S6X"); $I->click("#previous"); - $I->see("W2Q7K"); $I->click("#last"); - $I->see("N2Z7T"); $I->click("#first"); - $I->see("W2Q7K"); } - /** * @group mysql + * @param AcceptanceTester $I */ public function testNewAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename').'/new'); - $I->see('Create '.Fixtures::get('tablename')); + $I->amOnPage('/' . Fixtures::get('tablename') . '/new'); + $I->see('Create ' . Fixtures::get('tablename')); $I->fillField('firstname', 'jeremy'); $I->fillField('surname', 'jenovateurs'); $I->fillField('membertype', 'aaa'); @@ -170,41 +169,41 @@ public function testNewAction(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testEditAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename'). + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); $I->click(['link' => 'Edit']); $I->seeInField('firstname', 'Lillian'); $I->fillField('firstname', 'samedi'); $I->click('input[type=submit]'); - $I->amOnPage('/'.Fixtures::get('tablename'). - '/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); //Check if edit work - // $I->see('samedi'); + // $I->see('samedi'); } /** * @group mysql + * @param AcceptanceTester $I */ public function testDeleteAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename'). - '/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); $I->click(['link' => 'Delete']); $I->see('customer was deleted successfully'); - $I->amOnPage('/'.Fixtures::get('tablename'). - '/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->cantSee('samedi'); } /** * @group mysql + * @param AcceptanceTester $I */ public function after(AcceptanceTester $I): void { diff --git a/tests/console/GenerateMultyModelsCept.php b/tests/console/GenerateMultyModelsCept.php index 36533d7aa..db283c4d6 100644 --- a/tests/console/GenerateMultyModelsCept.php +++ b/tests/console/GenerateMultyModelsCept.php @@ -1,7 +1,23 @@ + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\DevTools\Tests\Console; + +use Codeception\Scenario; +use ConsoleTester; + +/** + * @var Scenario $scenario */ $I = new ConsoleTester($scenario); diff --git a/tests/console/GenerateProjectCept.php b/tests/console/GenerateProjectCept.php index 0bb930fba..4ffa73a71 100644 --- a/tests/console/GenerateProjectCept.php +++ b/tests/console/GenerateProjectCept.php @@ -1,16 +1,28 @@ + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\DevTools\Tests\Console; + +use Codeception\Scenario; +use ConsoleTester; + +/** + * @var Scenario $scenario */ $I = new ConsoleTester($scenario); $I->wantToTest('Generating project'); -$output=<< + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\DevTools\Tests\Console; + +use Codeception\Scenario; +use ConsoleTester; + +/** + * @var Scenario $scenario */ $I = new ConsoleTester($scenario); diff --git a/tests/console/GenerateSingleModelCept.php b/tests/console/GenerateSingleModelCept.php index 80288c321..7b0e3a2d6 100644 --- a/tests/console/GenerateSingleModelCept.php +++ b/tests/console/GenerateSingleModelCept.php @@ -1,7 +1,23 @@ + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\DevTools\Tests\Console; + +use Codeception\Scenario; +use ConsoleTester; + +/** + * @var Scenario $scenario */ $I = new ConsoleTester($scenario); diff --git a/tests/functional/Commands/Builtin/ServeTest.php b/tests/functional/Commands/Builtin/ServeTest.php index 64080d3e0..c7c49c25a 100644 --- a/tests/functional/Commands/Builtin/ServeTest.php +++ b/tests/functional/Commands/Builtin/ServeTest.php @@ -1,7 +1,4 @@