From fb2b7bbdf73a3bcac2341eb0ffd89eeac2b7bc76 Mon Sep 17 00:00:00 2001 From: Candison November Date: Sat, 3 Feb 2018 21:46:17 +0800 Subject: [PATCH] Update --- .travis.yml | 2 +- composer.json | 49 ++++-------------- script/.gitkeep | 0 script/Clean.php | 58 --------------------- script/PHPUnit.php | 115 ------------------------------------------ script/RemoveRule.php | 59 ---------------------- test/BaseTest.php | 61 ---------------------- test/DemoTest.php | 7 +-- 8 files changed, 16 insertions(+), 335 deletions(-) create mode 100644 script/.gitkeep delete mode 100644 script/Clean.php delete mode 100644 script/PHPUnit.php delete mode 100644 script/RemoveRule.php delete mode 100644 test/BaseTest.php diff --git a/.travis.yml b/.travis.yml index 51e308b..d5cf206 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ matrix: - php: hhvm - php: hhvm-nightly before_install: - - if [[ $TRAVIS_PHP_VERSION =~ ^hhvm ]]; then sudo cat .hhvm.php.ini >> /etc/hhvm/php.ini; fi + - if [[ $TRAVIS_PHP_VERSION =~ ^hhvm ]]; then sudo cat vendor/codemommy/developphp/file/hhvm.php.ini >> /etc/hhvm/php.ini; fi install: - composer install before_script: diff --git a/composer.json b/composer.json index 1cf61c3..c652e69 100644 --- a/composer.json +++ b/composer.json @@ -31,51 +31,24 @@ }, "autoload-dev": { "psr-4": { - "KanDisheng\\DemoPHP\\Test\\": "test", - "KanDisheng\\DemoPHP\\Script\\": "script" + "KanDisheng\\Test\\": "test", + "KanDisheng\\Script\\": "script" } }, "require": { "php": ">=5.3.0" }, "require-dev": { - "phpunit/phpunit": "*", - "phpmd/phpmd": "*", - "squizlabs/php_codesniffer": "*", - "satooshi/php-coveralls": "*", - "CodeMommy/TaskPHP": "*" + "CodeMommy/DevelopPHP": "dev-master" }, "scripts": { - "environment": [ - "composer -V", - "php -v", - "php -m" - ], - "update-project": [ - "git pull", - "composer self-update", - "composer update" - ], - "test": [ - "composer phpunit", - "composer phpcbf", - "composer phpcs", - "composer phpmd" - ], - "phpmd": [ - "KanDisheng\\DemoPHP\\Script\\Clean::workbench", - "KanDisheng\\DemoPHP\\Script\\RemoveRule::start", - "\"vendor/bin/phpmd\" autoload.php,interface,class,script,test,test_case text cleancode,codesize,controversial,design,naming,unusedcode" - ], - "phpcs": [ - "KanDisheng\\DemoPHP\\Script\\Clean::workbench", - "\"vendor/bin/phpcs\" autoload.php interface class script test test_case --standard=PSR2" - ], - "phpcbf": [ - "KanDisheng\\DemoPHP\\Script\\Clean::workbench", - "\"vendor/bin/phpcbf\" autoload.php interface class script test test_case --standard=PSR2" - ], - "phpunit": "KanDisheng\\DemoPHP\\Script\\PHPUnit::start", - "clean": "KanDisheng\\DemoPHP\\Script\\Clean::all" + "environment": "CodeMommy\\DevelopPHP\\Environment::start", + "update-project": "CodeMommy\\DevelopPHP\\UpdateProject::start", + "test": "CodeMommy\\DevelopPHP\\Test::start", + "phpmd": "CodeMommy\\DevelopPHP\\PHPMessDetector::start", + "phpcs": "CodeMommy\\DevelopPHP\\PHPCodeSniffer::start", + "phpcbf": "CodeMommy\\DevelopPHP\\PHPCodeBeautifierAndFixer::start", + "phpunit": "CodeMommy\\DevelopPHP\\PHPUnit::start", + "clean": "CodeMommy\\DevelopPHP\\Clean::all" } } \ No newline at end of file diff --git a/script/.gitkeep b/script/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/script/Clean.php b/script/Clean.php deleted file mode 100644 index 05439e4..0000000 --- a/script/Clean.php +++ /dev/null @@ -1,58 +0,0 @@ - - */ - -namespace KanDisheng\DemoPHP\Script; - -use CodeMommy\TaskPHP\Console; -use CodeMommy\TaskPHP\FileSystem; - -/** - * Class Clean - * @package KanDisheng\DemoPHP\Script; - */ -class Clean -{ - /** - * Clean constructor. - */ - public function __construct() - { - } - - /** - * Workbench - */ - public static function workbench() - { - $removeList = array( - 'workbench' - ); - $result = FileSystem::remove($removeList); - if ($result) { - Console::printLine('Clean Workbench Finished.', 'success'); - return; - } - Console::printLine('Clean Workbench Error.', 'error'); - } - - /** - * PHPUnit - */ - public static function phpUnit() - { - PHPUnit::clean(); - } - - /** - * All - */ - public static function all() - { - self::workbench(); - self::phpUnit(); - } -} diff --git a/script/PHPUnit.php b/script/PHPUnit.php deleted file mode 100644 index b062189..0000000 --- a/script/PHPUnit.php +++ /dev/null @@ -1,115 +0,0 @@ - - */ - -namespace KanDisheng\DemoPHP\Script; - -use CodeMommy\TaskPHP\Console; -use CodeMommy\TaskPHP\FileSystem; - -/** - * Class PHPUnit - * @package KanDisheng\DemoPHP\Script; - */ -class PHPUnit -{ - const BASE_PATH_NAME = 'KanDisheng'; - - /** - * Base Path - * @var string - */ - private static $basePath = ''; - - /** - * Workbench Path - * @var string - */ - private static $workbenchPath = ''; - - /** - * PHPUnit constructor. - */ - public function __construct() - { - } - - /** - * Get Base Path - * @return string - */ - private static function getBasePath() - { - if (empty(self::$basePath)) { - self::$basePath = sprintf('%s%s%s', sys_get_temp_dir(), DIRECTORY_SEPARATOR, self::BASE_PATH_NAME); - } - return self::$basePath; - } - - /** - * Get Workbench Path - * @return string - */ - private static function getWorkbenchPath() - { - if (empty(self::$workbenchPath)) { - self::$workbenchPath = sprintf( - '%s%s%s%s', - self::getBasePath(), - DIRECTORY_SEPARATOR, - time(), - rand(100, 999) - ); - } - return self::$workbenchPath; - } - - /** - * Clean - * @return bool - */ - public static function clean() - { - $removeList = array( - self::getBasePath() - ); - $result = FileSystem::remove($removeList); - if ($result) { - Console::printLine('Clean PHPUnit Report Finished.', 'success'); - return true; - } - Console::printLine('Clean PHPUnit Report Error.', 'error'); - return false; - } - - /** - * Start - */ - public static function start() - { - Clean::workbench(); - $coveragePath = sprintf('%s%sCodeCoverageReport', self::getWorkbenchPath(), DIRECTORY_SEPARATOR); - $coveragePathHTML = sprintf('%s%sHTML', $coveragePath, DIRECTORY_SEPARATOR); - $coverageFileHTML = sprintf('%s%sindex.html', $coveragePathHTML, DIRECTORY_SEPARATOR); - $coverageFileClover = sprintf( - '%s%sClover%sclover.xml', - $coveragePath, - DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR - ); - $command = sprintf( - '"vendor/bin/phpunit" -v --coverage-html="%s" --coverage-clover="%s"', - $coveragePathHTML, - $coverageFileClover - ); - system($command); - if (is_file($coverageFileHTML)) { - system(sprintf('start %s', $coverageFileHTML)); - return; - } - Console::printLine('No PHPUnit Report.', 'information'); - } -} diff --git a/script/RemoveRule.php b/script/RemoveRule.php deleted file mode 100644 index 58c77f8..0000000 --- a/script/RemoveRule.php +++ /dev/null @@ -1,59 +0,0 @@ - - */ - -namespace KanDisheng\DemoPHP\Script; - -use DOMDocument; - -/** - * Class RemoveRule - * @package KanDisheng\DemoPHP\Script; - */ -class RemoveRule -{ - /** - * RemoveRule constructor. - */ - public function __construct() - { - } - - /** - * Get Rule To Delete - * @return array - */ - private static function getRuleToDelete() - { - return array( - 'cleancode' => array( - 'StaticAccess' - ) - ); - } - - /** - * Start - */ - public static function start() - { - $ruleToDelete = self::getRuleToDelete(); - foreach ($ruleToDelete as $fileName => $ruleName) { - $file = sprintf('vendor/phpmd/phpmd/src/main/resources/rulesets/%s.xml', $fileName); - $ruleDocument = new DOMDocument(); - $ruleDocument->load($file); - $ruleSet = $ruleDocument->getElementsByTagName('rule'); - foreach ($ruleSet as $rule) { - foreach ($rule->attributes as $attribute) { - if ($attribute->nodeName == 'name' && in_array($attribute->nodeValue, $ruleName)) { - $rule->parentNode->removeChild($rule); - } - } - } - $ruleDocument->save($file); - } - } -} diff --git a/test/BaseTest.php b/test/BaseTest.php deleted file mode 100644 index 17957c1..0000000 --- a/test/BaseTest.php +++ /dev/null @@ -1,61 +0,0 @@ - - */ - -declare(strict_types=1); - -namespace KanDisheng\DemoPHP\Test; - -use Exception; -use PHPUnit\Framework\TestCase; - -/** - * Class BaseTest - * @package KanDisheng\DemoPHP\Test - */ -class BaseTest extends TestCase -{ - const TEST_CASE_PATH = 'test_case'; - - /** - * Test Case Path - * @var string - */ - private $testCasePath = ''; - - /** - * BaseTest constructor. - */ - public function __construct() - { - parent::__construct(); - $this->testCasePath = sprintf('%s/../%s', __DIR__, self::TEST_CASE_PATH); - } - - /** - * Get Test Case Path - * @param string $path - * @return string - */ - protected function getTestCasePath($path = '') - { - if (empty($path)) { - return $this->testCasePath; - } - $path = trim($path, '/\\'); - $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); - return sprintf('%s%s%s', $this->testCasePath, DIRECTORY_SEPARATOR, $path); - } - - /** - * Test - * @throws Exception - */ - public function test() - { - $this->assertTrue(true); - } -} diff --git a/test/DemoTest.php b/test/DemoTest.php index bc57b9a..fe2ffc9 100644 --- a/test/DemoTest.php +++ b/test/DemoTest.php @@ -7,16 +7,17 @@ declare(strict_types=1); -namespace KanDisheng\DemoPHP\Test; +namespace KanDisheng\Test; use Exception; +use CodeMommy\DevelopPHP\PHPUnitBase; use KanDisheng\DemoPHP\Demo; /** * Class DemoTest - * @package KanDisheng\DemoPHP\Test + * @package KanDisheng\Test */ -class DemoTest extends BaseTest +class DemoTest extends PHPUnitBase { /** * DemoTest constructor.