From 2a0c3f7cee26d562f360286410f7baca6524d432 Mon Sep 17 00:00:00 2001 From: Karoly Gossler Date: Mon, 18 Dec 2023 18:55:31 +0100 Subject: [PATCH] [test] fixed return type, add missing files --- tests/fixtures/ApplicationTask.php | 39 ++++++++++++++++++ tests/fixtures/FakeValidator.php | 17 ++++++++ tests/fixtures/FormListener.php | 31 ++++++++++++++ tests/fixtures/ProjectLoader2.php | 17 ++++++++ tests/fixtures/ProjectServiceContainer.php | 40 +++++++++++++++++++ tests/fixtures/TestForm.php | 20 ++++++++++ tests/fixtures/TestLogger.php | 22 ++++++++++ tests/fixtures/TestTask.php | 24 +++++++++++ tests/fixtures/ValidatorChoiceTestIsEmpty.php | 17 ++++++++ tests/fixtures/configuredView.php | 21 ++++++++++ tests/fixtures/myFilesystem.php | 22 ++++++++++ tests/fixtures/myLogger.php | 19 +++++++++ tests/fixtures/myLogger2.php | 19 +++++++++ tests/fixtures/myLoggerWrapper.php | 17 ++++++++ tests/fixtures/myResponse2.php | 20 ++++++++++ tests/fixtures/myView.php | 20 ++++++++++ tests/fixtures/myWebResponse2.php | 22 ++++++++++ tests/fixtures/sfPluginTestHelper.php | 34 ++++++++++++++++ tests/sfContext.class.php | 2 +- 19 files changed, 422 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/ApplicationTask.php create mode 100644 tests/fixtures/FakeValidator.php create mode 100644 tests/fixtures/FormListener.php create mode 100644 tests/fixtures/ProjectLoader2.php create mode 100644 tests/fixtures/ProjectServiceContainer.php create mode 100644 tests/fixtures/TestForm.php create mode 100644 tests/fixtures/TestLogger.php create mode 100644 tests/fixtures/TestTask.php create mode 100644 tests/fixtures/ValidatorChoiceTestIsEmpty.php create mode 100644 tests/fixtures/configuredView.php create mode 100644 tests/fixtures/myFilesystem.php create mode 100644 tests/fixtures/myLogger.php create mode 100644 tests/fixtures/myLogger2.php create mode 100644 tests/fixtures/myLoggerWrapper.php create mode 100644 tests/fixtures/myResponse2.php create mode 100644 tests/fixtures/myView.php create mode 100644 tests/fixtures/myWebResponse2.php create mode 100644 tests/fixtures/sfPluginTestHelper.php diff --git a/tests/fixtures/ApplicationTask.php b/tests/fixtures/ApplicationTask.php new file mode 100644 index 000000000..8bd5ba5bd --- /dev/null +++ b/tests/fixtures/ApplicationTask.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class ApplicationTask extends sfBaseTask +{ + protected function configure() + { + $this->addOption('application', null, sfCommandOption::PARAMETER_REQUIRED, '', true); + } + + protected function execute($arguments = array(), $options = array()) + { + if (!$this->configuration instanceof sfApplicationConfiguration) { + throw new Exception('This task requires an application configuration be loaded.'); + } + } + + public function getServiceContainer() + { + return parent::getServiceContainer(); + } + + public function getRouting() + { + return parent::getRouting(); + } + + public function getMailer() + { + return parent::getMailer(); + } +} diff --git a/tests/fixtures/FakeValidator.php b/tests/fixtures/FakeValidator.php new file mode 100644 index 000000000..ebea31761 --- /dev/null +++ b/tests/fixtures/FakeValidator.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class FakeValidator extends sfValidatorDecorator +{ + protected function getValidator() + { + return 'foo'; + } +} diff --git a/tests/fixtures/FormListener.php b/tests/fixtures/FormListener.php new file mode 100644 index 000000000..7ea3ad1c7 --- /dev/null +++ b/tests/fixtures/FormListener.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class FormListener +{ + public $events = array(); + + public function listen(sfEvent $event) + { + $this->events[] = func_get_args(); + } + + public function filter(sfEvent $event, $value) + { + $this->events[] = func_get_args(); + + return $value; + } + + public function reset() + { + $this->events = array(); + } +} diff --git a/tests/fixtures/ProjectLoader2.php b/tests/fixtures/ProjectLoader2.php new file mode 100644 index 000000000..471ad624f --- /dev/null +++ b/tests/fixtures/ProjectLoader2.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class ProjectLoader2 extends sfServiceContainerLoaderArray +{ + public function validate($content) + { + return parent::validate($content); + } +} diff --git a/tests/fixtures/ProjectServiceContainer.php b/tests/fixtures/ProjectServiceContainer.php new file mode 100644 index 000000000..91c26e49c --- /dev/null +++ b/tests/fixtures/ProjectServiceContainer.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class ProjectServiceContainer extends sfServiceContainer +{ + public $__bar; + public $__foo_bar; + public $__foo_baz; + + public function __construct() + { + parent::__construct(); + + $this->__bar = new stdClass(); + $this->__foo_bar = new stdClass(); + $this->__foo_baz = new stdClass(); + } + + protected function getBarService() + { + return $this->__bar; + } + + protected function getFooBarService() + { + return $this->__foo_bar; + } + + protected function getFoo_BazService() + { + return $this->__foo_baz; + } +} diff --git a/tests/fixtures/TestForm.php b/tests/fixtures/TestForm.php new file mode 100644 index 000000000..45c22ee26 --- /dev/null +++ b/tests/fixtures/TestForm.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class TestForm extends sfFormSymfony +{ + public function configure() + { + $this->setValidators(array( + 'first_name' => new sfValidatorString(), + 'last_name' => new sfValidatorString(), + )); + } +} diff --git a/tests/fixtures/TestLogger.php b/tests/fixtures/TestLogger.php new file mode 100644 index 000000000..d3d26018c --- /dev/null +++ b/tests/fixtures/TestLogger.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class TestLogger extends sfFileLogger +{ + public function getTimeFormat() + { + return $this->timeFormat; + } + + protected function getPriority($priority) + { + return '*'.$priority.'*'; + } +} diff --git a/tests/fixtures/TestTask.php b/tests/fixtures/TestTask.php new file mode 100644 index 000000000..86b93081c --- /dev/null +++ b/tests/fixtures/TestTask.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class TestTask extends sfBaseTask +{ + protected function execute($arguments = array(), $options = array()) {} + + public function reloadAutoload() + { + parent::reloadAutoload(); + } + + public function initializeAutoload(sfProjectConfiguration $configuration, $reload = false) + { + parent::initializeAutoload($configuration, $reload); + } +} diff --git a/tests/fixtures/ValidatorChoiceTestIsEmpty.php b/tests/fixtures/ValidatorChoiceTestIsEmpty.php new file mode 100644 index 000000000..23f4f610b --- /dev/null +++ b/tests/fixtures/ValidatorChoiceTestIsEmpty.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class ValidatorChoiceTestIsEmpty extends sfValidatorChoice +{ + public function run($value) + { + return $this->isEmpty($value); + } +} diff --git a/tests/fixtures/configuredView.php b/tests/fixtures/configuredView.php new file mode 100644 index 000000000..c22cb75fe --- /dev/null +++ b/tests/fixtures/configuredView.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class configuredView extends myView +{ + public static $isDecorated = false; + + public function initialize($context, $moduleName, $actionName, $viewName) + { + $this->setDecorator(self::$isDecorated); + + parent::initialize($context, $moduleName, $actionName, $viewName); + } +} diff --git a/tests/fixtures/myFilesystem.php b/tests/fixtures/myFilesystem.php new file mode 100644 index 000000000..ad545ee0e --- /dev/null +++ b/tests/fixtures/myFilesystem.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class myFilesystem extends sfFilesystem +{ + public function calculateRelativeDir($from, $to) + { + return parent::calculateRelativeDir($from, $to); + } + + public function canonicalizePath($path) + { + return parent::canonicalizePath($path); + } +} diff --git a/tests/fixtures/myLogger.php b/tests/fixtures/myLogger.php new file mode 100644 index 000000000..3020c453a --- /dev/null +++ b/tests/fixtures/myLogger.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class myLogger extends sfLogger +{ + public $log = ''; + + protected function doLog($message, $priority) + { + $this->log .= $message; + } +} diff --git a/tests/fixtures/myLogger2.php b/tests/fixtures/myLogger2.php new file mode 100644 index 000000000..dd6ccac46 --- /dev/null +++ b/tests/fixtures/myLogger2.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class myLogger2 implements sfLoggerInterface +{ + public $log = ''; + + public function log($message, $priority = null) + { + $this->log = $message; + } +} diff --git a/tests/fixtures/myLoggerWrapper.php b/tests/fixtures/myLoggerWrapper.php new file mode 100644 index 000000000..1801dcce2 --- /dev/null +++ b/tests/fixtures/myLoggerWrapper.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class myLoggerWrapper extends sfLoggerWrapper +{ + public function getLogger() + { + return $this->logger; + } +} diff --git a/tests/fixtures/myResponse2.php b/tests/fixtures/myResponse2.php new file mode 100644 index 000000000..f7a00123e --- /dev/null +++ b/tests/fixtures/myResponse2.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class myResponse2 extends sfResponse +{ + public function serialize() {} + + public function unserialize($serialized) {} + + public function __serialize() {} + + public function __unserialize($data) {} +} diff --git a/tests/fixtures/myView.php b/tests/fixtures/myView.php new file mode 100644 index 000000000..4c8ec380e --- /dev/null +++ b/tests/fixtures/myView.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class myView extends sfView +{ + public function execute() {} + + public function configure() {} + + public function getEngine() {} + + public function render() {} +} diff --git a/tests/fixtures/myWebResponse2.php b/tests/fixtures/myWebResponse2.php new file mode 100644 index 000000000..79991fc9e --- /dev/null +++ b/tests/fixtures/myWebResponse2.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class myWebResponse2 extends sfWebResponse +{ + public function getStatusText() + { + return $this->statusText; + } + + public function normalizeHeaderName($name) + { + return parent::normalizeHeaderName($name); + } +} diff --git a/tests/fixtures/sfPluginTestHelper.php b/tests/fixtures/sfPluginTestHelper.php new file mode 100644 index 000000000..d85ae6e42 --- /dev/null +++ b/tests/fixtures/sfPluginTestHelper.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class sfPluginTestHelper +{ + public static function convertUrlToFixture($url) + { + $file = preg_replace(array('/_+/', '#/+#', '#_/#'), array('_', '/', '/'), preg_replace('#[^a-zA-Z0-9\-/\.]#', '_', $url)); + + $dir = dirname($file); + $file = basename($file); + + $dest = SF_PLUGIN_TEST_DIR.'/'.$dir.'/'.$file; + + if (!is_dir(dirname($dest))) { + mkdir(dirname($dest), 0777, true); + } + + if (!file_exists(__DIR__.'/fixtures/'.$dir.'/'.$file)) { + throw new sfException(sprintf('Unable to find fixture for %s (%s)', $url, $file)); + } + + copy(__DIR__.'/fixtures/'.$dir.'/'.$file, $dest); + + return $dest; + } +} diff --git a/tests/sfContext.class.php b/tests/sfContext.class.php index b1b721287..8fead9ad3 100644 --- a/tests/sfContext.class.php +++ b/tests/sfContext.class.php @@ -47,7 +47,7 @@ public function __destruct() sfToolkit::clearDirectory($this->sessionPath); } - public static function hasInstance(): true + public static function hasInstance()/*: true*/ { return true; }