From bd921e29f309622164a5a400d5cad38239f4b633 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 24 Sep 2023 17:57:27 +0000 Subject: [PATCH] fix tests --- {Helper => Config}/.bashrc | 0 Helper/ModuleTestTrait.php | 769 ++++++++++++++++++ Helper/{ => Php}/findMissingAdminTest.php | 8 +- Helper/{ => Php}/findMissingApiFunctions.php | 14 +- Helper/{ => Php}/findMissingNullModelTest.php | 22 +- Helper/{ => Php}/ipGeoLocationBuilder.php | 0 Helper/{ => Php}/langUsageInspector.php | 0 .../{ => Php}/reconcileTestReportElements.php | 10 +- Helper/{ => Scripts}/inspectproject.sh | 0 Helper/{ => Scripts}/install.sh | 0 Helper/{ => Scripts}/screenshots.txt | 0 Helper/{ => Scripts}/serverInstall.sh | 0 Helper/{ => Scripts}/sitespeedAuth.js | 0 Helper/{ => Scripts}/sitespeedUrls.txt | 0 Helper/testreport.sh | 24 - Helper/watcher.sh | 18 - Inspection/Html/static_text.sh | 10 + Inspection/Html/syntax.sh | 33 + Inspection/Html/tags.sh | 4 +- Inspection/Logic/module_navigation.sh | 0 Inspection/Logic/module_route.sh | 0 Inspection/Php/linting.sh | 9 +- Inspection/Php/stats.sh | 1 + Inspection/Php/style.sh | 6 +- Inspection/Php/tests.sh | 2 - Inspection/inspect.sh | 106 +++ Tools/AutoGpt/GptHelper.php | 146 ---- Tools/AutoGpt/autoDevDoc.php | 60 -- Tools/AutoGpt/autoDocblock.php | 67 -- Tools/AutoGpt/autoOptimization.php | 76 -- Tools/AutoGpt/autoUnitTest.php | 108 --- buildProject.sh | 85 +- config.sh | 3 +- setup.sh | 110 --- 34 files changed, 1042 insertions(+), 649 deletions(-) rename {Helper => Config}/.bashrc (100%) mode change 100755 => 100644 create mode 100644 Helper/ModuleTestTrait.php rename Helper/{ => Php}/findMissingAdminTest.php (59%) mode change 100755 => 100644 rename Helper/{ => Php}/findMissingApiFunctions.php (95%) rename Helper/{ => Php}/findMissingNullModelTest.php (74%) mode change 100755 => 100644 rename Helper/{ => Php}/ipGeoLocationBuilder.php (100%) mode change 100755 => 100644 rename Helper/{ => Php}/langUsageInspector.php (100%) mode change 100755 => 100644 rename Helper/{ => Php}/reconcileTestReportElements.php (89%) mode change 100755 => 100644 rename Helper/{ => Scripts}/inspectproject.sh (100%) mode change 100755 => 100644 rename Helper/{ => Scripts}/install.sh (100%) mode change 100755 => 100644 rename Helper/{ => Scripts}/screenshots.txt (100%) mode change 100755 => 100644 rename Helper/{ => Scripts}/serverInstall.sh (100%) rename Helper/{ => Scripts}/sitespeedAuth.js (100%) mode change 100755 => 100644 rename Helper/{ => Scripts}/sitespeedUrls.txt (100%) mode change 100755 => 100644 delete mode 100755 Helper/testreport.sh delete mode 100755 Helper/watcher.sh create mode 100644 Inspection/Html/static_text.sh create mode 100644 Inspection/Html/syntax.sh delete mode 100755 Inspection/Logic/module_navigation.sh delete mode 100755 Inspection/Logic/module_route.sh delete mode 100644 Tools/AutoGpt/GptHelper.php delete mode 100644 Tools/AutoGpt/autoDevDoc.php delete mode 100644 Tools/AutoGpt/autoDocblock.php delete mode 100644 Tools/AutoGpt/autoOptimization.php delete mode 100644 Tools/AutoGpt/autoUnitTest.php delete mode 100755 setup.sh diff --git a/Helper/.bashrc b/Config/.bashrc old mode 100755 new mode 100644 similarity index 100% rename from Helper/.bashrc rename to Config/.bashrc diff --git a/Helper/ModuleTestTrait.php b/Helper/ModuleTestTrait.php new file mode 100644 index 0000000..e2b2daa --- /dev/null +++ b/Helper/ModuleTestTrait.php @@ -0,0 +1,769 @@ +markTestSkipped( + 'The TestModule is not tested' + ); + } + + $this->app = new class() extends ApplicationAbstract + { + protected string $appName = 'Api'; + }; + + $this->app->dbPool = $GLOBALS['dbpool']; + $this->app->router = new WebRouter(); + $this->app->dispatcher = new Dispatcher($this->app); + $this->app->appSettings = new CoreSettings(); + $this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../Modules/'); + $this->app->sessionManager = new HttpSession(0); + $this->app->accountManager = new AccountManager($this->app->sessionManager); + $this->app->eventManager = new EventManager($this->app->dispatcher); + $this->app->l11nManager = new L11nManager(); + } + + /** + * @group admin + * @slowThreshold 5000 + * @group module + */ + public function testModuleIntegration() : void + { + $iResponse = new HttpResponse(); + $iRequest = new HttpRequest(new HttpUri('')); + $iRequest->header->account = 1; + $iRequest->setData('status', ModuleStatusUpdateType::INSTALL); + + $iRequest->setData('module', self::NAME); + $this->app->moduleManager->get('Admin')->apiModuleStatusUpdate($iRequest, $iResponse); + + $iRequest->setData('status', ModuleStatusUpdateType::DEACTIVATE, true); + $this->app->moduleManager->get('Admin')->apiModuleStatusUpdate($iRequest, $iResponse); + self::assertFalse($this->app->moduleManager->isActive(self::NAME), 'Module "' . self::NAME . '" is not active.'); + + $iRequest->setData('status', ModuleStatusUpdateType::ACTIVATE, true); + $this->app->moduleManager->get('Admin')->apiModuleStatusUpdate($iRequest, $iResponse); + self::assertTrue($this->app->moduleManager->isActive(self::NAME), 'Module "' . self::NAME . '" is not active.'); + } + + /** + * @group module + * @coversNothing + */ + public function testMembers() : void + { + $module = $this->app->moduleManager->get(self::NAME); + + if ($module::ID === 0) { + return; + } + + self::assertEquals(self::NAME, $module::NAME); + self::assertEquals(\realpath(__DIR__ . '/../../Modules/' . self::NAME), \realpath($module::PATH)); + self::assertGreaterThanOrEqual(0, Version::compare($module::VERSION, '1.0.0')); + } + + /** + * @group module + * @coversNothing + */ + public function testValidMapper() : void + { + $mappers = \glob(__DIR__ . '/../../Modules/' . self::NAME . '/Models/*Mapper.php'); + + foreach ($mappers as $mapper) { + $class = $this->getMapperFromPath($mapper); + $columns = $class::COLUMNS; + + foreach ($columns as $cName => $column) { + if (!\in_array($column['type'], ['int', 'string', 'compress', 'DateTime', 'DateTimeImmutable', 'Json', 'Serializable', 'bool', 'float'])) { + self::assertTrue(false, 'Mapper "' . $class . '" column "' . $cName . '" has invalid type'); + } + + if ($cName !== ($column['name'] ?? false)) { + self::assertTrue(false); + } + } + } + + self::assertTrue(true); + } + + /** + * Get mapper from file path + * + * @param string $mapper Mapper path + * + * @return string + */ + private function getMapperFromPath(string $mapper) : string + { + $name = \substr($mapper, \strlen(__DIR__ . '/../../Modules/' . self::NAME . '/Models/'), -4); + + return '\\Modules\\' . self::NAME . '\\Models\\' . $name; + } + + /** + * @group module + * @coversNothing + */ + public function testMapperAgainstModel() : void + { + $mappers = \glob(__DIR__ . '/../../Modules/' . self::NAME . '/Models/*Mapper.php'); + + foreach ($mappers as $mapper) { + $class = $this->getMapperFromPath($mapper); + if ($class === '\Modules\Admin\Models\ModuleMapper' + || !Autoloader::exists(\substr($class, 0, -6)) + ) { + continue; + } + + $columns = $class::COLUMNS; + $ownsOne = $class::OWNS_ONE; + + $classReflection = new \ReflectionClass(\substr($class, 0, -6)); + $defaultProperties = $classReflection->getDefaultProperties(); + + $invalidAcessors = []; + + foreach ($columns as $cName => $column) { + $isArray = false; + // testing existence of member variable in model + if (\stripos($column['internal'], '/') !== false) { + $column['internal'] = \explode('/', $column['internal'])[0]; + $isArray = true; + } + + if (!$classReflection->hasProperty($column['internal'])) { + self::assertTrue(false, 'Mapper "' . $class . '" column "' . $cName . '" has missing/invalid internal/member'); + } + + $property = $classReflection->getProperty($column['internal']) ?? null; + if ($property === null || (!$property->isPublic() && (!isset($column['private']) || !$column['private']))) { + $invalidAcessors[] = $column['internal']; + } + + // testing correct mapper/model variable type definition + $property = $defaultProperties[$column['internal']] ?? null; + if (!($property === null /* not every value is allowed to be null but this just has to be correctly implemented in the mapper, no additional checks for this case! */ + || (\is_string($property) && ($column['type'] === 'string' || $column['type'] === 'compress')) + || (\is_int($property) && $column['type'] === 'int') + || (\is_array($property) && ($column['type'] === 'Json' || $column['type'] === 'Serializable' || $isArray)) + || (\is_bool($property) && $column['type'] === 'bool') + || (\is_float($property) && $column['type'] === 'float') + || ($property instanceof \DateTime && $column['type'] === 'DateTime') + || ($property instanceof \DateTimeImmutable && $column['type'] === 'DateTimeImmutable') + || (isset($ownsOne[$column['internal']]) && $column['type'] === 'int') // if it is in ownsOne it can be a different type because it is a reference! + )) { + self::assertTrue(false, 'Mapper "' . $class . '" column "' . $cName . '" has invalid type compared to model definition'); + } + } + + if (!empty($invalidAcessors)) { + self::assertTrue(false, 'Mapper "' . $class . '" must define private for "' . \implode(',', $invalidAcessors) . '" or make them public (recommended) in the model'); + } + + // test hasMany variable exists in model + $rel = $class::HAS_MANY; + foreach ($rel as $pName => $def) { + $property = $classReflection->getProperty($pName) ?? null; + if (!\array_key_exists($pName, $defaultProperties) && $property === null) { + self::assertTrue(false, 'Mapper "' . $class . '" property "' . $pName . '" doesn\'t exist in model'); + } + } + } + + self::assertTrue(true); + } + + /** + * @group module + * @coversNothing + */ + public function testValidDbSchema() : void + { + $schemaPath = __DIR__ . '/../../Modules/' . self::NAME . '/Admin/Install/db.json'; + + if (!\is_file($schemaPath)) { + self::assertTrue(true); + + return; + } + + $db = \json_decode(\file_get_contents($schemaPath), true); + + foreach ($db as $name => $table) { + if ($name !== ($table['name'] ?? false)) { + self::assertTrue(false, 'Schema "' . $schemaPath . '" name "' . $name . '" is invalid'); + } + + foreach ($table['fields'] as $cName => $column) { + if ($cName !== ($column['name'] ?? false)) { + self::assertTrue(false, 'Schema "' . $schemaPath . '" name "' . $cName . '" is invalid'); + } + + if (!(\stripos($column['type'] ?? '', 'TINYINT') === 0 + || \stripos($column['type'] ?? '', 'SMALLINT') === 0 + || \stripos($column['type'] ?? '', 'INT') === 0 + || \stripos($column['type'] ?? '', 'BIGINT') === 0 + || \stripos($column['type'] ?? '', 'VARCHAR') === 0 + || \stripos($column['type'] ?? '', 'VARBINARY') === 0 + || \stripos($column['type'] ?? '', 'TEXT') === 0 + || \stripos($column['type'] ?? '', 'LONGTEXT') === 0 + || \stripos($column['type'] ?? '', 'BLOB') === 0 + || \stripos($column['type'] ?? '', 'DATETIME') === 0 + || \stripos($column['type'] ?? '', 'DECIMAL') === 0 + )) { + self::assertTrue(false, 'Schema "' . $schemaPath . '" type "' . ($column['type'] ?? '') . '" is a missing/invalid type'); + } + } + } + + $dbTemplate = \json_decode(\file_get_contents(__DIR__ . '/../../phpOMS/DataStorage/Database/tableDefinition.json'), true); + self::assertTrue(Json::validateTemplate($dbTemplate, $db), 'Invalid db template for ' . self::NAME); + } + + /** + * @group module + * @coversNothing + */ + public function testDbSchemaAgainstDb() : void + { + $builder = new SchemaBuilder($this->app->dbPool->get()); + $tables = $builder->selectTables()->execute()->fetchAll(\PDO::FETCH_COLUMN); + + $schemaPath = __DIR__ . '/../../Modules/' . self::NAME . '/Admin/Install/db.json'; + + if (!\is_file($schemaPath)) { + self::assertTrue(true); + + return; + } + + $db = \json_decode(\file_get_contents($schemaPath), true); + + foreach ($db as $name => $table) { + if (!\in_array($name, $tables)) { + self::assertTrue(false, 'Table ' . $name . ' doesn\'t exist in the database.'); + } + + $field = new SchemaBuilder($this->app->dbPool->get()); + $fields = $field->selectFields($name)->execute()->fetchAll(); + + foreach ($table['fields'] as $cName => $column) { + if (!ArrayUtils::inArrayRecursive($cName, $fields)) { + self::assertTrue(false, 'Couldn\'t find "' . $cName . '" in "' . $name . '"'); + } + } + } + + self::assertTrue(true); + } + + /** + * @group module + * @coversNothing + */ + public function testMapperAgainstDbSchema() : void + { + $schemaPath = __DIR__ . '/../../Modules/' . self::NAME . '/Admin/Install/db.json'; + $mappers = \glob(__DIR__ . '/../../Modules/' . self::NAME . '/Models/*Mapper.php'); + + if (!\is_file($schemaPath)) { + self::assertTrue(true); + + return; + } + + $db = \json_decode(\file_get_contents($schemaPath), true); + + foreach ($mappers as $mapper) { + $class = $this->getMapperFromPath($mapper); + + if (\defined('self::MAPPER_TO_IGNORE') && \in_array(\ltrim($class, '\\'), self::MAPPER_TO_IGNORE) + || empty($class::COLUMNS) + || $class === '\Modules\Admin\Models\ModuleMapper' + ) { + continue; + } + + $table = $class::TABLE; + $columns = $class::COLUMNS; + + foreach ($columns as $cName => $column) { + // testing existence of field name in schema + if (!isset($db[$table]['fields'][$cName])) { + self::assertTrue(false, 'Mapper "' . $class . '" column "' . $cName . '" doesn\'t match schema'); + } + + // testing schema/mapper same column data type + if (!(($column['type'] === 'string' + && (\stripos($db[$table]['fields'][$cName]['type'], 'VARCHAR') === 0 + || \stripos($db[$table]['fields'][$cName]['type'], 'VARBINARY') === 0 + || \stripos($db[$table]['fields'][$cName]['type'], 'BLOB') === 0 + || \stripos($db[$table]['fields'][$cName]['type'], 'TEXT') === 0 + || \stripos($db[$table]['fields'][$cName]['type'], 'LONGTEXT') === 0)) + || ($column['type'] === 'int' + && (\stripos($db[$table]['fields'][$cName]['type'], 'TINYINT') === 0 + || \stripos($db[$table]['fields'][$cName]['type'], 'SMALLINT') === 0 + || \stripos($db[$table]['fields'][$cName]['type'], 'INT') === 0 + || \stripos($db[$table]['fields'][$cName]['type'], 'BIGINT') === 0)) + || ($column['type'] === 'Json' + && (\stripos($db[$table]['fields'][$cName]['type'], 'VARCHAR') === 0 + || \stripos($db[$table]['fields'][$cName]['type'], 'LONGTEXT') === 0 + || \stripos($db[$table]['fields'][$cName]['type'], 'TEXT') === 0)) + || ($column['type'] === 'compress' + && (\stripos($db[$table]['fields'][$cName]['type'], 'BLOB') === 0)) + || ($column['type'] === 'Serializable') + || ($column['type'] === 'bool' && \stripos($db[$table]['fields'][$cName]['type'], 'TINYINT') === 0) + || ($column['type'] === 'float' && \stripos($db[$table]['fields'][$cName]['type'], 'DECIMAL') === 0) + || ($column['type'] === 'DateTime' && \stripos($db[$table]['fields'][$cName]['type'], 'DATETIME') === 0) + || ($column['type'] === 'DateTimeImmutable' && \stripos($db[$table]['fields'][$cName]['type'], 'DATETIME') === 0) + )) { + self::assertTrue(false, 'Schema "' . $schemaPath . '" type "' . ($column['type'] ?? '') . '" is incompatible with mapper "' . $class . '" definition "' . $db[$table]['fields'][$cName]['type'] . '" for field "' . $cName . '"'); + } + } + + // testing schema/mapper same primary key definition + $primary = $class::PRIMARYFIELD; + if (!($db[$table]['fields'][$primary]['primary'] ?? false)) { + self::assertTrue(false, 'Field "' . $primary . '" from mapper "' . $class . '" is not defined as primary key in table "' . $table . '"'); + } + } + + self::assertTrue(true); + } + + /** + * @group module + * @coversNothing + */ + public function testJson() : void + { + $sampleInfo = \json_decode(\file_get_contents(__DIR__ . '/../TestModule/info.json'), true); + $infoTemplate = \json_decode(\file_get_contents(__DIR__ . '/../../phpOMS/Module/infoLayout.json'), true); + + $module = $this->app->moduleManager->get(self::NAME); + + if ($module::ID === 0) { + return; + } + + // validate info.json + $info = \json_decode(\file_get_contents($module::PATH . '/info.json'), true); + self::assertTrue($this->infoJsonTest($info, $sampleInfo), 'Info assert failed for '. self::NAME); + self::assertTrue(Json::validateTemplate($infoTemplate, $info), 'Invalid info template for ' . self::NAME); + } + + /** + * @group module + * @coversNothing + */ + public function testDependency() : void + { + $module = $this->app->moduleManager->get(self::NAME); + + if ($module::ID === 0) { + return; + } + + // validate dependency installation + $info = \json_decode(\file_get_contents($module::PATH . '/info.json'), true); + self::assertTrue($this->dependencyTest($info, $this->app->moduleManager->getInstalledModules(false)), 'Invalid dependency configuration in ' . self::NAME); + } + + /** + * @group module + * @coversNothing + */ + public function testRoutes() : void + { + $this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../Modules/'); + $totalBackendRoutes = \is_file(__DIR__ . '/../../Web/Backend/Routes.php') ? include __DIR__ . '/../../Web/Backend/Routes.php' : []; + $totalApiRoutes = \is_file(__DIR__ . '/../../Web/Api/Routes.php') ? include __DIR__ . '/../../Web/Api/Routes.php' : []; + + $module = $this->app->moduleManager->get(self::NAME); + + if ($module::ID === 0) { + return; + } + + // test routes + if (\is_file($module::PATH . '/Admin/Routes/Web/Backend.php')) { + $moduleRoutes = include $module::PATH . '/Admin/Routes/Web/Backend.php'; + self::assertEquals(1, $this->routesTest($moduleRoutes, $totalBackendRoutes), 'Backend route assert failed for '. self::NAME); + } + + // test routes + if (\is_file($module::PATH . '/Admin/Routes/Web/Api.php')) { + $moduleRoutes = include $module::PATH . '/Admin/Routes/Web/Api.php'; + self::assertEquals(1, $this->routesTest($moduleRoutes, $totalApiRoutes), 'Api route assert failed for '. self::NAME); + } + } + + /** + * @group module + * @coversNothing + */ + public function testHooks() : void + { + $this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../Modules/'); + $totalBackendHooks = \is_file(__DIR__ . '/../../Web/Backend/Hooks.php') ? include __DIR__ . '/../../Web/Backend/Hooks.php' : []; + $totalApiHooks = \is_file(__DIR__ . '/../../Web/Api/Hooks.php') ? include __DIR__ . '/../../Web/Api/Hooks.php' : []; + + $module = $this->app->moduleManager->get(self::NAME); + + if ($module::ID === 0) { + return; + } + + // test hooks + if (\is_file($module::PATH . '/Admin/Hooks/Web/Backend.php')) { + $moduleHooks = include $module::PATH . '/Admin/Hooks/Web/Backend.php'; + self::assertEquals(1, $this->hooksTest($moduleHooks, $totalBackendHooks), 'Backend hook assert failed for '. self::NAME); + } + + // test hooks + if (\is_file($module::PATH . '/Admin/Hooks/Web/Api.php')) { + $moduleHooks = include $module::PATH . '/Admin/Hooks/Web/Api.php'; + self::assertEquals(1, $this->hooksTest($moduleHooks, $totalApiHooks), 'Api hook assert failed for '. self::NAME); + } + } + + /** + * @group final + * @group module + * @coversNothing + */ + public function testNavigation() : void + { + $module = $this->app->moduleManager->get(self::NAME); + + if ($module::ID === 0 + || $this->app->moduleManager->get('Navigation')::ID === 0 + || !\is_file($module::PATH . '/Admin/Install/Navigation.install.json') + ) { + return; + } + + // test if navigation db entries match json files + self::assertTrue( + $this->navLinksTest( + $this->app->dbPool->get(), + \json_decode( + \file_get_contents($module::PATH . '/Admin/Install/Navigation.install.json'), + true + ), + self::NAME + ) + ); + } + + /** + * Test if all navigation links are in the database + * + * @param mixed $db Database connection + * @param array $links Navigation links from install file + * @param string $module Module name + * + * @return bool + */ + private function navLinksTest($db, array $links, string $module) : bool + { + $query = new Builder($db); + $query->select('nav_id')->from('nav')->where('nav_from', '=', $module); + + $result = $query->execute()->fetchAll(\PDO::FETCH_COLUMN); + $it = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($links)); + + foreach ($it as $link) { + if (\is_array($link) + && !\in_array($link['id'], $result) + ) { + return false; + } + } + + return true; + } + + /** + * Test if all dependencies got installed + * + * @param array $info Module info array/file + * @param array $modules Installed modules + * + * @return bool + */ + private function dependencyTest(array $info, array $modules) : bool + { + foreach ($info['dependencies'] as $module => $version) { + if (!isset($modules[$module])) { + return false; + } + } + + return true; + } + + /** + * Test if route destinations exist (in the *Controller and global application route file) + * + * @param array $module Routes of the module from the respective app and module route file + * @param array $total Routing file of the respective application which contains all app routes + * + * @return int + */ + private function routesTest(array $module, array $total) : int + { + foreach ($module as $route => $dests) { + // test route existence after installation + if (!isset($total[$route])) { + return -1; + } + + // test route class + foreach ($dests as $verb) { + $parts = \explode(':', $verb['dest']); + $path = __DIR__ . '/../../' . \ltrim(\strtr($parts[0], '\\', '/'), '/') . '.php'; + if (!\is_file($path)) { + return -2; + } + + // test route method + $content = \file_get_contents($path); + if (\stripos($content, 'function ' . $parts[\count($parts) - 1]) === false + && \strpos($parts[\count($parts) - 1], 'Trait') === false + ) { + return -3; + } + } + } + + return 1; + } + + /** + * Test if hook destinations exist (in the *Controller and global application hook file) + * + * @param array $module Hooks of the module from the respective app and module hook file + * @param array $total Routing file of the respective application which contains all app routes + * + * @return int + */ + private function hooksTest(array $module, array $total) : int + { + foreach ($module as $route => $dests) { + if (!isset($total[$route])) { + return -1; + } + + // test route class + foreach ($dests['callback'] as $callback) { + $parts = \explode(':', $callback); + $path = __DIR__ . '/../../' . \ltrim(\strtr($parts[0], '\\', '/'), '/') . '.php'; + if (!\is_file($path)) { + return -2; + } + + // test route method + $content = \file_get_contents($path); + if (\stripos($content, 'function ' . $parts[\count($parts) - 1]) === false) { + return -3; + } + } + } + + return 1; + } + + /** + * Test if the module info file has the correct types + * + * @param array $module Module info file + * @param array $samle Sample info file (as basis for checking the data types) + * + * @return bool + */ + private function infoJsonTest(array $module, array $sample) : bool + { + try { + if (\gettype($module['name']['id']) === \gettype($sample['name']['id']) + && \gettype($module['name']['internal']) === \gettype($sample['name']['internal']) + && \gettype($module['name']['external']) === \gettype($sample['name']['external']) + && \gettype($module['category']) === \gettype($sample['category']) + && \gettype($module['version']) === \gettype($sample['version']) + && \gettype($module['requirements']) === \gettype($sample['requirements']) + && \gettype($module['creator']) === \gettype($sample['creator']) + && \gettype($module['creator']['name']) === \gettype($sample['creator']['name']) + && \gettype($module['description']) === \gettype($sample['description']) + && \gettype($module['directory']) === \gettype($sample['directory']) + && \gettype($module['dependencies']) === \gettype($sample['dependencies']) + && \gettype($module['providing']) === \gettype($sample['providing']) + && \gettype($module['load']) === \gettype($sample['load']) + ) { + return true; + } + } catch (\Throwable $_) { + return false; + } + + return false; + } + + /** + * @group module + * @coversNothing + */ + public function testRequestLoads() : void + { + if (!\defined('self::URI_LOAD') || empty(self::URI_LOAD)) { + return; + } + + $request = new HttpRequest(new HttpUri(self::URI_LOAD)); + $request->createRequestHashs(2); + + $loaded = $this->app->moduleManager->getUriLoad($request); + + $found = false; + foreach ($loaded[4] as $module) { + if ($module['module_load_file'] === self::NAME) { + $found = true; + break; + } + } + + self::assertTrue($found, 'Module ' . self::NAME . ' is not loaded at ' . self::URI_LOAD . '. The module info.json file ("load" section for type: 4 loads) and the routing files paths should match.'); + self::assertGreaterThan(0, \count($this->app->moduleManager->getLanguageFiles($request))); + self::assertTrue(\in_array(self::NAME, $this->app->moduleManager->getRoutedModules($request))); + + $this->app->moduleManager->initRequestModules($request); + self::assertTrue($this->app->moduleManager->isRunning(self::NAME)); + } + + /** + * @group module + * @coversNothing + */ + public function testLanguage() : void + { + $module = $this->app->moduleManager->get(self::NAME); + if ($module::ID === 0) { + return; + } + + $required = ['en', 'de']; + if (!\is_dir($module::PATH . '/Theme')) { + return; + } + + $themes = \scandir($module::PATH . '/Theme'); + if ($themes === false) { + return; + } + + foreach ($themes as $theme) { + if ($theme === '.' || $theme === '..' || !\is_dir($module::PATH . '/Theme/' . $theme . '/Lang')) { + continue; + } + + $langKeys = []; + + $langFiles = \scandir($module::PATH . '/Theme/' . $theme . '/Lang'); + foreach ($langFiles as $file) { + if ($file === '.' || $file === '..' || \stripos($file, '.lang.') === false) { + continue; + } + + $parts = \explode('.', $file); + $type = ''; + + $type = \strlen($parts[0]) === 2 ? '' : $parts[0]; + + if (!isset($langKeys[$type])) { + $langKeys[$type] = [ + 'required' => null, + 'keys' => [], + ]; + } + + // check if required lanugages files exist IFF any language file of a specific type exists + if ($langKeys[$type]['required'] === null) { + $langKeys[$type]['required'] = true; + + $missingLanguages = []; + foreach ($required as $lang) { + if (!\in_array(($type !== '' ? $type . '.' : '') . $lang . '.lang.php', $langFiles)) { + $langKeys[$type]['required'] = false; + $missingLanguages[] = $lang; + } + } + + if (!empty($missingLanguages)) { + self::assertTrue(false, 'The language files "' . \implode(', ', $missingLanguages) . '" are missing with type "' . $type . '".'); + } + } + + // compare key equality + // every key in the key list must be present in all other language files of the same type and vice versa + $langArray = include $module::PATH . '/Theme/' . $theme . '/Lang/' . $file; + $langArray = \reset($langArray); + + $keys = \array_keys($langArray); + + if (empty($langKeys[$type]['keys'])) { + $langKeys[$type]['keys'] = $keys; + } elseif (!empty($diff1 = \array_diff($langKeys[$type]['keys'], $keys)) + || !empty($diff2 = \array_diff($keys, $langKeys[$type]['keys']))) { + self::assertTrue(false, $file . ': The language keys "' . \implode(', ', \array_merge($diff1, $diff2)) . '" are different.'); + } + } + } + + self::assertTrue(true); + } +} diff --git a/Helper/findMissingAdminTest.php b/Helper/Php/findMissingAdminTest.php old mode 100755 new mode 100644 similarity index 59% rename from Helper/findMissingAdminTest.php rename to Helper/Php/findMissingAdminTest.php index 36ceefc..ee6f90a --- a/Helper/findMissingAdminTest.php +++ b/Helper/Php/findMissingAdminTest.php @@ -14,17 +14,17 @@ declare(strict_types=1); // Find modules where the Module/tests/Admin/AdminTest.php is missing -$modules = \scandir(__DIR__ . '/../../Modules'); +$modules = \scandir(__DIR__ . '/../../../Modules'); foreach ($modules as $module) { if ($module === '..' || $module === '.' - || !\is_dir(__DIR__ . '/../../Modules/' . $module) - || !\is_file(__DIR__ . '/../../Modules/' . $module . '/info.json')) + || !\is_dir(__DIR__ . '/../../../Modules/' . $module) + || !\is_file(__DIR__ . '/../../../Modules/' . $module . '/info.json')) { continue; } - if (!\is_file(__DIR__ . '/../../Modules/' . $module . '/tests/Admin/AdminTest.php')) { + if (!\is_file(__DIR__ . '/../../../Modules/' . $module . '/tests/Admin/AdminTest.php')) { echo $module . "\n"; } } diff --git a/Helper/findMissingApiFunctions.php b/Helper/Php/findMissingApiFunctions.php similarity index 95% rename from Helper/findMissingApiFunctions.php rename to Helper/Php/findMissingApiFunctions.php index 456623d..2785be4 100644 --- a/Helper/findMissingApiFunctions.php +++ b/Helper/Php/findMissingApiFunctions.php @@ -14,7 +14,7 @@ declare(strict_types=1); // Create missing api functions -$modules = \scandir(__DIR__ . '/../../Modules'); +$modules = \scandir(__DIR__ . '/../../../Modules'); $allowed = ['Organization']; @@ -241,22 +241,22 @@ function deleteFunction($module, $modelName) foreach ($modules as $module) { if ($module === '..' || $module === '.' - || !\is_dir(__DIR__ . '/../../Modules/' . $module) - || !\is_dir(__DIR__ . '/../../Modules/' . $module . '/Controller') - || !\is_file(__DIR__ . '/../../Modules/' . $module . '/info.json') + || !\is_dir(__DIR__ . '/../../../Modules/' . $module) + || !\is_dir(__DIR__ . '/../../../Modules/' . $module . '/Controller') + || !\is_file(__DIR__ . '/../../../Modules/' . $module . '/info.json') || (!empty($allowed) && !\in_array($module, $allowed)) ) { continue; } - $controllers = \scandir(__DIR__ . '/../../Modules/' . $module . '/Controller'); + $controllers = \scandir(__DIR__ . '/../../../Modules/' . $module . '/Controller'); foreach ($controllers as $controller) { if (\stripos($controller, 'Api') === false) { continue; } - $content = \file_get_contents(__DIR__ . '/../../Modules/' . $module . '/Controller/' . $controller); + $content = \file_get_contents(__DIR__ . '/../../../Modules/' . $module . '/Controller/' . $controller); $matches = []; \preg_match_all('/(public function )(.*?)(\()/', $content, $matches); @@ -375,7 +375,7 @@ foreach ($modules as $module) { echo "\nMissing functions \"" . $module . "\": \n"; $newContent = \rtrim($content, " }\n") . "\n }\n" . $newContent . "}\n"; - \file_put_contents(__DIR__ . '/../../Modules/' . $module . '/Controller/' . $controller, $newContent); + \file_put_contents(__DIR__ . '/../../../Modules/' . $module . '/Controller/' . $controller, $newContent); } foreach ($missing as $m) { diff --git a/Helper/findMissingNullModelTest.php b/Helper/Php/findMissingNullModelTest.php old mode 100755 new mode 100644 similarity index 74% rename from Helper/findMissingNullModelTest.php rename to Helper/Php/findMissingNullModelTest.php index 434a40a..97ce664 --- a/Helper/findMissingNullModelTest.php +++ b/Helper/Php/findMissingNullModelTest.php @@ -14,18 +14,18 @@ declare(strict_types=1); // Find null models with no null model test and creates the tests -$modules = \scandir(__DIR__ . '/../../Modules'); +$modules = \scandir(__DIR__ . '/../../../Modules'); foreach ($modules as $module) { if ($module === '..' || $module === '.' - || !\is_dir(__DIR__ . '/../../Modules/' . $module) - || !\is_dir(__DIR__ . '/../../Modules/' . $module . '/Models') - || !\is_file(__DIR__ . '/../../Modules/' . $module . '/info.json')) + || !\is_dir(__DIR__ . '/../../../Modules/' . $module) + || !\is_dir(__DIR__ . '/../../../Modules/' . $module . '/Models') + || !\is_file(__DIR__ . '/../../../Modules/' . $module . '/info.json')) { continue; } - $models = \scandir(__DIR__ . '/../../Modules/' . $module . '/Models'); + $models = \scandir(__DIR__ . '/../../../Modules/' . $module . '/Models'); foreach ($models as $model) { if ($model === '..' || $model === '.' @@ -44,15 +44,15 @@ foreach ($modules as $module) { throw new Exception('invalid substr'); } - if (!\is_file(__DIR__ . '/../../Modules/' . $module . '/tests/Models/Null' . $model . 'Test.php')) { + if (!\is_file(__DIR__ . '/../../../Modules/' . $module . '/tests/Models/Null' . $model . 'Test.php')) { echo $module . ': Null' . $model . "\n"; - if (!\is_dir(__DIR__ . '/../../Modules/' . $module . '/tests')) { - \mkdir(__DIR__ . '/../../Modules/' . $module . '/tests'); + if (!\is_dir(__DIR__ . '/../../../Modules/' . $module . '/tests')) { + \mkdir(__DIR__ . '/../../../Modules/' . $module . '/tests'); } - if (!\is_dir(__DIR__ . '/../../Modules/' . $module . '/tests/Models')) { - \mkdir(__DIR__ . '/../../Modules/' . $module . '/tests/Models'); + if (!\is_dir(__DIR__ . '/../../../Modules/' . $module . '/tests/Models')) { + \mkdir(__DIR__ . '/../../../Modules/' . $module . '/tests/Models'); } $test = ' $line) { $file = \reset($parts); $function = \end($parts); - $file = __DIR__ . '/../../' . \strtr($file, '\\', '/') . '.php'; + $file = __DIR__ . '/../../../' . \strtr($file, '\\', '/') . '.php'; if (!\is_file($file)) { $noTestFile[] = $key; @@ -80,8 +80,8 @@ foreach ($invalidDescription as $function) { } $directories = [ - __DIR__ . '/../../phpOMS/tests/**/*Test.php', - __DIR__ . '/../../Modules/**/tests/**/*Test.php' + __DIR__ . '/../../../phpOMS/tests/**/*Test.php', + __DIR__ . '/../../../Modules/**/tests/**/*Test.php' ]; foreach ($directories as $directory) { @@ -103,7 +103,7 @@ foreach ($directories as $directory) { $end = \strpos($line, '('); $function = \substr($line, 20, $end - 20); - $name = \substr(\realpath($file), \strlen(\realpath(__DIR__ . '/../../')) + 1, -4); + $name = \substr(\realpath($file), \strlen(\realpath(__DIR__ . '/../../../')) + 1, -4); $name = \strtr($name, '/', '\\'); $reportKey = $name . ':' . $function; diff --git a/Helper/inspectproject.sh b/Helper/Scripts/inspectproject.sh old mode 100755 new mode 100644 similarity index 100% rename from Helper/inspectproject.sh rename to Helper/Scripts/inspectproject.sh diff --git a/Helper/install.sh b/Helper/Scripts/install.sh old mode 100755 new mode 100644 similarity index 100% rename from Helper/install.sh rename to Helper/Scripts/install.sh diff --git a/Helper/screenshots.txt b/Helper/Scripts/screenshots.txt old mode 100755 new mode 100644 similarity index 100% rename from Helper/screenshots.txt rename to Helper/Scripts/screenshots.txt diff --git a/Helper/serverInstall.sh b/Helper/Scripts/serverInstall.sh similarity index 100% rename from Helper/serverInstall.sh rename to Helper/Scripts/serverInstall.sh diff --git a/Helper/sitespeedAuth.js b/Helper/Scripts/sitespeedAuth.js old mode 100755 new mode 100644 similarity index 100% rename from Helper/sitespeedAuth.js rename to Helper/Scripts/sitespeedAuth.js diff --git a/Helper/sitespeedUrls.txt b/Helper/Scripts/sitespeedUrls.txt old mode 100755 new mode 100644 similarity index 100% rename from Helper/sitespeedUrls.txt rename to Helper/Scripts/sitespeedUrls.txt diff --git a/Helper/testreport.sh b/Helper/testreport.sh deleted file mode 100755 index ede5f37..0000000 --- a/Helper/testreport.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -mkdir -p Build/test - -# php cs + phpstan + eslint file generation -./vendor/bin/phpcs --severity=1 ./ --standard="Build/Config/phpcs.xml" -s --report-junit=Build/test/junit_phpcs.xml -./vendor/bin/phpstan analyse -l 9 -c Build/Config/phpstan.neon --error-format=prettyJson ./ > Build/test/phpstan.json -npx eslint jsOMS/ -c Build/Config/.eslintrc.json -o Build/test/junit_eslint.xml -f junit - -# Remove empty lines and lines with warnings which corrupt the json format -sed -i '/^$/d' Build/test/phpstan.json -sed -i '/^Warning: /d' Build/test/phpstan.json - -# Create report -php ./Tools/TestReportGenerator/src/index.php \ --b /var/www/html/Karaka \ --l /var/www/html/Karaka/Build/Config/reportLang.php \ --c /var/www/html/Karaka/tests/coverage.xml \ --s /var/www/html/Karaka/Build/test/junit_phpcs.xml \ --sj /var/www/html/Karaka/Build/test/junit_eslint.xml \ --a /var/www/html/Karaka/Build/test/phpstan.json \ --u /var/www/html/Karaka/Build/test/junit_php.xml \ --d /var/www/html/Karaka/Build/test/ReportExternal \ ---version 1.0.0 diff --git a/Helper/watcher.sh b/Helper/watcher.sh deleted file mode 100755 index 7291e28..0000000 --- a/Helper/watcher.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -DIRECTORY_TO_OBSERVE="cssOMS jsOMS" -function watcher { - inotifywait -r -e modify,move,create,delete \ - --exclude ".*(\.css|\.php|\.json|\.md|\.sh|\.txt|\.log|\.min\.js)" \ - ${DIRECTORY_TO_OBSERVE} -} - -BUILD_SCRIPT=build_frontend.sh -function build { - bash ${BUILD_SCRIPT} -} - -build -while watcher; do - build -done diff --git a/Inspection/Html/static_text.sh b/Inspection/Html/static_text.sh new file mode 100644 index 0000000..e5a95b8 --- /dev/null +++ b/Inspection/Html/static_text.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +. config.sh + +echo "#################################################" +echo "Start static text inspection" +echo "#################################################" + +grep -rlnP '(title|alt|aria\-label)(=\")((?!\<\?).)*(>)' --include \*.tpl.php Modules >> ${INSPECTION_PATH}/Modules/html/static_text.log +grep -rlnP '(\|\|\|\)[0-9a-zA-Z\.\?]+' --include \*.tpl.php Modules >> ${INSPECTION_PATH}/Modules/html/static_text.log diff --git a/Inspection/Html/syntax.sh b/Inspection/Html/syntax.sh new file mode 100644 index 0000000..4e37711 --- /dev/null +++ b/Inspection/Html/syntax.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +. config.sh + +echo "#################################################" +echo "Start html syntax inspection" +echo "#################################################" + +# +echo "Image alt missing:" > ${INSPECTION_PATH}/Modules/html_syntax.log +grep -rlnP '(\)' --include \*.tpl.php Modules >> ${INSPECTION_PATH}/Modules/html_syntax.log + +echo "Input type missing:" >> ${INSPECTION_PATH}/Modules/html_syntax.log +grep -rlnP '()' --include \*.tpl.php Modules >> ${INSPECTION_PATH}/Modules/html_syntax.log + +echo "Input name missing:" >> ${INSPECTION_PATH}/Modules/html_syntax.log +grep -rlnP '()' --include \*.tpl.php Modules >> ${INSPECTION_PATH}/Modules/html_syntax.log + +echo "Form id missing:" >> ${INSPECTION_PATH}/Modules/html_syntax.log +grep -rlnP '(\)' --include \*.tpl.php Modules >> ${INSPECTION_PATH}/Modules/html_syntax.log + +# +echo "Image alt missing:" > ${INSPECTION_PATH}/Web/html_syntax.log +grep -rlnP '(\)' --include \*.tpl.php Web >> ${INSPECTION_PATH}/Web/html_syntax.log + +echo "Input type missing:" >> ${INSPECTION_PATH}/Web/html_syntax.log +grep -rlnP '()' --include \*.tpl.php Web >> ${INSPECTION_PATH}/Web/html_syntax.log + +echo "Input name missing:" >> ${INSPECTION_PATH}/Web/html_syntax.log +grep -rlnP '()' --include \*.tpl.php Web >> ${INSPECTION_PATH}/Web/html_syntax.log + +echo "Form id missing:" >> ${INSPECTION_PATH}/Web/html_syntax.log +grep -rlnP '(\)' --include \*.tpl.php Web >> ${INSPECTION_PATH}/Web/html_syntax.log \ No newline at end of file diff --git a/Inspection/Html/tags.sh b/Inspection/Html/tags.sh index 697b116..8a12377 100755 --- a/Inspection/Html/tags.sh +++ b/Inspection/Html/tags.sh @@ -29,6 +29,6 @@ TAG[18]="" for i in "${TAG[@]}" do - grep -rln "$i" --include \*.tpl.php ${ROOT_PATH}/phpOMS >> ${INSPECTION_PATH}/Framework/html/tags.log - grep -rln "$i" --include \*.tpl.php ${ROOT_PATH}/Modules >> ${INSPECTION_PATH}/Modules/html/tags.log + grep -rln "$i" --include \*.tpl.php ${ROOT_PATH}/phpOMS >> ${INSPECTION_PATH}/Framework/html_tags.log + grep -rln "$i" --include \*.tpl.php ${ROOT_PATH}/Modules >> ${INSPECTION_PATH}/Modules/html_tags.log done diff --git a/Inspection/Logic/module_navigation.sh b/Inspection/Logic/module_navigation.sh deleted file mode 100755 index e69de29..0000000 diff --git a/Inspection/Logic/module_route.sh b/Inspection/Logic/module_route.sh deleted file mode 100755 index e69de29..0000000 diff --git a/Inspection/Php/linting.sh b/Inspection/Php/linting.sh index 3ddd6fd..5bf90b1 100755 --- a/Inspection/Php/linting.sh +++ b/Inspection/Php/linting.sh @@ -7,12 +7,15 @@ echo "Start php linting inspection" echo "#################################################" find ${ROOT_PATH}/phpOMS -name "*.php" | xargs -L1 php -l > ${INSPECTION_PATH}/logs/temp.log -sed '/^No syntax.*/ d' < ${INSPECTION_PATH}/logs/temp.log > ${INSPECTION_PATH}/Framework/linting/linting_php.log +sed '/^No syntax.*/ d' < ${INSPECTION_PATH}/logs/temp.log > ${INSPECTION_PATH}/Framework/linting_php.log find ${ROOT_PATH}/Web -name "*.php" | xargs -L1 php -l > ${INSPECTION_PATH}/logs/temp.log -sed '/^No syntax.*/ d' < ${INSPECTION_PATH}/logs/temp.log > ${INSPECTION_PATH}/Framework/linting/linting_php.log +sed '/^No syntax.*/ d' < ${INSPECTION_PATH}/logs/temp.log > ${INSPECTION_PATH}/Framework/linting_php.log find ${ROOT_PATH}/Modules -name "*.php" | xargs -L1 php -l > ${INSPECTION_PATH}/logs/temp.log -sed '/^No syntax.*/ d' < ${INSPECTION_PATH}/logs/temp.log > ${INSPECTION_PATH}/Modules/linting/linting_php.log +sed '/^No syntax.*/ d' < ${INSPECTION_PATH}/logs/temp.log > ${INSPECTION_PATH}/Modules/linting_php.log + +find ${ROOT_PATH}/Model -name "*.php" | xargs -L1 php -l > ${INSPECTION_PATH}/logs/temp.log +sed '/^No syntax.*/ d' < ${INSPECTION_PATH}/logs/temp.log > ${INSPECTION_PATH}/Model/linting_php.log rm ${INSPECTION_PATH}/logs/temp.log \ No newline at end of file diff --git a/Inspection/Php/stats.sh b/Inspection/Php/stats.sh index 00c290b..d6c2335 100755 --- a/Inspection/Php/stats.sh +++ b/Inspection/Php/stats.sh @@ -10,6 +10,7 @@ echo "#################################################" php ${ROOT_PATH}/vendor/bin/phploc ${ROOT_PATH}/phpOMS/ > ${INSPECTION_PATH}/Framework/phploc.log php ${ROOT_PATH}/vendor/bin/phploc ${ROOT_PATH}/Web/ > ${INSPECTION_PATH}/Web/phploc.log php ${ROOT_PATH}/vendor/bin/phploc ${ROOT_PATH}/Modules/ > ${INSPECTION_PATH}/Modules/phploc.log +php ${ROOT_PATH}/vendor/bin/phploc ${ROOT_PATH}/Model/ > ${INSPECTION_PATH}/Model/phploc.log # php ${ROOT_PATH}/vendor/bin/phpmetrics --report-html=${INSPECTION_PATH}/Framework/metrics/metrics.html ${ROOT_PATH}/phpOMS/ >> ${INSPECTION_PATH}/Framework/build.log diff --git a/Inspection/Php/style.sh b/Inspection/Php/style.sh index c193999..53417c5 100755 --- a/Inspection/Php/style.sh +++ b/Inspection/Php/style.sh @@ -7,11 +7,11 @@ echo "Start php style inspection" echo "#################################################" php ${ROOT_PATH}/vendor/bin/phpcs ${ROOT_PATH}/phpOMS --standard="${BUILD_PATH}/Config/phpcs.xml" -s --report-full=${INSPECTION_PATH}/Framework/phpcs.log --report-junit=${INSPECTION_PATH}/Framework/phpcs.xml -php ${ROOT_PATH}/vendor/bin/phpcs ${ROOT_PATH}/Web --standard="${BUILD_PATH}/Config/phpcs.xml" -s --report-full=${INSPECTION_PATH}/Modules/phpcs.log --report-junit=${INSPECTION_PATH}/Modules/phpcs.xml +php ${ROOT_PATH}/vendor/bin/phpcs ${ROOT_PATH}/Web --standard="${BUILD_PATH}/Config/phpcs.xml" -s --report-full=${INSPECTION_PATH}/Web/phpcs.log --report-junit=${INSPECTION_PATH}/Web/phpcs.xml php ${ROOT_PATH}/vendor/bin/phpcs ${ROOT_PATH}/Modules --standard="${BUILD_PATH}/Config/phpcs.xml" -s --report-full=${INSPECTION_PATH}/Modules/phpcs.log --report-junit=${INSPECTION_PATH}/Modules/phpcs.xml -php ${ROOT_PATH}/vendor/bin/phpcs ${ROOT_PATH} --standard="${BUILD_PATH}/Config/phpcs.xml" -s --report-full=${INSPECTION_PATH}/Test/Php/phpcs.log --report-junit=${INSPECTION_PATH}/Test/Php/junit_phpcs.xml +php ${ROOT_PATH}/vendor/bin/phpcs ${ROOT_PATH}/Model --standard="${BUILD_PATH}/Config/phpcs.xml" -s --report-full=${INSPECTION_PATH}/Model/phpcs.log --report-junit=${INSPECTION_PATH}/Model/phpcs.xml php ${ROOT_PATH}/vendor/bin/rector --dry-run --config ${BUILD_PATH}/Config/rector.php process ${ROOT_PATH}/phpOMS > ${INSPECTION_PATH}/Framework/rector.log php ${ROOT_PATH}/vendor/bin/rector --dry-run --config ${BUILD_PATH}/Config/rector.php process ${ROOT_PATH}/Web > ${INSPECTION_PATH}/Modules/rector.log php ${ROOT_PATH}/vendor/bin/rector --dry-run --config ${BUILD_PATH}/Config/rector.php process ${ROOT_PATH}/Modules > ${INSPECTION_PATH}/Modules/rector.log -php ${ROOT_PATH}/vendor/bin/rector --dry-run --config ${BUILD_PATH}/Config/rector.php process ${ROOT_PATH} > ${INSPECTION_PATH}/Test/Php/rector.log \ No newline at end of file +php ${ROOT_PATH}/vendor/bin/rector --dry-run --config ${BUILD_PATH}/Config/rector.php process ${ROOT_PATH}/Web > ${INSPECTION_PATH}/Web/rector.log \ No newline at end of file diff --git a/Inspection/Php/tests.sh b/Inspection/Php/tests.sh index f49ba4e..f9a7acc 100755 --- a/Inspection/Php/tests.sh +++ b/Inspection/Php/tests.sh @@ -17,7 +17,5 @@ php -d memory_limit=4G ${ROOT_PATH}/vendor/bin/phpstan analyse --autoload-file=$ php -d memory_limit=4G ${ROOT_PATH}/vendor/bin/phpstan analyse --autoload-file=${ROOT_PATH}/phpOMS/Autoloader.php -l 9 -c ${BUILD_PATH}/Config/phpstan.neon ${ROOT_PATH}/Model > ${INSPECTION_PATH}/Model/phpstan.log php -d memory_limit=4G ${ROOT_PATH}/vendor/bin/phpstan analyse --autoload-file=${ROOT_PATH}/phpOMS/Autoloader.php -l 9 -c ${BUILD_PATH}/Config/phpstan.neon ${ROOT_PATH}/Web > ${INSPECTION_PATH}/Web/phpstan.log -php -d memory_limit=4G ${ROOT_PATH}/vendor/bin/phpstan analyse --autoload-file=${ROOT_PATH}/phpOMS/Autoloader.php -l 9 -c ${BUILD_PATH}/Config/phpstan.neon --error-format=json ${ROOT_PATH}/phpOMS > ${INSPECTION_PATH}/Test/Php/phpstan.json - # Cli debugging # php -dzend_extension=xdebug.so -dxdebug.mode=debug -dxdebug.profiler_enable=1 \ No newline at end of file diff --git a/Inspection/inspect.sh b/Inspection/inspect.sh index 74ef2c5..28da244 100755 --- a/Inspection/inspect.sh +++ b/Inspection/inspect.sh @@ -51,6 +51,8 @@ echo "#################################################" echo "Custom html inspection" echo "#################################################" . ${BUILD_PATH}/Inspection/Html/tags.sh +. ${BUILD_PATH}/Inspection/Html/syntax.sh +. ${BUILD_PATH}/Inspection/Html/static_text.sh # Custom php inspections echo "#################################################" @@ -64,6 +66,110 @@ echo "Custom js inspection" echo "#################################################" . ${BUILD_PATH}/Inspection/Js/security.sh +# Build internal test report +echo "#################################################" +echo "Internal test report" +echo "#################################################" + +echo -e "Internal test report" > ${INSPECTION_PATH}/internal_test_report.txt + +echo -e "\n\n#################################################" > ${INSPECTION_PATH}/internal_test_report.txt +echo "Unit test" > ${INSPECTION_PATH}/internal_test_report.txt +echo -e "#################################################\n\n" > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Test/Php/phpunit.log > ${INSPECTION_PATH}/internal_test_report.txt + +echo -e "\n\n#################################################" > ${INSPECTION_PATH}/internal_test_report.txt +echo "Static test" > ${INSPECTION_PATH}/internal_test_report.txt +echo -e "#################################################\n\n" > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Framework/phpstan.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Modules/phpstan.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Model/phpstan.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Web/phpstan.log > ${INSPECTION_PATH}/internal_test_report.txt + +echo -e "\n\n#################################################" > ${INSPECTION_PATH}/internal_test_report.txt +echo "PHP style test" > ${INSPECTION_PATH}/internal_test_report.txt +echo -e "#################################################\n\n" > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Framework/phpcs.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Modules/phpcs.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Model/phpcs.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Web/phpcs.log > ${INSPECTION_PATH}/internal_test_report.txt + +cat ${INSPECTION_PATH}/Framework/rector.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Modules/rector.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Model/rector.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Web/rector.log > ${INSPECTION_PATH}/internal_test_report.txt + +echo -e "\n\n#################################################" > ${INSPECTION_PATH}/internal_test_report.txt +echo "JS style test" > ${INSPECTION_PATH}/internal_test_report.txt +echo -e "#################################################\n\n" > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Framework/eslint.txt > ${INSPECTION_PATH}/internal_test_report.txt + +echo -e "\n\n#################################################" > ${INSPECTION_PATH}/internal_test_report.txt +echo "Stats" > ${INSPECTION_PATH}/internal_test_report.txt +echo -e "#################################################\n\n" > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Framework/phploc.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Modules/phploc.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Model/phploc.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Web/phploc.log > ${INSPECTION_PATH}/internal_test_report.txt + +echo -e "\n\n#################################################" > ${INSPECTION_PATH}/internal_test_report.txt +echo "PHP security tests" > ${INSPECTION_PATH}/internal_test_report.txt +echo -e "#################################################\n\n" > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Framework/critical_php.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Modules/critical_php.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Model/critical_php.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Web/critical_php.log > ${INSPECTION_PATH}/internal_test_report.txt + +cat ${INSPECTION_PATH}/Framework/strict_missing_php.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Modules/strict_missing_php.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Model/strict_missing_php.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Web/strict_missing_php.log > ${INSPECTION_PATH}/internal_test_report.txt + +echo -e "\n\n#################################################" > ${INSPECTION_PATH}/internal_test_report.txt +echo "JS security tests" > ${INSPECTION_PATH}/internal_test_report.txt +echo -e "#################################################\n\n" > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Framework/critical_js.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Modules/critical_js.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Web/critical_js.log > ${INSPECTION_PATH}/internal_test_report.txt + +cat ${INSPECTION_PATH}/Framework/strict_missing_js.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Modules/strict_missing_js.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Model/strict_missing_js.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Web/strict_missing_js.log > ${INSPECTION_PATH}/internal_test_report.txt + +echo -e "\n\n#################################################" > ${INSPECTION_PATH}/internal_test_report.txt +echo "Linting tests" > ${INSPECTION_PATH}/internal_test_report.txt +echo -e "#################################################\n\n" > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Framework/linting_php.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Modules/linting_php.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Model/linting_php.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Web/linting_php.log > ${INSPECTION_PATH}/internal_test_report.txt + +echo -e "\n\n#################################################" > ${INSPECTION_PATH}/internal_test_report.txt +echo "DB queries" > ${INSPECTION_PATH}/internal_test_report.txt +echo -e "#################################################\n\n" > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Sql/slow_queries.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Sql/locked_queries.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Sql/query_details.log > ${INSPECTION_PATH}/internal_test_report.txt + +echo -e "\n\n#################################################" > ${INSPECTION_PATH}/internal_test_report.txt +echo "Html tags" > ${INSPECTION_PATH}/internal_test_report.txt +echo -e "#################################################\n\n" > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Framework/html_tags.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Modules/html_tags.log > ${INSPECTION_PATH}/internal_test_report.txt + +echo -e "\n\n#################################################" > ${INSPECTION_PATH}/internal_test_report.txt +echo "Html syntax" > ${INSPECTION_PATH}/internal_test_report.txt +echo -e "#################################################\n\n" > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Modules/html_syntax.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Web/html_syntax.log > ${INSPECTION_PATH}/internal_test_report.txt + +echo -e "\n\n#################################################" > ${INSPECTION_PATH}/internal_test_report.txt +echo "Static text" > ${INSPECTION_PATH}/internal_test_report.txt +echo -e "#################################################\n\n" > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Modules/static_text.log > ${INSPECTION_PATH}/internal_test_report.txt +cat ${INSPECTION_PATH}/Web/static_text.log > ${INSPECTION_PATH}/internal_test_report.txt + # Build external test report echo "#################################################" echo "Test report" diff --git a/Tools/AutoGpt/GptHelper.php b/Tools/AutoGpt/GptHelper.php deleted file mode 100644 index 0077f21..0000000 --- a/Tools/AutoGpt/GptHelper.php +++ /dev/null @@ -1,146 +0,0 @@ - self::MODEL, - 'max_tokens' => self::MAX_TOKENS, - 'temperature' => self::TEMPERATUR, - 'messages' => [ - [ - 'role' => 'system', - 'content' => $behavior, - ], - [ - 'role' => 'user', - 'content' => $content, - ] - ] - ]; - - $request = new HttpRequest(new HttpUri(self::ENDPOINT)); - $request->header->set('Authorization', 'Bearer ' . self::APIKEY); - $request->header->set('Content-Type', 'application/json'); - $request->setMethod('POST'); - $request->data = $requestBody; - - do { - $time = \time(); - if ($time - self::$lastRun <= (int) (61 / self::LIMIT_REQUEST_PER_MINUTE)) { - \sleep((int) (61 / self::LIMIT_REQUEST_PER_MINUTE - ($time - self::$lastRun)) + 1); - } - - $response = Rest::request($request); - self::$lastRun = \time(); - } while (\stripos($response->getBody(), '"code":502') !== false - || \stripos($response->getBody(), '"code": 502') !== false - || \stripos($response->getBody(), '503 Service') !== false - ); - - return $response->getBody(); - } - - public static function handleFile(string $inPath, string $outPath, string $behavior, Callable $fileReader, bool $bulk = true) : string - { - $response = ''; - - $in = \fopen($inPath, 'r'); - $out = \fopen($outPath . ($inPath === $outPath ? '.out' : ''), 'w'); - $lines = ''; - - while (($line = $fileReader($in, $inPath)) !== false) { - $line = \str_replace(' ', "\t", $line); - if (\strlen($line) > self::MAX_STRLEN) { - continue; - } - - if (!$bulk) { - $lines = $line; - } - - if (!$bulk || \strlen($lines) + \strlen($line) > self::MAX_STRLEN) { - $response = self::aiRequest($behavior, $lines); - - if ($response === '' || $response === false) { - continue; - } - - if(\stripos($outPath, '.php') !== false) { - $response = \str_replace('```', '', $response); - } - - $json = \json_decode($response, true); - \fwrite($out, $json[5][0]['message']['content']); - \fwrite($out, "\n"); - - $lines = ''; - } - - if ($bulk) { - $lines .= $line . "\n"; - } - } - - if (\trim($lines) !== '' && \strlen($lines) <= self::MAX_STRLEN) { - $response = self::aiRequest($behavior, $lines); - - if ($response !== '' && $response !== false) { - if(\stripos($outPath, '.php') !== false) { - $response = \str_replace('```', '', $response); - } - - $json = \json_decode($response, true); - \fwrite($out, $json[5][0]['message']['content']); - \fwrite($out, "\n"); - } - } - - if ($outPath === 'php://memory') { - \rewind($out); - $response = \stream_get_contents($out); - } - - if ($inPath === $outPath) { - if (\ftell($in) === 0 || \ftell($out) / \ftell($in) < 0.9) { - \unlink($outPath . '.out'); - } else { - \unlink($outPath); - \rename($outPath . '.out', $outPath); - } - } - - \fclose($in); - \fclose($out); - - return $response; - } -} diff --git a/Tools/AutoGpt/autoDevDoc.php b/Tools/AutoGpt/autoDevDoc.php deleted file mode 100644 index 93600bc..0000000 --- a/Tools/AutoGpt/autoDevDoc.php +++ /dev/null @@ -1,60 +0,0 @@ - 1300) { - return false; - } - - $lines = ''; - $isFirstLine = true; - - while (($line = \fgets($in)) !== false) { - $isFirstLine = false; - $lines .= $line; - } - - if ($isFirstLine && empty($lines)) { - return false; - } - - return $lines; -}; - -$output = __DIR__ . '/../../../doc.md'; -$md = \fopen($output, 'w'); - -foreach ($globs as $glob) { - $files = \glob($glob); - - foreach ($files as $file) { - if (\stripos($file, 'Test.php')) { - continue; - } - - $response = GptHelper::handleFile($file, 'php://memory', $behaviour, $fileReader); - - if (\trim($response) !== '') { - \fwrite($md, $file . ":\n"); - \fwrite($md, $response); - \fwrite($md, "\n\n"); - } - } -} - -\fclose($md); \ No newline at end of file diff --git a/Tools/AutoGpt/autoDocblock.php b/Tools/AutoGpt/autoDocblock.php deleted file mode 100644 index 10aa2e5..0000000 --- a/Tools/AutoGpt/autoDocblock.php +++ /dev/null @@ -1,67 +0,0 @@ - 1300) { - return false; - } - - $lines = ''; - $isFirstLine = true; - - while (($line = \fgets($in)) !== false) { - $isFirstLine = false; - $lines .= $line; - } - - if ($isFirstLine && empty($lines)) { - return false; - } - - return $lines; -}; - -foreach ($globs as $glob) { - $files = \glob($glob); - - foreach ($files as $file) { - if (\stripos($file, 'Test.php')) { - continue; - } - - GptHelper::handleFile($file, $file, $behaviour, $fileReader); - } -} diff --git a/Tools/AutoGpt/autoOptimization.php b/Tools/AutoGpt/autoOptimization.php deleted file mode 100644 index 67c8fab..0000000 --- a/Tools/AutoGpt/autoOptimization.php +++ /dev/null @@ -1,76 +0,0 @@ -/dev/null +done + +cd ${ROOT_PATH} +git submodule update --init --recursive >/dev/null +git submodule foreach git checkout develop >/dev/null + +echo "#################################################" +echo "Setup build output" +echo "#################################################" + +# Creating directories for inspection +mkdir -p ${INSPECTION_PATH}/logs +mkdir -p ${INSPECTION_PATH}/Framework/logs +mkdir -p ${INSPECTION_PATH}/Framework/metrics +#mkdir -p ${INSPECTION_PATH}/Framework/pdepend +mkdir -p ${INSPECTION_PATH}/Framework/phpcs +mkdir -p ${INSPECTION_PATH}/Framework/phpcpd +mkdir -p ${INSPECTION_PATH}/Framework/linting +mkdir -p ${INSPECTION_PATH}/Framework/html + +mkdir -p ${INSPECTION_PATH}/Modules/logs +mkdir -p ${INSPECTION_PATH}/Modules/metrics +#mkdir -p ${INSPECTION_PATH}/Modules/pdepend +mkdir -p ${INSPECTION_PATH}/Modules/phpcs +mkdir -p ${INSPECTION_PATH}/Modules/phpcpd +mkdir -p ${INSPECTION_PATH}/Modules/linting +mkdir -p ${INSPECTION_PATH}/Modules/html + +mkdir -p ${INSPECTION_PATH}/Web/logs +mkdir -p ${INSPECTION_PATH}/Web/metrics +#mkdir -p ${INSPECTION_PATH}/Web/pdepend +mkdir -p ${INSPECTION_PATH}/Web/phpcs +mkdir -p ${INSPECTION_PATH}/Web/phpcpd +mkdir -p ${INSPECTION_PATH}/Web/linting +mkdir -p ${INSPECTION_PATH}/Web/html + +mkdir -p ${INSPECTION_PATH}/Framework +mkdir -p ${INSPECTION_PATH}/Web +mkdir -p ${INSPECTION_PATH}/Model +mkdir -p ${INSPECTION_PATH}/Modules + +mkdir -p ${INSPECTION_PATH}/Test/Php +mkdir -p ${INSPECTION_PATH}/Test/Js +mkdir -p ${INSPECTION_PATH}/Test/sitespeed + +mkdir -p ${INSPECTION_PATH}/Sql + +# Permission handling +chmod -R 777 ${ROOT_PATH} + +# Setup tools for inspection +mkdir -p ${TOOLS_PATH} + +echo "#################################################" +echo "Setup tools" +echo "#################################################" + +cd ${ROOT_PATH} +composer install +npm install cd ${BUILD_PATH} diff --git a/config.sh b/config.sh index 0981698..2720c29 100755 --- a/config.sh +++ b/config.sh @@ -10,7 +10,7 @@ RELEASE_PATH="/var/www/html/Release" INSPECTION_PATH="/var/www/html/Inspection" # Web -WEB_URL="http://karaka.de" +WEB_URL="http://jingga.app" MAIL_ADDR="" # Authentications @@ -19,7 +19,6 @@ DB_PASSWORD="root" # Git variables GITHUB_URL[0]="https://github.com/Karaka-Management/Karaka.git" -GITHUB_URL[1]="https://github.com/Karaka-Management/Website.git" GIT_BRANCH="develop" diff --git a/setup.sh b/setup.sh deleted file mode 100755 index 7f1ce52..0000000 --- a/setup.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash - -. config.sh - -echo "#################################################" -echo "Remove old setup" -echo "#################################################" - -# Previous cleanup -rm -r -f ${ROOT_PATH} -rm -r -f ${BASE_PATH}/Website -rm -r -f ${BASE_PATH}/phpOMS -rm -r -f ${BASE_PATH}/jsOMS -rm -r -f ${BASE_PATH}/cssOMS -rm -r -f ${TOOLS_PATH} - -rm -r -f ${INSPECTION_PATH} -mkdir -p ${INSPECTION_PATH} - -cd ${BASE_PATH} - -echo "#################################################" -echo "Setup repositories" -echo "#################################################" - -# Create git repositories -for i in "${GITHUB_URL[@]}" -do - git clone -b ${GIT_BRANCH} $i >/dev/null -done - -cd ${BASE_PATH}/Website -git submodule update --init --recursive >/dev/null -git submodule foreach git checkout develop >/dev/null - -cd ${ROOT_PATH} -git submodule update --init --recursive >/dev/null -git submodule foreach git checkout develop >/dev/null - -echo "#################################################" -echo "Setup hooks" -echo "#################################################" - -# Setup hooks -cp ${ROOT_PATH}/Build/Hooks/default.sh ${ROOT_PATH}/.git/hooks/pre-commit -cp ${ROOT_PATH}/Build/Hooks/default.sh ${ROOT_PATH}/.git/modules/Build/hooks/pre-commit -cp ${ROOT_PATH}/Build/Hooks/default.sh ${ROOT_PATH}/.git/modules/phpOMS/hooks/pre-commit -cp ${ROOT_PATH}/Build/Hooks/default.sh ${ROOT_PATH}/.git/modules/jsOMS/hooks/pre-commit -cp ${ROOT_PATH}/Build/Hooks/default.sh ${ROOT_PATH}/.git/modules/cssOMS/hooks/pre-commit - -chmod +x ${ROOT_PATH}/.git/hooks/pre-commit -chmod +x ${ROOT_PATH}/.git/modules/Build/hooks/pre-commit -chmod +x ${ROOT_PATH}/.git/modules/phpOMS/hooks/pre-commit -chmod +x ${ROOT_PATH}/.git/modules/jsOMS/hooks/pre-commit -chmod +x ${ROOT_PATH}/.git/modules/cssOMS/hooks/pre-commit - -echo "#################################################" -echo "Setup build output" -echo "#################################################" - -# Creating directories for inspection -mkdir -p ${INSPECTION_PATH}/logs -mkdir -p ${INSPECTION_PATH}/Framework/logs -mkdir -p ${INSPECTION_PATH}/Framework/metrics -#mkdir -p ${INSPECTION_PATH}/Framework/pdepend -mkdir -p ${INSPECTION_PATH}/Framework/phpcs -mkdir -p ${INSPECTION_PATH}/Framework/phpcpd -mkdir -p ${INSPECTION_PATH}/Framework/linting -mkdir -p ${INSPECTION_PATH}/Framework/html - -mkdir -p ${INSPECTION_PATH}/Modules/logs -mkdir -p ${INSPECTION_PATH}/Modules/metrics -#mkdir -p ${INSPECTION_PATH}/Modules/pdepend -mkdir -p ${INSPECTION_PATH}/Modules/phpcs -mkdir -p ${INSPECTION_PATH}/Modules/phpcpd -mkdir -p ${INSPECTION_PATH}/Modules/linting -mkdir -p ${INSPECTION_PATH}/Modules/html - -mkdir -p ${INSPECTION_PATH}/Web/logs -mkdir -p ${INSPECTION_PATH}/Web/metrics -#mkdir -p ${INSPECTION_PATH}/Web/pdepend -mkdir -p ${INSPECTION_PATH}/Web/phpcs -mkdir -p ${INSPECTION_PATH}/Web/phpcpd -mkdir -p ${INSPECTION_PATH}/Web/linting -mkdir -p ${INSPECTION_PATH}/Web/html - -mkdir -p ${INSPECTION_PATH}/Framework -mkdir -p ${INSPECTION_PATH}/Web -mkdir -p ${INSPECTION_PATH}/Model -mkdir -p ${INSPECTION_PATH}/Modules - -mkdir -p ${INSPECTION_PATH}/Test/Php -mkdir -p ${INSPECTION_PATH}/Test/Js -mkdir -p ${INSPECTION_PATH}/Test/sitespeed - -mkdir -p ${INSPECTION_PATH}/Sql - -# Permission handling -chmod -R 777 ${ROOT_PATH} - -# Setup tools for inspection -mkdir -p ${TOOLS_PATH} - -echo "#################################################" -echo "Setup tools" -echo "#################################################" - -cd ${ROOT_PATH} -composer install -npm install \ No newline at end of file