From 86478a126456bdacf49896d5a431595e83d55587 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Wed, 11 Jan 2017 22:15:54 +0700 Subject: [PATCH] Fixes for build without config --- bin/console | 3 + bootstrap.php | 4 +- runtime/builds/.gitkeep | 0 src/PHPCensor/Builder.php | 2 +- src/PHPCensor/ErrorHandler.php | 68 ------------------- src/PHPCensor/Logging/BuildLogger.php | 1 + src/PHPCensor/Logging/LoggerConfig.php | 3 +- src/PHPCensor/Model/Build.php | 9 ++- src/PHPCensor/Plugin.php | 8 +++ src/PHPCensor/Plugin/Atoum.php | 8 +++ src/PHPCensor/Plugin/Behat.php | 8 +++ src/PHPCensor/Plugin/Campfire.php | 8 +++ src/PHPCensor/Plugin/CleanBuild.php | 8 +++ src/PHPCensor/Plugin/Codeception.php | 8 +++ src/PHPCensor/Plugin/Composer.php | 8 +++ src/PHPCensor/Plugin/CopyBuild.php | 8 +++ src/PHPCensor/Plugin/Deployer.php | 8 +++ src/PHPCensor/Plugin/Email.php | 8 +++ src/PHPCensor/Plugin/Env.php | 8 +++ src/PHPCensor/Plugin/FlowdockNotify.php | 8 +++ src/PHPCensor/Plugin/Git.php | 8 +++ src/PHPCensor/Plugin/Grunt.php | 8 +++ src/PHPCensor/Plugin/Gulp.php | 8 +++ src/PHPCensor/Plugin/HipchatNotify.php | 8 +++ src/PHPCensor/Plugin/Irc.php | 8 +++ src/PHPCensor/Plugin/Lint.php | 8 +++ src/PHPCensor/Plugin/Mysql.php | 8 +++ src/PHPCensor/Plugin/PackageBuild.php | 8 +++ src/PHPCensor/Plugin/Pdepend.php | 8 +++ src/PHPCensor/Plugin/Pgsql.php | 8 +++ src/PHPCensor/Plugin/Phar.php | 8 +++ src/PHPCensor/Plugin/Phing.php | 9 ++- src/PHPCensor/Plugin/PhpCodeSniffer.php | 8 +++ src/PHPCensor/Plugin/PhpCpd.php | 8 +++ src/PHPCensor/Plugin/PhpCsFixer.php | 8 +++ src/PHPCensor/Plugin/PhpDocblockChecker.php | 8 +++ src/PHPCensor/Plugin/PhpLoc.php | 8 +++ src/PHPCensor/Plugin/PhpMessDetector.php | 8 +++ src/PHPCensor/Plugin/PhpParallelLint.php | 8 +++ src/PHPCensor/Plugin/PhpSpec.php | 8 +++ src/PHPCensor/Plugin/PhpTalLint.php | 8 +++ src/PHPCensor/Plugin/PhpUnit.php | 8 +++ src/PHPCensor/Plugin/Shell.php | 8 +++ src/PHPCensor/Plugin/SlackNotify.php | 8 +++ src/PHPCensor/Plugin/Sqlite.php | 8 +++ src/PHPCensor/Plugin/TechnicalDebt.php | 8 +++ src/PHPCensor/Plugin/Wipe.php | 8 +++ src/PHPCensor/Plugin/Xmpp.php | 8 +++ tests/B8Framework/ViewTest.php | 2 +- tests/PHPCensor/Plugin/Util/FactoryTest.php | 4 +- .../Plugin/Util/Fake/ExamplePluginFull.php | 12 +++- .../ExamplePluginWithNoConstructorArgs.php | 8 +++ .../ExamplePluginWithSingleOptionalArg.php | 8 +++ .../ExamplePluginWithSingleRequiredArg.php | 7 ++ ...xamplePluginWithSingleTypedRequiredArg.php | 7 ++ tests/bootstrap.php | 2 - 56 files changed, 376 insertions(+), 85 deletions(-) delete mode 100644 runtime/builds/.gitkeep delete mode 100644 src/PHPCensor/ErrorHandler.php diff --git a/bin/console b/bin/console index 9360d461..d5f99b18 100755 --- a/bin/console +++ b/bin/console @@ -24,6 +24,9 @@ use PHPCensor\Console\Application; define('IS_CONSOLE', true); +error_reporting(-1); +ini_set('display_errors', 1); + require_once(dirname(__DIR__) . '/bootstrap.php'); $application = new Application(); diff --git a/bootstrap.php b/bootstrap.php index 27087f69..35bbf1d0 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -39,8 +39,6 @@ if (!defined('IS_WIN')) { require_once(ROOT_DIR . 'vendor/autoload.php'); -\PHPCensor\ErrorHandler::register(); - if (defined('IS_CONSOLE') && IS_CONSOLE) { $loggerConfig = LoggerConfig::newFromFile(APP_DIR . "loggerconfig.php"); } @@ -66,4 +64,4 @@ if (!defined('IS_CONSOLE')) { define('IS_CONSOLE', false); } -\PHPCensor\Helper\Lang::init($config); +\PHPCensor\Helper\Lang::init($config, 'ru'); diff --git a/runtime/builds/.gitkeep b/runtime/builds/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/src/PHPCensor/Builder.php b/src/PHPCensor/Builder.php index 18c0c5fe..0d564c32 100644 --- a/src/PHPCensor/Builder.php +++ b/src/PHPCensor/Builder.php @@ -231,7 +231,7 @@ class Builder implements LoggerAwareInterface } } catch (\Exception $ex) { $this->build->setStatus(Build::STATUS_FAILED); - $this->buildLogger->logFailure(Lang::get('exception') . $ex->getMessage()); + $this->buildLogger->logFailure(Lang::get('exception') . $ex->getMessage(), $ex); } if (Build::STATUS_FAILED === $this->build->getStatus()) { diff --git a/src/PHPCensor/ErrorHandler.php b/src/PHPCensor/ErrorHandler.php deleted file mode 100644 index 285fcaa6..00000000 --- a/src/PHPCensor/ErrorHandler.php +++ /dev/null @@ -1,68 +0,0 @@ - 'Warning', - E_NOTICE => 'Notice', - E_USER_ERROR => 'User Error', - E_USER_WARNING => 'User Warning', - E_USER_NOTICE => 'User Notice', - E_STRICT => 'Runtime Notice', - E_RECOVERABLE_ERROR => 'Catchable Fatal Error', - E_DEPRECATED => 'Deprecated', - E_USER_DEPRECATED => 'User Deprecated', - ]; - - /** - * Registers an instance of the error handler to throw ErrorException. - */ - public static function register() - { - $handler = new static(); - set_error_handler([$handler, 'handleError']); - } - - /** - * @param integer $level - * @param string $message - * @param string $file - * @param integer $line - * - * @throws \ErrorException - * - * @internal - */ - public function handleError($level, $message, $file, $line) - { - if (error_reporting() & $level === 0) { - return; - } - - $exceptionLevel = isset($this->levels[$level]) ? $this->levels[$level] : $level; - throw new \ErrorException( - sprintf('%s: %s in %s line %d', $exceptionLevel, $message, $file, $line), - 0, - $level, - $file, - $line - ); - } -} diff --git a/src/PHPCensor/Logging/BuildLogger.php b/src/PHPCensor/Logging/BuildLogger.php index 459e422b..ac9efee0 100644 --- a/src/PHPCensor/Logging/BuildLogger.php +++ b/src/PHPCensor/Logging/BuildLogger.php @@ -89,6 +89,7 @@ class BuildLogger implements LoggerAwareInterface // as the exception key in the context array. if ($exception) { $context['exception'] = $exception; + $context['trace'] = $exception->getTrace(); } $this->log("\033[0;31m" . $message . "\033[0m", LogLevel::ERROR, $context); diff --git a/src/PHPCensor/Logging/LoggerConfig.php b/src/PHPCensor/Logging/LoggerConfig.php index cdefc25a..ece13b9e 100644 --- a/src/PHPCensor/Logging/LoggerConfig.php +++ b/src/PHPCensor/Logging/LoggerConfig.php @@ -9,7 +9,6 @@ namespace PHPCensor\Logging; -use Monolog\ErrorHandler; use Monolog\Logger; /** @@ -68,7 +67,7 @@ class LoggerConfig } $logger = new Logger($name, $handlers); - ErrorHandler::register($logger); + Handler::register($logger); $this->cache[$name] = $logger; return $logger; diff --git a/src/PHPCensor/Model/Build.php b/src/PHPCensor/Model/Build.php index 58a7eaba..888e8308 100644 --- a/src/PHPCensor/Model/Build.php +++ b/src/PHPCensor/Model/Build.php @@ -110,8 +110,11 @@ class Build extends BuildBase } } - $yamlParser = new YamlParser(); - $build_config = $yamlParser->parse($build_config); + // for YAML configs from files/DB + if (is_string($build_config)) { + $yamlParser = new YamlParser(); + $build_config = $yamlParser->parse($build_config); + } $builder->setConfigArray($build_config); @@ -159,7 +162,7 @@ class Build extends BuildBase foreach (['setup', 'test', 'complete', 'success', 'failure'] as $stage) { if ($className::canExecute($stage, $builder, $this)) { - $config[$stage][$className] = [ + $config[$stage][$className::pluginName()] = [ 'zero_config' => true ]; } diff --git a/src/PHPCensor/Plugin.php b/src/PHPCensor/Plugin.php index 5675d8fb..0c5c9d0a 100644 --- a/src/PHPCensor/Plugin.php +++ b/src/PHPCensor/Plugin.php @@ -67,4 +67,12 @@ abstract class Plugin * @return boolean */ abstract public function execute(); + + /** + * @return string + */ + public static function pluginName() + { + return ''; + } } diff --git a/src/PHPCensor/Plugin/Atoum.php b/src/PHPCensor/Plugin/Atoum.php index da2840ac..5e5fd6e9 100644 --- a/src/PHPCensor/Plugin/Atoum.php +++ b/src/PHPCensor/Plugin/Atoum.php @@ -26,6 +26,14 @@ class Atoum extends Plugin protected $config; protected $directory; + /** + * @return string + */ + public static function pluginName() + { + return 'atoum'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Behat.php b/src/PHPCensor/Plugin/Behat.php index 7c8b78af..daf1fe10 100644 --- a/src/PHPCensor/Plugin/Behat.php +++ b/src/PHPCensor/Plugin/Behat.php @@ -27,6 +27,14 @@ class Behat extends Plugin protected $features; protected $executable; + /** + * @return string + */ + public static function pluginName() + { + return 'behat'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Campfire.php b/src/PHPCensor/Plugin/Campfire.php index 97a739f4..dd978e79 100644 --- a/src/PHPCensor/Plugin/Campfire.php +++ b/src/PHPCensor/Plugin/Campfire.php @@ -32,6 +32,14 @@ class Campfire extends Plugin protected $roomId; protected $message; + /** + * @return string + */ + public static function pluginName() + { + return 'campfire'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/CleanBuild.php b/src/PHPCensor/Plugin/CleanBuild.php index 1a4cf0ea..37b01fc9 100644 --- a/src/PHPCensor/Plugin/CleanBuild.php +++ b/src/PHPCensor/Plugin/CleanBuild.php @@ -25,6 +25,14 @@ class CleanBuild extends Plugin { protected $remove; + /** + * @return string + */ + public static function pluginName() + { + return 'clean_build'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Codeception.php b/src/PHPCensor/Plugin/Codeception.php index a9bbac09..27f1e8c2 100644 --- a/src/PHPCensor/Plugin/Codeception.php +++ b/src/PHPCensor/Plugin/Codeception.php @@ -41,6 +41,14 @@ class Codeception extends Plugin implements ZeroConfigPlugin */ protected $path; + /** + * @return string + */ + public static function pluginName() + { + return 'codeception'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Composer.php b/src/PHPCensor/Plugin/Composer.php index fffe8044..91c9ebc5 100644 --- a/src/PHPCensor/Plugin/Composer.php +++ b/src/PHPCensor/Plugin/Composer.php @@ -31,6 +31,14 @@ class Composer extends Plugin implements ZeroConfigPlugin protected $ignorePlatformReqs; protected $preferSource; + /** + * @return string + */ + public static function pluginName() + { + return 'composer'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/CopyBuild.php b/src/PHPCensor/Plugin/CopyBuild.php index 94a7e58d..9716ab5a 100644 --- a/src/PHPCensor/Plugin/CopyBuild.php +++ b/src/PHPCensor/Plugin/CopyBuild.php @@ -27,6 +27,14 @@ class CopyBuild extends Plugin protected $ignore; protected $wipe; + /** + * @return string + */ + public static function pluginName() + { + return 'copy_build'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Deployer.php b/src/PHPCensor/Plugin/Deployer.php index 7c5c1b80..93d47699 100644 --- a/src/PHPCensor/Plugin/Deployer.php +++ b/src/PHPCensor/Plugin/Deployer.php @@ -27,6 +27,14 @@ class Deployer extends Plugin protected $reason; protected $updateOnly; + /** + * @return string + */ + public static function pluginName() + { + return 'deployer'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Email.php b/src/PHPCensor/Plugin/Email.php index 3c9618b0..d5a5e61b 100644 --- a/src/PHPCensor/Plugin/Email.php +++ b/src/PHPCensor/Plugin/Email.php @@ -29,6 +29,14 @@ use PHPCensor\Plugin; */ class Email extends Plugin { + /** + * @return string + */ + public static function pluginName() + { + return 'email'; + } + /** * Send a notification mail. * diff --git a/src/PHPCensor/Plugin/Env.php b/src/PHPCensor/Plugin/Env.php index 37e8cd1e..7363ae81 100644 --- a/src/PHPCensor/Plugin/Env.php +++ b/src/PHPCensor/Plugin/Env.php @@ -25,6 +25,14 @@ class Env extends Plugin { protected $env_vars; + /** + * @return string + */ + public static function pluginName() + { + return 'env'; + } + /** * Adds the specified environment variables to the builder environment */ diff --git a/src/PHPCensor/Plugin/FlowdockNotify.php b/src/PHPCensor/Plugin/FlowdockNotify.php index c715b186..d00fd52b 100644 --- a/src/PHPCensor/Plugin/FlowdockNotify.php +++ b/src/PHPCensor/Plugin/FlowdockNotify.php @@ -30,6 +30,14 @@ class FlowdockNotify extends Plugin const MESSAGE_DEFAULT = 'Build %BUILD% has finished for commit %SHORT_COMMIT% (%COMMIT_EMAIL%)> on branch %BRANCH%'; + /** + * @return string + */ + public static function pluginName() + { + return 'flowdock_notify'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Git.php b/src/PHPCensor/Plugin/Git.php index 9e8681f6..40a2fca8 100644 --- a/src/PHPCensor/Plugin/Git.php +++ b/src/PHPCensor/Plugin/Git.php @@ -25,6 +25,14 @@ class Git extends Plugin { protected $actions = []; + /** + * @return string + */ + public static function pluginName() + { + return 'git'; + } + /** * Run the Git plugin. * @return bool diff --git a/src/PHPCensor/Plugin/Grunt.php b/src/PHPCensor/Plugin/Grunt.php index 2a6fe084..6cdf8256 100644 --- a/src/PHPCensor/Plugin/Grunt.php +++ b/src/PHPCensor/Plugin/Grunt.php @@ -28,6 +28,14 @@ class Grunt extends Plugin protected $grunt; protected $gruntfile; + /** + * @return string + */ + public static function pluginName() + { + return 'grunt'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Gulp.php b/src/PHPCensor/Plugin/Gulp.php index 646c1c88..72110921 100644 --- a/src/PHPCensor/Plugin/Gulp.php +++ b/src/PHPCensor/Plugin/Gulp.php @@ -28,6 +28,14 @@ class Gulp extends Plugin protected $gulp; protected $gulpfile; + /** + * @return string + */ + public static function pluginName() + { + return 'gulp'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/HipchatNotify.php b/src/PHPCensor/Plugin/HipchatNotify.php index 0eb7bd27..ec644ecf 100644 --- a/src/PHPCensor/Plugin/HipchatNotify.php +++ b/src/PHPCensor/Plugin/HipchatNotify.php @@ -32,6 +32,14 @@ class HipchatNotify extends Plugin protected $message; protected $room; + /** + * @return string + */ + public static function pluginName() + { + return 'hipchat_notify'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Irc.php b/src/PHPCensor/Plugin/Irc.php index b8be97b6..9b64b853 100644 --- a/src/PHPCensor/Plugin/Irc.php +++ b/src/PHPCensor/Plugin/Irc.php @@ -29,6 +29,14 @@ class Irc extends Plugin protected $room; protected $nick; + /** + * @return string + */ + public static function pluginName() + { + return 'irc'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Lint.php b/src/PHPCensor/Plugin/Lint.php index 57d4ee6c..2e68b5f1 100644 --- a/src/PHPCensor/Plugin/Lint.php +++ b/src/PHPCensor/Plugin/Lint.php @@ -27,6 +27,14 @@ class Lint extends Plugin protected $recursive = true; protected $ignore; + /** + * @return string + */ + public static function pluginName() + { + return 'lint'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Mysql.php b/src/PHPCensor/Plugin/Mysql.php index fe6fa1b0..66a473cd 100644 --- a/src/PHPCensor/Plugin/Mysql.php +++ b/src/PHPCensor/Plugin/Mysql.php @@ -41,6 +41,14 @@ class Mysql extends Plugin */ protected $pass; + /** + * @return string + */ + public static function pluginName() + { + return 'mysql'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/PackageBuild.php b/src/PHPCensor/Plugin/PackageBuild.php index 28da69d9..abeecc10 100644 --- a/src/PHPCensor/Plugin/PackageBuild.php +++ b/src/PHPCensor/Plugin/PackageBuild.php @@ -26,6 +26,14 @@ class PackageBuild extends Plugin protected $filename; protected $format; + /** + * @return string + */ + public static function pluginName() + { + return 'package_build'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Pdepend.php b/src/PHPCensor/Plugin/Pdepend.php index 35a71ef6..40a6066a 100644 --- a/src/PHPCensor/Plugin/Pdepend.php +++ b/src/PHPCensor/Plugin/Pdepend.php @@ -50,6 +50,14 @@ class Pdepend extends Plugin */ protected $location; + /** + * @return string + */ + public static function pluginName() + { + return 'pdepend'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Pgsql.php b/src/PHPCensor/Plugin/Pgsql.php index f041679c..968918b2 100644 --- a/src/PHPCensor/Plugin/Pgsql.php +++ b/src/PHPCensor/Plugin/Pgsql.php @@ -38,6 +38,14 @@ class Pgsql extends Plugin */ protected $pass; + /** + * @return string + */ + public static function pluginName() + { + return 'pgsql'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Phar.php b/src/PHPCensor/Plugin/Phar.php index 0a8bafd0..130f5275 100644 --- a/src/PHPCensor/Plugin/Phar.php +++ b/src/PHPCensor/Plugin/Phar.php @@ -38,6 +38,14 @@ class Phar extends Plugin */ protected $stub; + /** + * @return string + */ + public static function pluginName() + { + return 'phar'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Phing.php b/src/PHPCensor/Plugin/Phing.php index bf082320..0f7329ee 100644 --- a/src/PHPCensor/Plugin/Phing.php +++ b/src/PHPCensor/Plugin/Phing.php @@ -23,13 +23,20 @@ use PHPCensor\Plugin; */ class Phing extends Plugin { - protected $directory; protected $buildFile = 'build.xml'; protected $targets = ['build']; protected $properties = []; protected $propertyFile; + /** + * @return string + */ + public static function pluginName() + { + return 'phing'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/PhpCodeSniffer.php b/src/PHPCensor/Plugin/PhpCodeSniffer.php index 611c2a9d..771d8779 100644 --- a/src/PHPCensor/Plugin/PhpCodeSniffer.php +++ b/src/PHPCensor/Plugin/PhpCodeSniffer.php @@ -71,6 +71,14 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPlugin */ protected $ignore; + /** + * @return string + */ + public static function pluginName() + { + return 'php_code_sniffer'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/PhpCpd.php b/src/PHPCensor/Plugin/PhpCpd.php index 581303ef..9b5cd3f7 100644 --- a/src/PHPCensor/Plugin/PhpCpd.php +++ b/src/PHPCensor/Plugin/PhpCpd.php @@ -39,6 +39,14 @@ class PhpCpd extends Plugin implements ZeroConfigPlugin */ protected $ignore; + /** + * @return string + */ + public static function pluginName() + { + return 'php_cpd'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/PhpCsFixer.php b/src/PHPCensor/Plugin/PhpCsFixer.php index abdf2891..dc5b2feb 100644 --- a/src/PHPCensor/Plugin/PhpCsFixer.php +++ b/src/PHPCensor/Plugin/PhpCsFixer.php @@ -28,6 +28,14 @@ class PhpCsFixer extends Plugin protected $diff = ''; protected $levels = ['psr0', 'psr1', 'psr2', 'symfony']; + /** + * @return string + */ + public static function pluginName() + { + return 'php_cs_fixer'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/PhpDocblockChecker.php b/src/PHPCensor/Plugin/PhpDocblockChecker.php index 97bcadf4..c82d82cf 100644 --- a/src/PHPCensor/Plugin/PhpDocblockChecker.php +++ b/src/PHPCensor/Plugin/PhpDocblockChecker.php @@ -39,6 +39,14 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPlugin protected $skipMethods = false; protected $allowed_warnings; + /** + * @return string + */ + public static function pluginName() + { + return 'php_docblock_checker'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/PhpLoc.php b/src/PHPCensor/Plugin/PhpLoc.php index 4aa35e10..a827595b 100644 --- a/src/PHPCensor/Plugin/PhpLoc.php +++ b/src/PHPCensor/Plugin/PhpLoc.php @@ -29,6 +29,14 @@ class PhpLoc extends Plugin implements ZeroConfigPlugin */ protected $directory; + /** + * @return string + */ + public static function pluginName() + { + return 'php_loc'; + } + /** * Check if this plugin can be executed. * @param $stage diff --git a/src/PHPCensor/Plugin/PhpMessDetector.php b/src/PHPCensor/Plugin/PhpMessDetector.php index 592b0835..721797b8 100644 --- a/src/PHPCensor/Plugin/PhpMessDetector.php +++ b/src/PHPCensor/Plugin/PhpMessDetector.php @@ -49,6 +49,14 @@ class PhpMessDetector extends Plugin implements ZeroConfigPlugin protected $rules; protected $allowed_warnings; + /** + * @return string + */ + public static function pluginName() + { + return 'php_mess_detector'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/PhpParallelLint.php b/src/PHPCensor/Plugin/PhpParallelLint.php index 846bcff2..b8604878 100644 --- a/src/PHPCensor/Plugin/PhpParallelLint.php +++ b/src/PHPCensor/Plugin/PhpParallelLint.php @@ -38,6 +38,14 @@ class PhpParallelLint extends Plugin implements ZeroConfigPlugin */ protected $extensions; + /** + * @return string + */ + public static function pluginName() + { + return 'php_parallel_lint'; + } + /** * $options['directory'] Output Directory. Default: %BUILDPATH% * $options['filename'] Phar Filename. Default: build.phar diff --git a/src/PHPCensor/Plugin/PhpSpec.php b/src/PHPCensor/Plugin/PhpSpec.php index 6d7a387c..a95cdd4f 100644 --- a/src/PHPCensor/Plugin/PhpSpec.php +++ b/src/PHPCensor/Plugin/PhpSpec.php @@ -23,6 +23,14 @@ use PHPCensor\Plugin; */ class PhpSpec extends Plugin { + /** + * @return string + */ + public static function pluginName() + { + return 'php_spec'; + } + /** * Runs PHP Spec tests. */ diff --git a/src/PHPCensor/Plugin/PhpTalLint.php b/src/PHPCensor/Plugin/PhpTalLint.php index 2a9e03cb..41e44cd4 100644 --- a/src/PHPCensor/Plugin/PhpTalLint.php +++ b/src/PHPCensor/Plugin/PhpTalLint.php @@ -28,6 +28,14 @@ class PhpTalLint extends Plugin protected $suffixes; protected $ignore; + /** + * @return string + */ + public static function pluginName() + { + return 'php_tal_lint'; + } + /** * @var string The path to a file contain custom phptal_tales_ functions */ diff --git a/src/PHPCensor/Plugin/PhpUnit.php b/src/PHPCensor/Plugin/PhpUnit.php index d2b18846..cc9c2991 100644 --- a/src/PHPCensor/Plugin/PhpUnit.php +++ b/src/PHPCensor/Plugin/PhpUnit.php @@ -32,6 +32,14 @@ class PhpUnit extends Plugin implements ZeroConfigPlugin /** @var string[] Raw options from the PHPCI config file */ protected $options = array(); + /** + * @return string + */ + public static function pluginName() + { + return 'php_unit'; + } + /** * Standard Constructor * $options['config'] Path to a PHPUnit XML configuration file. diff --git a/src/PHPCensor/Plugin/Shell.php b/src/PHPCensor/Plugin/Shell.php index 18e2a7df..45976f98 100644 --- a/src/PHPCensor/Plugin/Shell.php +++ b/src/PHPCensor/Plugin/Shell.php @@ -29,6 +29,14 @@ class Shell extends Plugin */ protected $commands = []; + /** + * @return string + */ + public static function pluginName() + { + return 'shell'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/SlackNotify.php b/src/PHPCensor/Plugin/SlackNotify.php index 7250a7ec..444c828e 100644 --- a/src/PHPCensor/Plugin/SlackNotify.php +++ b/src/PHPCensor/Plugin/SlackNotify.php @@ -31,6 +31,14 @@ class SlackNotify extends Plugin private $icon; private $show_status; + /** + * @return string + */ + public static function pluginName() + { + return 'slack_notify'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Sqlite.php b/src/PHPCensor/Plugin/Sqlite.php index ddacce4d..c984fc5f 100644 --- a/src/PHPCensor/Plugin/Sqlite.php +++ b/src/PHPCensor/Plugin/Sqlite.php @@ -33,6 +33,14 @@ class Sqlite extends Plugin */ protected $path; + /** + * @return string + */ + public static function pluginName() + { + return 'sqlite'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/TechnicalDebt.php b/src/PHPCensor/Plugin/TechnicalDebt.php index 2813f85d..90349e79 100755 --- a/src/PHPCensor/Plugin/TechnicalDebt.php +++ b/src/PHPCensor/Plugin/TechnicalDebt.php @@ -55,6 +55,14 @@ class TechnicalDebt extends Plugin implements ZeroConfigPlugin */ protected $searches; + /** + * @return string + */ + public static function pluginName() + { + return 'technical_debt'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Wipe.php b/src/PHPCensor/Plugin/Wipe.php index 046e770d..4da96a95 100644 --- a/src/PHPCensor/Plugin/Wipe.php +++ b/src/PHPCensor/Plugin/Wipe.php @@ -24,6 +24,14 @@ class Wipe extends Plugin { protected $directory; + /** + * @return string + */ + public static function pluginName() + { + return 'wipe'; + } + /** * {@inheritdoc} */ diff --git a/src/PHPCensor/Plugin/Xmpp.php b/src/PHPCensor/Plugin/Xmpp.php index 27a6ce63..f62f73fe 100644 --- a/src/PHPCensor/Plugin/Xmpp.php +++ b/src/PHPCensor/Plugin/Xmpp.php @@ -59,6 +59,14 @@ class XMPP extends Plugin */ protected $date_format; + /** + * @return string + */ + public static function pluginName() + { + return 'xmpp'; + } + /** * {@inheritdoc} */ diff --git a/tests/B8Framework/ViewTest.php b/tests/B8Framework/ViewTest.php index e1a13244..5794ec58 100755 --- a/tests/B8Framework/ViewTest.php +++ b/tests/B8Framework/ViewTest.php @@ -90,7 +90,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase $view->tmp = $tmp; $this->assertTrue($view->render() == 'Hello '); } catch (\Exception $e) { - self::assertInstanceOf('\ErrorException', $e); + self::assertInstanceOf('\PHPUnit_Framework_Error_Notice', $e); } $view = new Template('Hello {@who.toUpperCase}'); diff --git a/tests/PHPCensor/Plugin/Util/FactoryTest.php b/tests/PHPCensor/Plugin/Util/FactoryTest.php index 87682a55..bfb28696 100644 --- a/tests/PHPCensor/Plugin/Util/FactoryTest.php +++ b/tests/PHPCensor/Plugin/Util/FactoryTest.php @@ -129,8 +129,8 @@ class FactoryTest extends \PHPUnit_Framework_TestCase { $expectedArgs ); - $this->assertInternalType('array', $plugin->Options); - $this->assertArrayHasKey('thing', $plugin->Options); + $this->assertInternalType('array', $plugin->options); + $this->assertArrayHasKey('thing', $plugin->options); } public function testAddConfigFromFile_ReturnsTrueForValidFile() diff --git a/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginFull.php b/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginFull.php index c39eb1d7..1179badf 100644 --- a/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginFull.php +++ b/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginFull.php @@ -18,11 +18,19 @@ class ExamplePluginFull extends Plugin { /** * @var array */ - public $Options; + public $options; + + /** + * @return string + */ + public static function pluginName() + { + return 'example_plugin_full'; + } public function __construct(Builder $builder, Build $build, array $options = []) { - $this->Options = $options; + $this->options = $options; } public function execute() diff --git a/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithNoConstructorArgs.php b/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithNoConstructorArgs.php index 96a00068..7c3a673d 100644 --- a/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithNoConstructorArgs.php +++ b/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithNoConstructorArgs.php @@ -14,6 +14,14 @@ use PHPCensor\Plugin; class ExamplePluginWithNoConstructorArgs extends Plugin { + /** + * @return string + */ + public static function pluginName() + { + return 'example_plugin_with_no_constructor_args'; + } + public function execute() { } diff --git a/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithSingleOptionalArg.php b/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithSingleOptionalArg.php index af8e40a0..c09f241f 100644 --- a/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithSingleOptionalArg.php +++ b/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithSingleOptionalArg.php @@ -14,6 +14,14 @@ use PHPCensor\Plugin; class ExamplePluginWithSingleOptionalArg extends Plugin { + /** + * @return string + */ + public static function pluginName() + { + return 'example_plugin_with_single_optional_arg'; + } + function __construct($optional = null) { diff --git a/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithSingleRequiredArg.php b/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithSingleRequiredArg.php index 0663d759..80747a59 100644 --- a/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithSingleRequiredArg.php +++ b/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithSingleRequiredArg.php @@ -14,6 +14,13 @@ use PHPCensor\Plugin; class ExamplePluginWithSingleRequiredArg extends Plugin { + /** + * @return string + */ + public static function pluginName() + { + return 'example_plugin_with_single_required_arg'; + } public $RequiredArgument; diff --git a/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithSingleTypedRequiredArg.php b/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithSingleTypedRequiredArg.php index 5e8e8ca2..6e0dcb11 100644 --- a/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithSingleTypedRequiredArg.php +++ b/tests/PHPCensor/Plugin/Util/Fake/ExamplePluginWithSingleTypedRequiredArg.php @@ -14,6 +14,13 @@ use PHPCensor\Plugin; class ExamplePluginWithSingleTypedRequiredArg extends Plugin { + /** + * @return string + */ + public static function pluginName() + { + return 'example_plugin_with_single_typed_required_arg'; + } public $RequiredArgument; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 3a4edb9d..adf83769 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -39,8 +39,6 @@ if (!defined('IS_WIN')) { require_once(ROOT_DIR . 'vendor/autoload.php'); -\PHPCensor\ErrorHandler::register(); - if (defined('IS_CONSOLE') && IS_CONSOLE) { $loggerConfig = LoggerConfig::newFromFile(APP_DIR . "loggerconfig.php"); }