From f0a498e2cfbee57558349c7524e2ad9312940fce Mon Sep 17 00:00:00 2001 From: Koopzington Date: Sun, 13 Nov 2016 16:12:49 +0100 Subject: [PATCH 1/9] Remove CS dependencies and add zend-coding-standard to require-dev --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 97a048f..94b0061 100644 --- a/composer.json +++ b/composer.json @@ -19,8 +19,8 @@ "require-dev": { "zendframework/zend-json": "^2.6.1", "zendframework/zend-session": "^2.6.2", - "fabpot/php-cs-fixer": "1.7.*", - "phpunit/PHPUnit": "~4.0" + "phpunit/PHPUnit": "~4.0", + "zendframework/zend-coding-standard": "~1.0.0" }, "suggest": { "zendframework/zend-json": "Zend\\Json component", From f582b46e18f1e2dac3ab9b42acfcf48fda3b8086 Mon Sep 17 00:00:00 2001 From: Koopzington Date: Sun, 13 Nov 2016 20:04:18 +0100 Subject: [PATCH 2/9] Delete .php_cs --- .php_cs | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 .php_cs diff --git a/.php_cs b/.php_cs deleted file mode 100644 index 8f4dd5a..0000000 --- a/.php_cs +++ /dev/null @@ -1,45 +0,0 @@ -in('src') - ->in('test') - ->notPath('TestAsset') - ->notPath('_files') - ->filter(function (SplFileInfo $file) { - if (strstr($file->getPath(), 'compatibility')) { - return false; - } - }); -$config = Symfony\CS\Config\Config::create(); -$config->level(null); -$config->fixers( - array( - 'braces', - 'duplicate_semicolon', - 'elseif', - 'empty_return', - 'encoding', - 'eof_ending', - 'function_call_space', - 'function_declaration', - 'indentation', - 'join_function', - 'line_after_namespace', - 'linefeed', - 'lowercase_keywords', - 'parenthesis', - 'multiple_use', - 'method_argument_space', - 'object_operator', - 'php_closing_tag', - 'remove_lines_between_uses', - 'short_array_syntax', - 'short_tag', - 'standardize_not_equal', - 'trailing_spaces', - 'unused_use', - 'visibility', - 'whitespacy_lines', - ) -); -$config->finder($finder); -return $config; From 55c582bdc6098ba6f770558a15d23b9eeaefcb63 Mon Sep 17 00:00:00 2001 From: Koopzington Date: Sun, 13 Nov 2016 20:07:03 +0100 Subject: [PATCH 3/9] add/update phpcs.xml --- phpcs.xml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 phpcs.xml diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..9e6a751 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,8 @@ + + + + + + src + test + From 261c3356250aa9d19cbb1a9a56cc12ddf7d5a8c1 Mon Sep 17 00:00:00 2001 From: Koopzington Date: Sun, 13 Nov 2016 20:28:15 +0100 Subject: [PATCH 4/9] add/update composer scripts --- composer.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/composer.json b/composer.json index 94b0061..aec3a32 100644 --- a/composer.json +++ b/composer.json @@ -38,5 +38,16 @@ "psr-4": { "ZendTest\\ProgressBar\\": "test/" } + }, + "scripts": { + "check": [ + "@cs-check", + "@test" + ], + "cs-check": "phpcs", + "cs-fix": "phpcbf", + "test": "phpunit --colors=always", + "test-coverage": "phpunit --colors=always --coverage-clover clover.xml", + "upload-coverage": "coveralls -v" } } From 48b21253ae984505039f9fe2463dfc2ee1d8c77e Mon Sep 17 00:00:00 2001 From: Koopzington Date: Sun, 13 Nov 2016 20:41:39 +0100 Subject: [PATCH 5/9] Use composer scripts in .travis.yml --- .travis.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6d28225..cae9c71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,10 +26,10 @@ matrix: include: - php: 5.5 env: - - EXECUTE_CS_CHECK=true + - CS_CHECK=true - php: 5.6 env: - - EXECUTE_TEST_COVERALLS=true + - TEST_COVERAGE=true - DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)" - PATH="$HOME/.local/bin:$PATH" - php: 7 @@ -42,21 +42,20 @@ notifications: email: false before_install: - - if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi + - if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi - composer self-update - - if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi + - if [[ $TEST_COVERAGE == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi install: - travis_retry composer install --no-interaction --ignore-platform-reqs script: - - if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover clover.xml ; fi - - if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then ./vendor/bin/phpunit ; fi - - if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run ; fi + - if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi + - if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi - if [[ $DEPLOY_DOCS == "true" && "$TRAVIS_TEST_RESULT" == "0" ]]; then wget -O theme-installer.sh "https://raw.githubusercontent.com/zendframework/zf-mkdoc-theme/master/theme-installer.sh" ; chmod 755 theme-installer.sh ; ./theme-installer.sh ; fi after_success: - if [[ $DEPLOY_DOCS == "true" ]]; then echo "Preparing to build and deploy documentation" ; ./zf-mkdoc-theme/deploy.sh ; echo "Completed deploying documentation" ; fi after_script: - - if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/coveralls ; fi + - if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi From 13535e1d6d254105cd48f373fdc1e7b3c5886c56 Mon Sep 17 00:00:00 2001 From: Koopzington Date: Sun, 13 Nov 2016 20:43:26 +0100 Subject: [PATCH 6/9] Replace mentions of php-cs-fixer with phpcs --- CONTRIBUTING.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 73308be..272435c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,24 +77,24 @@ To do so: ## Running Coding Standards Checks -This component uses [php-cs-fixer](http://cs.sensiolabs.org/) for coding +This component uses [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) for coding standards checks, and provides configuration for our selected checks. -`php-cs-fixer` is installed by default via Composer. +`phpcs` is installed by default via Composer. To run checks only: ```console -$ ./vendor/bin/php-cs-fixer fix . -v --diff --dry-run --config-file=.php_cs +$ ./vendor/bin/phpcs ``` -To have `php-cs-fixer` attempt to fix problems for you, omit the `--dry-run` -flag: +`phpcs` also includes a tool for fixing most CS violations, `phpcbf`: + ```console -$ ./vendor/bin/php-cs-fixer fix . -v --diff --config-file=.php_cs +$ ./vendor/bin/phpcbf ``` -If you allow php-cs-fixer to fix CS issues, please re-run the tests to ensure +If you allow `phpcbf` to fix CS issues, please re-run the tests to ensure they pass, and make sure you add and commit the changes after verification. ## Recommended Workflow for Contributions From 12db0bca748b3031621b9c1eb9cba1de4957c232 Mon Sep 17 00:00:00 2001 From: Koopzington Date: Tue, 15 Nov 2016 19:32:38 +0100 Subject: [PATCH 7/9] Replace mentions of phpcs and phpcbf with composer scripts --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 272435c..7aa55f2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,14 +84,14 @@ standards checks, and provides configuration for our selected checks. To run checks only: ```console -$ ./vendor/bin/phpcs +$ composer cs-check ``` `phpcs` also includes a tool for fixing most CS violations, `phpcbf`: ```console -$ ./vendor/bin/phpcbf +$ composer cs-fix ``` If you allow `phpcbf` to fix CS issues, please re-run the tests to ensure From 19fd8d20d4261eb3c9de4348eb920c89ea582a11 Mon Sep 17 00:00:00 2001 From: Koopzington Date: Thu, 17 Nov 2016 21:27:44 +0100 Subject: [PATCH 8/9] Automated CS fixes --- src/Adapter/Console.php | 6 +++--- src/Upload/AbstractUploadHandler.php | 8 ++++---- src/Upload/ApcProgress.php | 6 +++--- src/Upload/SessionProgress.php | 6 +++--- src/Upload/UploadProgress.php | 4 ++-- test/Adapter/ConsoleTest.php | 2 +- test/Upload/AbstractUploadHandlerTest.php | 5 ++++- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/Adapter/Console.php b/src/Adapter/Console.php index c6c786b..721c171 100644 --- a/src/Adapter/Console.php +++ b/src/Adapter/Console.php @@ -192,7 +192,7 @@ public function setOutputStream($resource) public function getOutputStream() { if ($this->outputStream === null) { - if (!defined('STDOUT')) { + if (! defined('STDOUT')) { $this->outputStream = fopen('php://stdout', 'w'); } else { return STDOUT; @@ -210,7 +210,7 @@ public function getOutputStream() */ public function setWidth($width = null) { - if ($width === null || !is_int($width)) { + if ($width === null || ! is_int($width)) { if (substr(PHP_OS, 0, 3) === 'WIN') { // We have to default to 79 on windows, because the windows // terminal always has a fixed width of 80 characters and the @@ -351,7 +351,7 @@ public function setFinishAction($action) self::FINISH_ACTION_EOL, self::FINISH_ACTION_NONE]; - if (!in_array($action, $allowedActions)) { + if (! in_array($action, $allowedActions)) { throw new Exception\InvalidArgumentException('Invalid finish action specified'); } diff --git a/src/Upload/AbstractUploadHandler.php b/src/Upload/AbstractUploadHandler.php index cc2f38a..56415f1 100644 --- a/src/Upload/AbstractUploadHandler.php +++ b/src/Upload/AbstractUploadHandler.php @@ -36,7 +36,7 @@ abstract class AbstractUploadHandler implements UploadHandlerInterface */ public function __construct($options = []) { - if (!empty($options)) { + if (! empty($options)) { $this->setOptions($options); } } @@ -54,7 +54,7 @@ public function setOptions($options) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); - } elseif (!is_array($options)) { + } elseif (! is_array($options)) { throw new Exception\InvalidArgumentException( 'The options parameter must be an array or a Traversable' ); @@ -141,7 +141,7 @@ public function getProgress($id) $this->setProgressAdapter($adapter); } - if (!$adapter instanceof ProgressBar) { + if (! $adapter instanceof ProgressBar) { throw new Exception\RuntimeException('Unknown Adapter type given'); } @@ -170,7 +170,7 @@ abstract protected function getUploadProgress($id); protected function toByteString($size) { $sizes = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; - for ($i=0; $size >= 1024 && $i < 9; $i++) { + for ($i = 0; $size >= 1024 && $i < 9; $i++) { $size /= 1024; } diff --git a/src/Upload/ApcProgress.php b/src/Upload/ApcProgress.php index 73f20d2..37eb993 100644 --- a/src/Upload/ApcProgress.php +++ b/src/Upload/ApcProgress.php @@ -23,12 +23,12 @@ class ApcProgress extends AbstractUploadHandler */ protected function getUploadProgress($id) { - if (!$this->isApcAvailable()) { + if (! $this->isApcAvailable()) { throw new Exception\PhpEnvironmentException('APC extension is not installed'); } $uploadInfo = apc_fetch(ini_get('apc.rfc1867_prefix') . $id); - if (!is_array($uploadInfo)) { + if (! is_array($uploadInfo)) { return false; } @@ -40,7 +40,7 @@ protected function getUploadProgress($id) 'done' => false ]; $status = $uploadInfo + $status; - if (!empty($status['cancel_upload'])) { + if (! empty($status['cancel_upload'])) { $status['done'] = true; $status['message'] = 'The upload has been canceled'; } diff --git a/src/Upload/SessionProgress.php b/src/Upload/SessionProgress.php index d7e874a..0b4a924 100644 --- a/src/Upload/SessionProgress.php +++ b/src/Upload/SessionProgress.php @@ -23,7 +23,7 @@ class SessionProgress extends AbstractUploadHandler */ protected function getUploadProgress($id) { - if (!$this->isSessionUploadProgressAvailable()) { + if (! $this->isSessionUploadProgressAvailable()) { throw new Exception\PhpEnvironmentException( 'Session Upload Progress is not available' ); @@ -31,7 +31,7 @@ protected function getUploadProgress($id) $sessionKey = ini_get('session.upload_progress.prefix') . $id; $uploadInfo = (isset($_SESSION[$sessionKey])) ? $_SESSION[$sessionKey] : null; - if (!is_array($uploadInfo)) { + if (! is_array($uploadInfo)) { return false; } @@ -49,7 +49,7 @@ protected function getUploadProgress($id) $time = time() - $status['start_time']; $status['rate'] = ($time > 0) ? $status['bytes_processed'] / $time : 0; - if (!empty($status['cancel_upload'])) { + if (! empty($status['cancel_upload'])) { $status['done'] = true; $status['message'] = 'The upload has been canceled'; } diff --git a/src/Upload/UploadProgress.php b/src/Upload/UploadProgress.php index dcedbdd..c4e5d0a 100644 --- a/src/Upload/UploadProgress.php +++ b/src/Upload/UploadProgress.php @@ -23,14 +23,14 @@ class UploadProgress extends AbstractUploadHandler */ protected function getUploadProgress($id) { - if (!$this->isUploadProgressAvailable()) { + if (! $this->isUploadProgressAvailable()) { throw new Exception\PhpEnvironmentException( 'UploadProgress extension is not installed' ); } $uploadInfo = uploadprogress_get_info($id); - if (!is_array($uploadInfo)) { + if (! is_array($uploadInfo)) { return false; } diff --git a/test/Adapter/ConsoleTest.php b/test/Adapter/ConsoleTest.php index d5aeca7..dc1c96e 100644 --- a/test/Adapter/ConsoleTest.php +++ b/test/Adapter/ConsoleTest.php @@ -127,7 +127,7 @@ public function testEtaOnly() public function testCustomOrder() { - $adapter = new ConsoleStub(['width' => 25, 'elements' => [Adapter\Console::ELEMENT_ETA, + $adapter = new ConsoleStub(['width' => 25, 'elements' => [Adapter\Console::ELEMENT_ETA, Adapter\Console::ELEMENT_PERCENT, Adapter\Console::ELEMENT_BAR]]); $adapter->notify(0, 100, 0, 0, null, null); diff --git a/test/Upload/AbstractUploadHandlerTest.php b/test/Upload/AbstractUploadHandlerTest.php index e62c7e6..0f4ce58 100644 --- a/test/Upload/AbstractUploadHandlerTest.php +++ b/test/Upload/AbstractUploadHandlerTest.php @@ -144,7 +144,10 @@ public function testProgressBarUpdate($progressData) ->method('notify'); } $progressBar = new ProgressBar( - $adapterStub, 0, $progressData['total'], 'testSession' + $adapterStub, + 0, + $progressData['total'], + 'testSession' ); From 90ead205018c4f29677d192d685afbdc5a637d3b Mon Sep 17 00:00:00 2001 From: Koopzington Date: Thu, 17 Nov 2016 21:48:02 +0100 Subject: [PATCH 9/9] CS fixes --- src/Adapter/Console.php | 19 +++++-- src/Adapter/JsPull.php | 2 + src/Adapter/JsPush.php | 2 + test/Adapter/ConsoleStub.php | 2 + test/Adapter/ConsoleTest.php | 60 +++++++++++++++++----- test/Adapter/JsPullTest.php | 17 +----- test/Adapter/JsPushTest.php | 23 +++------ test/Adapter/MockupStream.php | 12 +++++ test/ProgressBarTest.php | 97 ++--------------------------------- test/TestAsset/JsPullStub.php | 22 ++++++++ test/TestAsset/JsPushStub.php | 22 ++++++++ test/TestAsset/MockUp.php | 59 +++++++++++++++++++++ test/TestAsset/Stub.php | 41 +++++++++++++++ 13 files changed, 237 insertions(+), 141 deletions(-) create mode 100644 test/TestAsset/JsPullStub.php create mode 100644 test/TestAsset/JsPushStub.php create mode 100644 test/TestAsset/MockUp.php create mode 100644 test/TestAsset/Stub.php diff --git a/src/Adapter/Console.php b/src/Adapter/Console.php index 721c171..09987dc 100644 --- a/src/Adapter/Console.php +++ b/src/Adapter/Console.php @@ -243,7 +243,8 @@ public function setWidth($width = null) * Set the elements to display with the progressbar * * @param array $elements - * @throws \Zend\ProgressBar\Adapter\Exception\InvalidArgumentException When an invalid element is found in the array + * @throws \Zend\ProgressBar\Adapter\Exception\InvalidArgumentException When an invalid element is found + * in the array * @return \Zend\ProgressBar\Adapter\Console */ public function setElements(array $elements) @@ -394,14 +395,22 @@ public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $te $doneWidth = min($visualWidth - $indicatorWidth, round($visualWidth * $percent)); if ($doneWidth > 0) { - $bar .= substr(str_repeat($this->barLeftChar, ceil($doneWidth / strlen($this->barLeftChar))), 0, $doneWidth); + $bar .= substr( + str_repeat($this->barLeftChar, ceil($doneWidth / strlen($this->barLeftChar))), + 0, + $doneWidth + ); } $bar .= $this->barIndicatorChar; $leftWidth = $visualWidth - $doneWidth - $indicatorWidth; if ($leftWidth > 0) { - $bar .= substr(str_repeat($this->barRightChar, ceil($leftWidth / strlen($this->barRightChar))), 0, $leftWidth); + $bar .= substr( + str_repeat($this->barRightChar, ceil($leftWidth / strlen($this->barRightChar))), + 0, + $leftWidth + ); } $bar .= ']'; @@ -485,8 +494,10 @@ public function finish() * * @return void */ + // @codingStandardsIgnoreStart protected function _calculateBarWidth() { + // @codingStandardsIgnoreEnd if (in_array(self::ELEMENT_BAR, $this->elements)) { $barWidth = $this->width; @@ -514,8 +525,10 @@ protected function _calculateBarWidth() * @param string $data * @return void */ + // @codingStandardsIgnoreStart protected function _outputData($data) { + // @codingStandardsIgnoreEnd fwrite($this->getOutputStream(), $data); } } diff --git a/src/Adapter/JsPull.php b/src/Adapter/JsPull.php index b349005..85a60ae 100644 --- a/src/Adapter/JsPull.php +++ b/src/Adapter/JsPull.php @@ -84,8 +84,10 @@ public function finish() * @param string $data * @return void */ + // @codingStandardsIgnoreStart protected function _outputData($data) { + // @codingStandardsIgnoreEnd echo $data; if ($this->exitAfterSend) { diff --git a/src/Adapter/JsPush.php b/src/Adapter/JsPush.php index 48753ee..284df24 100644 --- a/src/Adapter/JsPush.php +++ b/src/Adapter/JsPush.php @@ -113,8 +113,10 @@ public function finish() * @param string $data * @return void */ + // @codingStandardsIgnoreStart protected function _outputData($data) { + // @codingStandardsIgnoreEnd // 1024 padding is required for Safari, while 256 padding is required // for Internet Explorer. The
is required so Safari actually // executes the #', $output, $result); + $matches = preg_match('##', $output, $result); $this->assertEquals(1, $matches); $data = json_decode($result[1], true); @@ -37,22 +40,8 @@ public function testJson() $adapter->finish(); $output = $adapter->getLastOutput(); - $matches = preg_match('##', $output, $result); + $matches = preg_match('##', $output, $result); $this->assertEquals(1, $matches); } } - -class JsPushStub extends \Zend\ProgressBar\Adapter\JsPush -{ - protected $_lastOutput = null; - - public function getLastOutput() - { - return $this->_lastOutput; - } - - protected function _outputData($data) - { - $this->_lastOutput = $data; - } -} diff --git a/test/Adapter/MockupStream.php b/test/Adapter/MockupStream.php index cf6e5d7..a244c59 100644 --- a/test/Adapter/MockupStream.php +++ b/test/Adapter/MockupStream.php @@ -18,8 +18,10 @@ class MockupStream public static $tests = []; + // @codingStandardsIgnoreStart public function stream_open($path, $mode, $options, &$opened_path) { + // @codingStandardsIgnoreEnd $url = parse_url($path); $this->test = $url["host"]; $this->position = 0; @@ -28,15 +30,19 @@ public function stream_open($path, $mode, $options, &$opened_path) return true; } + // @codingStandardsIgnoreStart public function stream_read($count) { + // @codingStandardsIgnoreEnd $ret = substr(static::$tests[$this->test], $this->position, $count); $this->position += strlen($ret); return $ret; } + // @codingStandardsIgnoreStart public function stream_write($data) { + // @codingStandardsIgnoreEnd $left = substr(static::$tests[$this->test], 0, $this->position); $right = substr(static::$tests[$this->test], $this->position + strlen($data)); static::$tests[$this->test] = $left . $data . $right; @@ -44,18 +50,24 @@ public function stream_write($data) return strlen($data); } + // @codingStandardsIgnoreStart public function stream_tell() { + // @codingStandardsIgnoreEnd return $this->position; } + // @codingStandardsIgnoreStart public function stream_eof() { + // @codingStandardsIgnoreEnd return $this->position >= strlen(static::$tests[$this->test]); } + // @codingStandardsIgnoreStart public function stream_seek($offset, $whence) { + // @codingStandardsIgnoreEnd switch ($whence) { case SEEK_SET: if ($offset < strlen(static::$tests[$this->test]) && $offset >= 0) { diff --git a/test/ProgressBarTest.php b/test/ProgressBarTest.php index b5fe3ab..6b4840a 100644 --- a/test/ProgressBarTest.php +++ b/test/ProgressBarTest.php @@ -9,6 +9,9 @@ namespace ZendTest\ProgressBar; +use ZendTest\ProgressBar\TestAsset\MockUp; +use ZendTest\ProgressBar\TestAsset\Stub; + /** * @group Zend_ProgressBar */ @@ -84,100 +87,10 @@ public function testEtaZeroPercent() $this->assertEquals(null, $progressBar->getTimeRemaining()); } + // @codingStandardsIgnoreStart protected function _getProgressBar($min, $max, $persistenceNamespace = null) { + // @codingStandardsIgnoreEnd return new Stub(new MockUp(), $min, $max, $persistenceNamespace); } } - -class Stub extends \Zend\ProgressBar\ProgressBar -{ - public function sleep($seconds) - { - $this->startTime -= $seconds; - } - - public function getCurrent() - { - return $this->adapter->getCurrent(); - } - - public function getMax() - { - return $this->adapter->getMax(); - } - - public function getPercent() - { - return $this->adapter->getPercent(); - } - - public function getTimeTaken() - { - return $this->adapter->getTimeTaken(); - } - - public function getTimeRemaining() - { - return $this->adapter->getTimeRemaining(); - } - - public function getText() - { - return $this->adapter->getText(); - } -} - -class MockUp extends \Zend\ProgressBar\Adapter\AbstractAdapter -{ - protected $_current; - protected $_max; - protected $_percent; - protected $_timeTaken; - protected $_timeRemaining; - protected $_text; - - public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $text) - { - $this->_current = $current; - $this->_max = $max; - $this->_percent = $percent; - $this->_timeTaken = $timeTaken; - $this->_timeRemaining = $timeRemaining; - $this->_text = $text; - } - - public function finish() - { - } - - public function getCurrent() - { - return $this->_current; - } - - public function getMax() - { - return $this->_max; - } - - public function getPercent() - { - return $this->_percent; - } - - public function getTimeTaken() - { - return $this->_timeTaken; - } - - public function getTimeRemaining() - { - return $this->_timeRemaining; - } - - public function getText() - { - return $this->_text; - } -} diff --git a/test/TestAsset/JsPullStub.php b/test/TestAsset/JsPullStub.php new file mode 100644 index 0000000..0afac37 --- /dev/null +++ b/test/TestAsset/JsPullStub.php @@ -0,0 +1,22 @@ +_lastOutput; + } + + // @codingStandardsIgnoreStart + protected function _outputData($data) + { + // @codingStandardsIgnoreEnd + $this->_lastOutput = $data; + } +} diff --git a/test/TestAsset/JsPushStub.php b/test/TestAsset/JsPushStub.php new file mode 100644 index 0000000..bccff41 --- /dev/null +++ b/test/TestAsset/JsPushStub.php @@ -0,0 +1,22 @@ +_lastOutput; + } + + // @codingStandardsIgnoreStart + protected function _outputData($data) + { + // @codingStandardsIgnoreEnd + $this->_lastOutput = $data; + } +} diff --git a/test/TestAsset/MockUp.php b/test/TestAsset/MockUp.php new file mode 100644 index 0000000..942d804 --- /dev/null +++ b/test/TestAsset/MockUp.php @@ -0,0 +1,59 @@ +_current = $current; + $this->_max = $max; + $this->_percent = $percent; + $this->_timeTaken = $timeTaken; + $this->_timeRemaining = $timeRemaining; + $this->_text = $text; + } + + public function finish() + { + } + + public function getCurrent() + { + return $this->_current; + } + + public function getMax() + { + return $this->_max; + } + + public function getPercent() + { + return $this->_percent; + } + + public function getTimeTaken() + { + return $this->_timeTaken; + } + + public function getTimeRemaining() + { + return $this->_timeRemaining; + } + + public function getText() + { + return $this->_text; + } +} diff --git a/test/TestAsset/Stub.php b/test/TestAsset/Stub.php new file mode 100644 index 0000000..4cc56a5 --- /dev/null +++ b/test/TestAsset/Stub.php @@ -0,0 +1,41 @@ +startTime -= $seconds; + } + + public function getCurrent() + { + return $this->adapter->getCurrent(); + } + + public function getMax() + { + return $this->adapter->getMax(); + } + + public function getPercent() + { + return $this->adapter->getPercent(); + } + + public function getTimeTaken() + { + return $this->adapter->getTimeTaken(); + } + + public function getTimeRemaining() + { + return $this->adapter->getTimeRemaining(); + } + + public function getText() + { + return $this->adapter->getText(); + } +}