diff --git a/app/config.example.yml b/app/config.example.yml index 7bb9e501..a9f05ab2 100644 --- a/app/config.example.yml +++ b/app/config.example.yml @@ -1,13 +1,13 @@ b8: - database: - servers: - read: localhost - write: localhost - name: phpci - username: root - password: root + database: + servers: + read: localhost + write: localhost + name: phpci + username: root + password: root phpci: - url: 'http://phpci.local' - worker: - host: localhost - queue: phpci + url: 'http://phpci.local' + worker: + host: localhost + queue: phpci diff --git a/app/phinx.php b/app/phinx.php index 7e6632fb..687b9249 100644 --- a/app/phinx.php +++ b/app/phinx.php @@ -18,7 +18,7 @@ if (!is_array($writeServers)) { $conf = [ 'paths' => [ - 'migrations' => 'PHPCI/Migrations', + 'migrations' => 'src/PHPCI/Migrations', ], 'environments' => [ 'default_migration_table' => 'migration', diff --git a/bin/console b/bin/console index 03fcecd2..c6de3a00 100755 --- a/bin/console +++ b/bin/console @@ -1,5 +1,6 @@ #!/usr/bin/env php config[$key] = $value; + + return true; } /** - * Set an array of values. - */ + * Set an array of values. + */ public function setArray($array) { self::deepMerge($this->config, $array); } /** - * Short-hand syntax for get() - * @see Config::get() - */ + * Short-hand syntax for get() + * @see Config::get() + */ public function __get($key) { return $this->get($key); } /** - * Short-hand syntax for set() - * @see Config::set() - */ + * Short-hand syntax for set() + * @see Config::set() + */ public function __set($key, $value = null) { return $this->set($key, $value); } /** - * Is set - */ + * Is set + */ public function __isset($key) { return isset($this->config[$key]); } /** - * Unset - */ + * Unset + */ public function __unset($key) { unset($this->config[$key]); diff --git a/src/B8Framework/Controller/RestController.php b/src/B8Framework/Controller/RestController.php deleted file mode 100755 index 2164e4a3..00000000 --- a/src/B8Framework/Controller/RestController.php +++ /dev/null @@ -1,224 +0,0 @@ -response->setContent($response); - - return $this->response; - } - - public function setActiveUser(RestUser $user) - { - $this->activeUser = $user; - } - - public function getActiveUser() - { - return $this->activeUser; - } - - public function index() - { - if (!$this->activeUser->checkPermission('canRead', $this->_resourceName)) { - throw new HttpException\ForbiddenException('You do not have permission do this.'); - } - - $this->where = $this->_parseWhere(); - $this->limit = is_null($this->limit) ? $this->getParam('limit', 25) : $this->limit; - $this->offset = is_null($this->offset) ? $this->getParam('offset', 0) : $this->offset; - $this->order = is_null($this->order) || !count($this->order) ? $this->getParam('order', []) : $this->order; - $this->group = is_null($this->group) || !count($this->group) ? $this->getParam('group', null) : $this->group; - $this->searchType = $this->getParam('searchType', self::SEARCHTYPE_AND); - - $store = Factory::getStore($this->_modelName); - $data = $store->getWhere($this->where, $this->limit, $this->offset, $this->joins, $this->order, - $this->manualJoins, $this->group, $this->manualWheres, $this->searchType); - - $rtn = [ - 'debug' => [ - 'where' => $this->where, - 'searchType' => $this->searchType, - ], - 'limit' => $this->limit, - 'offset' => $this->offset, - 'total' => $data['count'], - 'items' => [] - ]; - - foreach ($data['items'] as $item) { - $rtn['items'][] = $item->toArray($this->arrayDepth); - } - - return $rtn; - } - - /** - * - */ - protected function _parseWhere() - { - $clauses = [ - 'fuzzy' => 'like', - 'gt' => '>', - 'gte' => '>=', - 'lt' => '<', - 'lte' => '<=', - 'neq' => '!=', - 'between' => 'between', - ]; - - $where = $this->getParam('where', []); - $where = array_merge($where, $this->where); - - if (count($where)) { - foreach ($where as &$value) { - if (!is_array($value) || !isset($value['operator'])) { - if (is_array($value) && count($value) == 1) { - $value = array_shift($value); - } - - $value = [ - 'operator' => '=', - 'value' => $value, - ]; - } - } - - foreach ($clauses as $clause => $operator) { - $fields = $this->getParam($clause, []); - - if (count($clause)) { - if (!is_array($fields)) { - $fields = [$fields]; - } - foreach ($fields as $field) { - if (isset($where[$field])) { - $where[$field]['operator'] = $operator; - if ($operator == 'like') { - $where[$field]['value'] = str_replace(' ', '%', $where[$field]['value']); - } - } - } - } - } - } - - return $where; - } - - public function get($key) - { - if (!$this->activeUser->checkPermission('canRead', $this->_resourceName)) { - throw new HttpException\ForbiddenException('You do not have permission do this.'); - } - - $rtn = Factory::getStore($this->_modelName)->getByPrimaryKey($key); - - if (is_object($rtn) && method_exists($rtn, 'toArray')) { - $rtn = $rtn->toArray($this->arrayDepth); - } - - return [strtolower($this->_modelName) => $rtn]; - } - - public function put($key) - { - if (!$this->activeUser->checkPermission('canEdit', $this->_resourceName)) { - throw new HttpException\ForbiddenException('You do not have permission do this.'); - } - - $store = Factory::getStore($this->_modelName); - - if ($obj = $store->getByPrimaryKey($key)) { - $obj->setValues($this->getParams()); - $rtn = $store->save($obj); - - return [strtolower($this->_modelName) => $rtn->toArray($this->arrayDepth)]; - } else { - return null; - } - } - - public function post() - { - if (!$this->activeUser->checkPermission('canCreate', $this->_resourceName)) { - throw new HttpException\ForbiddenException('You do not have permission do this.'); - } - - $store = Factory::getStore($this->_modelName); - - $modelClass = $this->_modelClass; - $obj = new $modelClass(); - $obj->setValues($this->getParams()); - $rtn = $store->save($obj); - - return [strtolower($this->_modelName) => $rtn->toArray($this->arrayDepth)]; - } - - public function delete($key) - { - if (!$this->activeUser->checkPermission('canDelete', $this->_resourceName)) { - throw new HttpException\ForbiddenException('You do not have permission do this.'); - } - - $store = Factory::getStore($this->_modelName); - - try { - if ($obj = $store->getByPrimaryKey($key)) { - $store->delete($obj); - return ['deleted' => true]; - } - } catch (\Exception $ex) { - } - - return ['deleted' => false]; - } -} \ No newline at end of file diff --git a/src/B8Framework/Database/Map.php b/src/B8Framework/Database/Map.php index 8fe6e217..a9ef5374 100755 --- a/src/B8Framework/Database/Map.php +++ b/src/B8Framework/Database/Map.php @@ -255,4 +255,4 @@ class Map return $fkMethod; } -} \ No newline at end of file +} diff --git a/src/B8Framework/Http/Response.php b/src/B8Framework/Http/Response.php index 44676f0d..e27e2047 100755 --- a/src/B8Framework/Http/Response.php +++ b/src/B8Framework/Http/Response.php @@ -128,4 +128,4 @@ class Response { return $this->flush(); } -} \ No newline at end of file +} diff --git a/src/B8Framework/Http/Router.php b/src/B8Framework/Http/Router.php index 481d3fce..256db752 100755 --- a/src/B8Framework/Http/Router.php +++ b/src/B8Framework/Http/Router.php @@ -2,8 +2,7 @@ namespace b8\Http; -use b8\Application; -use b8\Config; +use b8\Application, b8\Config; class Router { diff --git a/src/B8Framework/View/UserView.php b/src/B8Framework/View/UserView.php deleted file mode 100755 index 541606c1..00000000 --- a/src/B8Framework/View/UserView.php +++ /dev/null @@ -1,12 +0,0 @@ -setName('phpci:install') ->addOption('url', null, InputOption::VALUE_OPTIONAL, Lang::get('installation_url')) ->addOption('db-host', null, InputOption::VALUE_OPTIONAL, Lang::get('db_host')) + ->addOption('db-port', null, InputOption::VALUE_OPTIONAL, Lang::get('db_port')) ->addOption('db-name', null, InputOption::VALUE_OPTIONAL, Lang::get('db_name')) ->addOption('db-user', null, InputOption::VALUE_OPTIONAL, Lang::get('db_user')) ->addOption('db-pass', null, InputOption::VALUE_OPTIONAL, Lang::get('db_pass')) @@ -293,6 +294,10 @@ class InstallCommand extends Command $dbHost = $dialog->ask($output, Lang::get('enter_db_host'), 'localhost'); } + if (!$dbPort = $input->getOption('db-port')) { + $dbPort = $dialog->ask($output, Lang::get('enter_db_port'), '3306'); + } + if (!$dbName = $input->getOption('db-name')) { $dbName = $dialog->ask($output, Lang::get('enter_db_name'), 'phpci'); } @@ -305,11 +310,12 @@ class InstallCommand extends Command $dbPass = $dialog->askHiddenResponse($output, Lang::get('enter_db_pass')); } - $db['servers']['read'] = $dbHost; + $db['servers']['read'] = $dbHost; $db['servers']['write'] = $dbHost; - $db['name'] = $dbName; - $db['username'] = $dbUser; - $db['password'] = $dbPass; + $db['port'] = $dbPort; + $db['name'] = $dbName; + $db['username'] = $dbUser; + $db['password'] = $dbPass; return $db; } @@ -324,7 +330,7 @@ class InstallCommand extends Command { try { $pdo = new PDO( - 'mysql:host='.$db['servers']['write'].';dbname='.$db['name'], + 'mysql:host='.$db['servers']['write'].';port='.$db['port'].'dbname='.$db['name'], $db['username'], $db['password'], [ diff --git a/src/PHPCI/Controller/ProjectController.php b/src/PHPCI/Controller/ProjectController.php index 51fa421a..a5a4358b 100644 --- a/src/PHPCI/Controller/ProjectController.php +++ b/src/PHPCI/Controller/ProjectController.php @@ -258,7 +258,7 @@ class ProjectController extends PHPCI\Controller if ($values['type'] == "gitlab") { $accessInfo = $project->getAccessInformation(); - $reference = $accessInfo["user"].'@'.$accessInfo["domain"].':' . $project->getReference().".git"; + $reference = $accessInfo["user"].'@'.$accessInfo["domain"].':' . $accessInfo["port"] . '/' . ltrim($project->getReference(), '/') . ".git"; $values['reference'] = $reference; } diff --git a/src/PHPCI/Controller/WebhookController.php b/src/PHPCI/Controller/WebhookController.php index 667b35fa..77a45b4b 100644 --- a/src/PHPCI/Controller/WebhookController.php +++ b/src/PHPCI/Controller/WebhookController.php @@ -293,7 +293,14 @@ class WebhookController extends \b8\Controller $url = $payload['pull_request']['commits_url']; $http = new \b8\HttpClient(); $http->setHeaders($headers); - $response = $http->get($url); + + //for large pull requests, allow grabbing more then the default number of commits + $custom_per_page = \b8\Config::getInstance()->get('phpci.github.per_page'); + $params = []; + if ($custom_per_page) { + $params["per_page"] = $custom_per_page; + } + $response = $http->get($url, $params); // Check we got a success response: if (!$response['success']) { diff --git a/src/PHPCI/Helper/Lang.php b/src/PHPCI/Helper/Lang.php index d829f83a..bff0f458 100644 --- a/src/PHPCI/Helper/Lang.php +++ b/src/PHPCI/Helper/Lang.php @@ -88,7 +88,7 @@ class Lang { if (in_array($language, self::$languages)) { self::$language = $language; - self::$strings = self::loadLanguage(); + self::$strings = self::loadLanguage(); return true; } @@ -177,12 +177,11 @@ class Lang return null; } - $strings = include_once($langFile); - + $strings = include($langFile); if (is_null($strings) || !is_array($strings) || !count($strings)) { return null; } - + return $strings; } diff --git a/src/PHPCI/Languages/lang.en.php b/src/PHPCI/Languages/lang.en.php index 9dff9b22..530f022d 100644 --- a/src/PHPCI/Languages/lang.en.php +++ b/src/PHPCI/Languages/lang.en.php @@ -349,6 +349,7 @@ PHPCI', 'enter_phpci_url' => 'Your PHPCI URL ("http://phpci.local" for example): ', 'enter_db_host' => 'Please enter your MySQL host [localhost]: ', + 'enter_db_port' => 'Please enter your MySQL port [3306]: ', 'enter_db_name' => 'Please enter your MySQL database name [phpci]: ', 'enter_db_user' => 'Please enter your MySQL username [phpci]: ', 'enter_db_pass' => 'Please enter your MySQL password: ', @@ -449,6 +450,4 @@ PHPCI', 'php_unit' => 'PHP Unit', 'php_cpd' => 'PHP Copy/Paste Detector', 'php_docblock_checker' => 'PHP Docblock Checker', - 'behat' => 'Behat', - 'technical_debt' => 'Technical Debt', ]; diff --git a/src/PHPCI/Languages/lang.fr.php b/src/PHPCI/Languages/lang.fr.php index 2950a80f..11798e47 100644 --- a/src/PHPCI/Languages/lang.fr.php +++ b/src/PHPCI/Languages/lang.fr.php @@ -152,6 +152,9 @@ PHPCI', Services de votre dépôt Bitbucket.', + 'errors' => 'Erreurs', + 'information' => 'Informations', + // View Build 'build_x_not_found' => 'Le Build avec l\'ID %d n\'existe pas.', 'build_n' => 'Build %d', @@ -187,6 +190,7 @@ PHPCI', 'phpmd' => 'PHP Mess Detector', 'phpspec' => 'PHP Spec', 'phpunit' => 'PHP Unit', + 'behat' => 'Behat', 'file' => 'Fichier', 'line' => 'Ligne', @@ -406,5 +410,11 @@ PHPCI', 'build_file_missing' => 'Le fichier de build spécifié n\'existe pas.', 'property_file_missing' => 'Le fichier de propriété spécifié n\'existe pas.', 'could_not_process_report' => 'Impossible de traiter le rapport généré par cet outil.', - 'shell_not_enabled' => 'Le plugn shell n\'est pas activé. Merci de l\'activer via le fichier config.yml.' + 'shell_not_enabled' => 'Le plugn shell n\'est pas activé. Merci de l\'activer via le fichier config.yml.', + + // Error Levels: + 'critical' => 'Critique', + 'high' => 'Haut', + 'normal' => 'Normal', + 'low' => 'Base', ]; diff --git a/src/PHPCI/Languages/lang.ru.php b/src/PHPCI/Languages/lang.ru.php index fcd223fc..c54a3f61 100644 --- a/src/PHPCI/Languages/lang.ru.php +++ b/src/PHPCI/Languages/lang.ru.php @@ -158,6 +158,8 @@ PHPCI', 'group_save' => 'Сохранить группу', // View Build + 'errors' => 'Ошибки', + 'information' => 'Информация', 'build_x_not_found' => 'Сборки с ID %d не существует.', 'build_n' => 'Сборка %d', 'rebuild_now' => 'Пересобрать сейчас', @@ -215,8 +217,8 @@ PHPCI', 'build_created' => 'Сборка создана', 'build_started' => 'Сборка запущена', 'build_finished' => 'Сборка окончена', - 'test_message' => 'Message', - 'test_no_message' => 'No message', + 'test_message' => 'Сообщение', + 'test_no_message' => 'Нет сообщений', 'test_success' => 'Успешно: %d', 'test_fail' => 'Провалено: %d', 'test_skipped' => 'Пропущено: %d', @@ -336,6 +338,7 @@ PHPCI', 'enter_phpci_url' => 'URL-адрес вашего PHPCI (например: "http://phpci.local"): ', 'enter_db_host' => 'Пожалуйста, введите хост MySQL [localhost]: ', + 'enter_db_port' => 'Пожалуйста, введите порт MySQL [3306]: ', 'enter_db_name' => 'Пожалуйста, введите имя базы данных MySQL [phpci]: ', 'enter_db_user' => 'Пожалуйста, введите пользователя MySQL [phpci]: ', 'enter_db_pass' => 'Пожалуйста, введите пароль MySQL: ', @@ -418,5 +421,18 @@ PHPCI', 'build_file_missing' => 'Указанного файла сборки не существует.', 'property_file_missing' => 'Указанного файла сборки не существует.', 'could_not_process_report' => 'Невозможно обработать отчет этой утилиты.', - 'shell_not_enabled' => 'Плагин shell не включен. Пожалуйста, включите его в файле config.yml.' + 'shell_not_enabled' => 'Плагин shell не включен. Пожалуйста, включите его в файле config.yml.', + + // Error Levels: + 'critical' => 'Критичный', + 'high' => 'Высокий', + 'normal' => 'Нормальный', + 'low' => 'Низкий', + + // Plugins that generate errors: + 'php_mess_detector' => 'PHP Mess Detector', + 'php_code_sniffer' => 'PHP Code Sniffer', + 'php_unit' => 'PHP Unit', + 'php_cpd' => 'PHP Copy/Paste Detector', + 'php_docblock_checker' => 'PHP Docblock Checker', ]; diff --git a/src/PHPCI/Migrations/20140730143702_fix_database_columns.php b/src/PHPCI/Migrations/20140730143702_fix_database_columns.php index 355aa0de..621e2fb6 100644 --- a/src/PHPCI/Migrations/20140730143702_fix_database_columns.php +++ b/src/PHPCI/Migrations/20140730143702_fix_database_columns.php @@ -20,7 +20,7 @@ class FixDatabaseColumns extends AbstractMigration $build->changeColumn('project_id', 'integer', ['null' => false]); $build->changeColumn('commit_id', 'string', ['limit' => 50, 'null' => false]); $build->changeColumn('status', 'integer', ['null' => false]); - $build->changeColumn('log', 'text', ['null' => true, 'default' => '']); + $build->changeColumn('log', 'text', ['null' => true]); $build->changeColumn('branch', 'string', ['limit' => 50, 'null' => false, 'default' => 'master']); $build->changeColumn('created', 'datetime', ['null' => true]); $build->changeColumn('started', 'datetime', ['null' => true]); diff --git a/src/PHPCI/Migrations/20150131075425_archive_project.php b/src/PHPCI/Migrations/20150131075425_archive_project.php index 796fd48b..f1c0b39b 100644 --- a/src/PHPCI/Migrations/20150131075425_archive_project.php +++ b/src/PHPCI/Migrations/20150131075425_archive_project.php @@ -10,7 +10,7 @@ class ArchiveProject extends AbstractMigration public function up() { $project = $this->table('project'); - $project->addColumn('archived', 'boolean'); + $project->addColumn('archived', 'boolean', ['default' => 0]); $project->save(); } diff --git a/src/PHPCI/Migrations/20150203105015_fix_column_types.php b/src/PHPCI/Migrations/20150203105015_fix_column_types.php index 98ef3403..2c873b11 100644 --- a/src/PHPCI/Migrations/20150203105015_fix_column_types.php +++ b/src/PHPCI/Migrations/20150203105015_fix_column_types.php @@ -13,9 +13,8 @@ class FixColumnTypes extends AbstractMigration // Update the build log column to MEDIUMTEXT: $build = $this->table('build'); $build->changeColumn('log', 'text', [ - 'null' => true, - 'default' => '', - 'limit' => MysqlAdapter::TEXT_MEDIUM, + 'null' => true, + 'limit' => MysqlAdapter::TEXT_MEDIUM, ]); // Update the build meta value column to MEDIUMTEXT: diff --git a/src/PHPCI/Migrations/20151015124825_convert_errors.php b/src/PHPCI/Migrations/20151015124825_convert_errors.php index 3622bf14..69303da0 100644 --- a/src/PHPCI/Migrations/20151015124825_convert_errors.php +++ b/src/PHPCI/Migrations/20151015124825_convert_errors.php @@ -47,7 +47,7 @@ class ConvertErrors extends AbstractMigration $this->processPhpCpdMeta($meta); break; - case 'technicaldebt-data': + case 'technical_debt-data': $this->processTechnicalDebtMeta($meta); break; } diff --git a/src/PHPCI/Migrations/20160425162114_branch_column_length.php b/src/PHPCI/Migrations/20160425162114_branch_column_length.php new file mode 100644 index 00000000..2dfa2292 --- /dev/null +++ b/src/PHPCI/Migrations/20160425162114_branch_column_length.php @@ -0,0 +1,24 @@ +table('build'); + $table->changeColumn('branch', 'string', ['limit' => 250, 'null' => false, 'default' => 'master']); + + $table = $this->table('project'); + $table->changeColumn('branch', 'string', ['limit' => 250, 'null' => false, 'default' => 'master']); + } + + public function down() + { + $table = $this->table('build'); + $table->changeColumn('branch', 'string', ['limit' => 50, 'null' => false, 'default' => 'master']); + + $table = $this->table('project'); + $table->changeColumn('branch', 'string', ['limit' => 50, 'null' => false, 'default' => 'master']); + } +} diff --git a/src/PHPCI/Model/Base/BuildBase.php b/src/PHPCI/Model/Base/BuildBase.php index 047026c7..7cb8e55c 100644 --- a/src/PHPCI/Model/Base/BuildBase.php +++ b/src/PHPCI/Model/Base/BuildBase.php @@ -124,7 +124,7 @@ class BuildBase extends Model ], 'branch' => [ 'type' => 'varchar', - 'length' => 50, + 'length' => 250, 'default' => 'master', ], 'created' => [ diff --git a/src/PHPCI/Model/Base/ProjectBase.php b/src/PHPCI/Model/Base/ProjectBase.php index 6930c6bd..6cb81a8d 100644 --- a/src/PHPCI/Model/Base/ProjectBase.php +++ b/src/PHPCI/Model/Base/ProjectBase.php @@ -115,7 +115,7 @@ class ProjectBase extends Model ], 'branch' => [ 'type' => 'varchar', - 'length' => 50, + 'length' => 250, 'default' => 'master', ], 'ssh_private_key' => [ diff --git a/src/PHPCI/Plugin/Composer.php b/src/PHPCI/Plugin/Composer.php index 32b2e399..e85828fd 100644 --- a/src/PHPCI/Plugin/Composer.php +++ b/src/PHPCI/Plugin/Composer.php @@ -28,6 +28,8 @@ class Composer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin protected $phpci; protected $build; protected $nodev; + protected $ignorePlatformReqs; + protected $preferSource; /** * Check if this plugin can be executed. @@ -55,14 +57,15 @@ class Composer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin */ public function __construct(Builder $phpci, Build $build, array $options = []) { - $path = $phpci->buildPath; - $this->phpci = $phpci; - $this->build = $build; - $this->directory = $path; - $this->action = 'install'; - $this->preferDist = false; - $this->preferSource = false; - $this->nodev = false; + $path = $phpci->buildPath; + $this->phpci = $phpci; + $this->build = $build; + $this->directory = $path; + $this->action = 'install'; + $this->preferDist = false; + $this->preferSource = false; + $this->nodev = false; + $this->ignorePlatformReqs = false; if (array_key_exists('directory', $options)) { $this->directory = $path . DIRECTORY_SEPARATOR . $options['directory']; @@ -84,6 +87,10 @@ class Composer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin if (array_key_exists('no_dev', $options)) { $this->nodev = (bool)$options['no_dev']; } + + if (array_key_exists('ignore_platform_reqs', $options)) { + $this->ignorePlatformReqs = (bool)$options['ignore_platform_reqs']; + } } /** @@ -116,6 +123,11 @@ class Composer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin $cmd .= ' --no-dev'; } + if ($this->ignorePlatformReqs) { + $this->phpci->log('Using --ignore-platform-reqs flag'); + $cmd .= ' --ignore-platform-reqs'; + } + $cmd .= ' --working-dir="%s" %s'; return $this->phpci->executeCommand($cmd, $this->directory, $this->action); diff --git a/src/PHPCI/Plugin/Mysql.php b/src/PHPCI/Plugin/Mysql.php index 816e34f8..dd110108 100644 --- a/src/PHPCI/Plugin/Mysql.php +++ b/src/PHPCI/Plugin/Mysql.php @@ -146,8 +146,10 @@ class Mysql implements \PHPCI\Plugin /** * Builds the MySQL import command required to import/execute the specified file + * * @param string $import_file Path to file, relative to the build root * @param string $database If specified, this database is selected before execution + * * @return string */ protected function getImportCommand($import_file, $database = null) @@ -168,9 +170,10 @@ class Mysql implements \PHPCI\Plugin ':decomp_cmd' => $decomp_cmd, ':host' => escapeshellarg($this->host), ':user' => escapeshellarg($this->user), - ':pass' => escapeshellarg($this->pass), + ':pass' => (!$this->pass) ? '' : '-p' . escapeshellarg($this->pass), ':database' => ($database === null)? '': escapeshellarg($database), ]; - return strtr('cat :import_file :decomp_cmd | mysql -h:host -u:user -p:pass :database', $args); + + return strtr('cat :import_file :decomp_cmd | mysql -h:host -u:user :pass :database', $args); } } diff --git a/src/PHPCI/Plugin/Util/TestResultParsers/Codeception.php b/src/PHPCI/Plugin/Util/TestResultParsers/Codeception.php index efed1833..f3ee801c 100644 --- a/src/PHPCI/Plugin/Util/TestResultParsers/Codeception.php +++ b/src/PHPCI/Plugin/Util/TestResultParsers/Codeception.php @@ -28,7 +28,7 @@ class Codeception implements ParserInterface */ public function __construct(Builder $phpci, $resultsXml) { - $this->phpci = $phpci; + $this->phpci = $phpci; $this->resultsXml = $resultsXml; $this->totalTests = 0; } @@ -38,44 +38,43 @@ class Codeception implements ParserInterface */ public function parse() { - $rtn = []; - + $rtn = []; $this->results = new \SimpleXMLElement($this->resultsXml); // calculate total results - foreach ($this->results->testsuite as $testsuite) { - $this->totalTests += (int) $testsuite['tests']; - $this->totalTimeTaken += (float) $testsuite['time']; - $this->totalFailures += (int) $testsuite['failures']; - $this->totalErrors += (int) $testsuite['errors']; + foreach ($this->results->testsuite as $test_suite) { + $this->totalTests += (int)$test_suite['tests']; + $this->totalTimeTaken += (float)$test_suite['time']; + $this->totalFailures += (int)$test_suite['failures']; + $this->totalErrors += (int)$test_suite['errors']; - foreach ($testsuite->testcase as $testcase) { - $testresult = [ - 'suite' => (string) $testsuite['name'], - 'file' => str_replace($this->phpci->buildPath, '/', (string) $testcase['file']), - 'name' => (string) $testcase['name'], - 'feature' => (string) $testcase['feature'], - 'assertions' => (int) $testcase['assertions'], - 'time' => (float) $testcase['time'] + foreach ($test_suite->testcase as $test_case) { + $test_result = [ + 'suite' => (string)$test_suite['name'], + 'file' => str_replace($this->phpci->buildPath, '/', (string) $test_case['file']), + 'name' => (string)$test_case['name'], + 'feature' => (string)$test_case['feature'], + 'assertions' => (int)$test_case['assertions'], + 'time' => (float)$test_case['time'] ]; - if (isset($testcase['class'])) { - $testresult['class'] = (string) $testcase['class']; + if (isset($test_case['class'])) { + $test_result['class'] = (string) $test_case['class']; } // PHPUnit testcases does not have feature field. Use class::method instead - if (!$testresult['feature']) { - $testresult['feature'] = sprintf('%s::%s', $testresult['class'], $testresult['name']); + if (!$test_result['feature']) { + $test_result['feature'] = sprintf('%s::%s', $test_result['class'], $test_result['name']); } - if (isset($testcase->failure) || isset($testcase->error)) { - $testresult['pass'] = false; - $testresult['message'] = (string)$testcase->failure . (string)$testcase->error; + if (isset($test_case->failure) || isset($test_case->error)) { + $test_result['pass'] = false; + $test_result['message'] = isset($test_case->failure) ? (string)$test_case->failure : (string)$test_case->error; } else { - $testresult['pass'] = true; + $test_result['pass'] = true; } - $rtn[] = $testresult; + $rtn[] = $test_result; } } diff --git a/src/PHPCI/Store/BuildMetaStore.php b/src/PHPCI/Store/BuildMetaStore.php index 6d9f0293..019b44fd 100644 --- a/src/PHPCI/Store/BuildMetaStore.php +++ b/src/PHPCI/Store/BuildMetaStore.php @@ -28,7 +28,7 @@ class BuildMetaStore extends BuildMetaStoreBase public function getErrorsForUpgrade($limit) { $query = 'SELECT * FROM build_meta - WHERE meta_key IN (\'phpmd-data\', \'phpcs-data\', \'phpdoccheck-data\') + WHERE meta_key IN (\'phpmd-data\', \'phpcs-data\', \'phpdoccheck-data\', \'technical_debt - data\') ORDER BY id ASC LIMIT :limit'; $stmt = Database::getConnection('read')->prepare($query);