From 1e125d4131e40ac6904e29c1f54c457bf55d48de Mon Sep 17 00:00:00 2001 From: Karoly Gossler Date: Tue, 19 Dec 2023 20:45:11 +0100 Subject: [PATCH] [test] several fixes --- tests/fixtures/mySfUser.php | 2 +- tests/generator/sfGeneratorTest.php | 1 + tests/helper/DateHelperTest.php | 2 +- tests/response/sfResponseTest.php | 1 - tests/storage/sfCacheSessionStorageTest.php | 1 + tests/storage/sfMySQLiStorageTest.php | 2 +- tests/storage/sfSessionStorageTest.php | 1 + tests/storage/sfStorageTest.php | 1 + tests/task/cache/sfCacheClearTaskTest.php | 1 + tests/task/sfBaseTaskTest.php | 1 + tests/user/sfUserTest.php | 11 ++++++----- tests/validator/sfValidatorBaseTest.php | 1 + tests/widget/sfWidgetFormDateTest.php | 8 ++++---- tests/widget/sfWidgetFormDateTimeTest.php | 8 ++++---- tests/widget/sfWidgetFormSchemaFormatterTest.php | 6 +++--- tests/widget/sfWidgetFormTimeTest.php | 14 +++++++------- tests/widget/sfWidgetTest.php | 1 + 17 files changed, 35 insertions(+), 27 deletions(-) diff --git a/tests/fixtures/mySfUser.php b/tests/fixtures/mySfUser.php index 3e7465d71..7fbd392e6 100644 --- a/tests/fixtures/mySfUser.php +++ b/tests/fixtures/mySfUser.php @@ -20,7 +20,7 @@ public function getCulture() /** * @param string $culture */ - public function setCulture(string $culture): void + public function setCulture($culture) { $this->culture = $culture; } diff --git a/tests/generator/sfGeneratorTest.php b/tests/generator/sfGeneratorTest.php index a2b4e8f88..93cbed03a 100644 --- a/tests/generator/sfGeneratorTest.php +++ b/tests/generator/sfGeneratorTest.php @@ -21,6 +21,7 @@ class sfGeneratorTest extends TestCase { public function test() { + $this->markTestSkipped(); // $manager = new sfGeneratorManager(new ProjectConfiguration(__DIR__.'/../fixtures/symfony')); //$generator = new myGenerator($manager); diff --git a/tests/helper/DateHelperTest.php b/tests/helper/DateHelperTest.php index a2c761037..a01fde15a 100644 --- a/tests/helper/DateHelperTest.php +++ b/tests/helper/DateHelperTest.php @@ -29,7 +29,7 @@ class DateHelperTest extends TestCase public function testTodoMigrate() { - sfConfig::set('sf_charset', 'utf-8'); + sfConfig::set('sf_charset', 'UTF-8'); $context = sfContext::getInstance(array('user' => 'sfUser'), true); diff --git a/tests/response/sfResponseTest.php b/tests/response/sfResponseTest.php index 3ddc6fb78..a21625ad1 100644 --- a/tests/response/sfResponseTest.php +++ b/tests/response/sfResponseTest.php @@ -11,7 +11,6 @@ require_once __DIR__.'/../PhpUnitSfTestHelperTrait.php'; require_once __DIR__.'/../sfEventDispatcherTestCase.php'; require_once __DIR__.'/../fixtures/myResponse2.php'; -require_once __DIR__.'/../fixtures/fakeResponse.php'; /** * @internal diff --git a/tests/storage/sfCacheSessionStorageTest.php b/tests/storage/sfCacheSessionStorageTest.php index 1be5d001c..16e3a7845 100644 --- a/tests/storage/sfCacheSessionStorageTest.php +++ b/tests/storage/sfCacheSessionStorageTest.php @@ -23,6 +23,7 @@ class sfCacheSessionStorageTest extends TestCase public function testTodoMigrate() { + $this->markTestSkipped(); return; $app = 'frontend'; diff --git a/tests/storage/sfMySQLiStorageTest.php b/tests/storage/sfMySQLiStorageTest.php index 3454fd15d..241aa0b0d 100644 --- a/tests/storage/sfMySQLiStorageTest.php +++ b/tests/storage/sfMySQLiStorageTest.php @@ -128,7 +128,7 @@ public function testTodoMigrate() $result = mysqli_query($connection, sprintf('SELECT COUNT(sess_id) FROM session WHERE sess_id = "%s"', $session_id)); list($count) = mysqli_fetch_row($result); - $this->is($count, 0, 'session is removed from the database'); + $this->is($count, '0', 'session is removed from the database'); mysqli_free_result($result); unset($count, $result); diff --git a/tests/storage/sfSessionStorageTest.php b/tests/storage/sfSessionStorageTest.php index fe8726717..eca0513ea 100644 --- a/tests/storage/sfSessionStorageTest.php +++ b/tests/storage/sfSessionStorageTest.php @@ -23,6 +23,7 @@ class sfSessionStorageTest extends TestCase public function testTodoMigrate() { + $this->markTestSkipped(); return; $app = 'frontend'; diff --git a/tests/storage/sfStorageTest.php b/tests/storage/sfStorageTest.php index 634215edc..7b61255b5 100644 --- a/tests/storage/sfStorageTest.php +++ b/tests/storage/sfStorageTest.php @@ -25,6 +25,7 @@ class sfStorageTest extends TestCase public function testTodoMigrate() { + $this->markTestSkipped(); // TODO tests? } } diff --git a/tests/task/cache/sfCacheClearTaskTest.php b/tests/task/cache/sfCacheClearTaskTest.php index ca3aefab5..1f5bad8a7 100644 --- a/tests/task/cache/sfCacheClearTaskTest.php +++ b/tests/task/cache/sfCacheClearTaskTest.php @@ -25,6 +25,7 @@ class sfCacheClearTaskTest extends TestCase public function testTodoMigrate() { + $this->markTestSkipped(); return; // TODO fix internal state of sfBaseTaskTest and this // from bootstrap/task.php diff --git a/tests/task/sfBaseTaskTest.php b/tests/task/sfBaseTaskTest.php index da0cf8cb2..348734c60 100644 --- a/tests/task/sfBaseTaskTest.php +++ b/tests/task/sfBaseTaskTest.php @@ -25,6 +25,7 @@ class sfBaseTaskTest extends TestCase public function testTodoMigrate() { + $this->markTestSkipped(); return; // TODO fix internal state of sfCacheClearTask and this $rootDir = __DIR__.'/../../test/functional/fixtures'; diff --git a/tests/user/sfUserTest.php b/tests/user/sfUserTest.php index b69a14590..f27f532f0 100644 --- a/tests/user/sfUserTest.php +++ b/tests/user/sfUserTest.php @@ -11,6 +11,7 @@ use PHPUnit\Framework\TestCase; require_once __DIR__.'/../PhpUnitSfTestHelperTrait.php'; +require_once __DIR__.'/../fixtures/mySfUser.php'; function user_flush($dispatcher, $user, $storage, $options = array()) { @@ -38,7 +39,7 @@ public function testTodoMigrate() $sessionPath = sys_get_temp_dir().'/sessions_'.rand(11111, 99999); $storage = new sfSessionTestStorage(array('session_path' => $sessionPath)); - $user = new sfUser($dispatcher, $storage); + $user = new mySfUser($dispatcher, $storage); // ->initialize() $this->diag('->initialize()'); @@ -54,7 +55,7 @@ public function testTodoMigrate() user_flush($dispatcher, $user, $storage); $this->is($user->getCulture(), 'de', '->initialize() reads the culture from the session data if available'); - $userBis = new sfUser($dispatcher, $storage); + $userBis = new mySfUser($dispatcher, $storage); $this->is($userBis->getCulture(), 'de', '->initialize() serializes the culture to the session data'); // ->setCulture() ->getCulture() @@ -70,12 +71,12 @@ public function testTodoMigrate() $this->is($user->hasFlash('foo'), true, '->hasFlash() returns true if the flash variable exists'); user_flush($dispatcher, $user, $storage, array('use_flash' => true)); - $userBis = new sfUser($dispatcher, $storage, array('use_flash' => true)); + $userBis = new mySfUser($dispatcher, $storage, array('use_flash' => true)); $this->is($userBis->getFlash('foo'), 'bar', '->getFlash() returns a flash previously set'); $this->is($userBis->hasFlash('foo'), true, '->hasFlash() returns true if the flash variable exists'); user_flush($dispatcher, $user, $storage, array('use_flash' => true)); - $userBis = new sfUser($dispatcher, $storage, array('use_flash' => true)); + $userBis = new mySfUser($dispatcher, $storage, array('use_flash' => true)); $this->is($userBis->getFlash('foo'), null, 'Flashes are automatically removed after the next request'); $this->is($userBis->hasFlash('foo'), false, '->hasFlash() returns true if the flash variable exists'); @@ -94,7 +95,7 @@ public function testTodoMigrate() unset($user['foo2']); $this->is(isset($user['foo2']), false, '->offsetUnset() unsets attribute by name'); - $user = new sfUser($dispatcher, $storage); + $user = new mySfUser($dispatcher, $storage); // attribute holder proxy require_once __DIR__.'/../../test/unit/sfParameterHolderTest.class.php'; diff --git a/tests/validator/sfValidatorBaseTest.php b/tests/validator/sfValidatorBaseTest.php index 67979506d..779e6fc3a 100644 --- a/tests/validator/sfValidatorBaseTest.php +++ b/tests/validator/sfValidatorBaseTest.php @@ -172,6 +172,7 @@ public function testTodoMigrate() // ::getCharset() ::setCharset() $this->diag('::getCharset() ::setCharset()'); + sfValidatorBase::setCharset('UTF-8'); $this->is(sfValidatorBase::getCharset(), 'UTF-8', '::getCharset() returns the charset to use for validators'); sfValidatorBase::setCharset('ISO-8859-1'); $this->is(sfValidatorBase::getCharset(), 'ISO-8859-1', '::setCharset() changes the charset to use for validators'); diff --git a/tests/widget/sfWidgetFormDateTest.php b/tests/widget/sfWidgetFormDateTest.php index 241843dcf..ec9a2a201 100644 --- a/tests/widget/sfWidgetFormDateTest.php +++ b/tests/widget/sfWidgetFormDateTest.php @@ -34,7 +34,7 @@ public function testTodoMigrate() $this->diag('->render()'); foreach (array( - $year.'-10-15' => array('year' => $year, 'month' => 10, 'day' => 15), + $year.'-10-15' => array('year' => $year, 'month' => '10', 'day' => '15'), time() => array('year' => date('Y'), 'month' => date('m'), 'day' => date('d')), 'tomorrow' => array('year' => date('Y', time() + 86400), 'month' => date('m', time() + 86400), 'day' => date('d', time() + 86400)), ) as $date => $values) { @@ -60,7 +60,7 @@ public function testTodoMigrate() // date as an array $this->diag('date as an array'); - $values = array('year' => $year, 'month' => 10, 'day' => 15); + $values = array('year' => $year, 'month' => '10', 'day' => '15'); $dom->loadHTML($w->render('foo', $values)); $css = new sfDomCssSelector($dom); $this->is($css->matchSingle('#foo_year option[value="'.$values['year'].'"][selected="selected"]')->getValue(), $values['year'], '->render() renders a select tag for the year'); @@ -69,10 +69,10 @@ public function testTodoMigrate() // invalid date $this->diag('invalid date'); - $dom->loadHTML($w->render('foo', array('year' => null, 'month' => 10))); + $dom->loadHTML($w->render('foo', array('year' => null, 'month' => '10'))); $css = new sfDomCssSelector($dom); $this->is($css->matchSingle('#foo_year option[selected="selected"]')->getValue(), '', '->render() renders a select tag for the year'); - $this->is($css->matchSingle('#foo_month option[selected="selected"]')->getValue(), 10, '->render() renders a select tag for the month'); + $this->is($css->matchSingle('#foo_month option[selected="selected"]')->getValue(), '10', '->render() renders a select tag for the month'); $this->is($css->matchSingle('#foo_day option[selected="selected"]')->getValue(), '', '->render() renders a select tag for the day'); $dom->loadHTML($w->render('foo', 'invaliddate')); diff --git a/tests/widget/sfWidgetFormDateTimeTest.php b/tests/widget/sfWidgetFormDateTimeTest.php index 71749faf7..80bfd8d02 100644 --- a/tests/widget/sfWidgetFormDateTimeTest.php +++ b/tests/widget/sfWidgetFormDateTimeTest.php @@ -34,9 +34,9 @@ public function testTodoMigrate() $this->diag('->render()'); foreach (array( - $year.'-10-15 12:30:35' => array('year' => $year, 'month' => 10, 'day' => 15, 'hour' => 12, 'minute' => 30, 'second' => 35), + $year.'-10-15 12:30:35' => array('year' => $year, 'month' => '10', 'day' => '15', 'hour' => '12', 'minute' => '30', 'second' => '35'), time() => array('year' => date('Y'), 'month' => date('m'), 'day' => date('d'), 'hour' => date('G'), 'minute' => date('i'), 'second' => date('s')), - 'tomorrow 12:30:35' => array('year' => date('Y', time() + 86400), 'month' => date('m', time() + 86400), 'day' => date('d', time() + 86400), 'hour' => 12, 'minute' => 30, 'second' => 35), + 'tomorrow 12:30:35' => array('year' => date('Y', time() + 86400), 'month' => date('m', time() + 86400), 'day' => date('d', time() + 86400), 'hour' => '12', 'minute' => '30', 'second' => '35'), ) as $date => $values) { $dom->loadHTML($w->render('foo', $date)); $css = new sfDomCssSelector($dom); @@ -52,7 +52,7 @@ public function testTodoMigrate() // selected date / time $this->diag('selected date / time'); - $values = array('year' => $year, 'month' => 10, 'day' => 15, 'hour' => 12, 'minute' => 30, 'second' => 35); + $values = array('year' => $year, 'month' => '10', 'day' => '15', 'hour' => '12', 'minute' => '30', 'second' => '35'); $dom->loadHTML($w->render('foo', $values)); $css = new sfDomCssSelector($dom); $this->is($css->matchSingle('#foo_year option[value="'.$values['year'].'"][selected="selected"]')->getValue(), $values['year'], '->render() renders a select tag for the year'); @@ -64,7 +64,7 @@ public function testTodoMigrate() // invalid date / time $this->diag('invalid date / time'); - $values = array('year' => null, 'month' => 10, 'hour' => null, 'minute' => 30); + $values = array('year' => null, 'month' => '10', 'hour' => null, 'minute' => '30'); $dom->loadHTML($w->render('foo', $values)); $css = new sfDomCssSelector($dom); $this->is($css->matchSingle('#foo_year option[selected="selected"]')->getValue(), '', '->render() renders a select tag for the year'); diff --git a/tests/widget/sfWidgetFormSchemaFormatterTest.php b/tests/widget/sfWidgetFormSchemaFormatterTest.php index 7fa3c5ef7..5e9c003a1 100644 --- a/tests/widget/sfWidgetFormSchemaFormatterTest.php +++ b/tests/widget/sfWidgetFormSchemaFormatterTest.php @@ -12,7 +12,6 @@ require_once __DIR__.'/../PhpUnitSfTestHelperTrait.php'; require_once __DIR__.'/../fixtures/MyFormatter.php'; -require_once __DIR__.'/../fixtures/MyFormatter2.php'; require_once __DIR__.'/../fixtures/myI18n.php'; /** @@ -134,7 +133,7 @@ function my__($string) // ->setTranslationCatalogue() ->getTranslationCatalogue() - $f = new MyFormatter2(new sfWidgetFormSchema(array())); + $f = new MyFormatter(new sfWidgetFormSchema(array())); $f->setTranslationCatalogue('foo'); $this->is($f->getTranslationCatalogue(), 'foo', 'setTranslationCatalogue() has set the i18n catalogue correctly'); $this->diag('->setTranslationCatalogue() ->getTranslationCatalogue()'); @@ -150,9 +149,10 @@ function ___my($s, $p, $c) return $c; } - $f = new MyFormatter2(new sfWidgetFormSchema()); + $f = new MyFormatter(new sfWidgetFormSchema()); $f->setTranslationCallable('___my'); $f->setTranslationCatalogue('bar'); $this->is($f->translate('foo', array()), 'bar', 'translate() passes back the catalogue to the translation callable'); + MyFormatter::dropTranslationCallable(); } } diff --git a/tests/widget/sfWidgetFormTimeTest.php b/tests/widget/sfWidgetFormTimeTest.php index 16d8d1e12..6c4a1fb00 100644 --- a/tests/widget/sfWidgetFormTimeTest.php +++ b/tests/widget/sfWidgetFormTimeTest.php @@ -39,18 +39,18 @@ public function testTodoMigrate() $css = new sfDomCssSelector($dom); // selected date - $this->is($css->matchSingle('#foo_hour option[value="12"][selected="selected"]')->getValue(), 12, '->render() renders a select tag for the hour'); - $this->is($css->matchSingle('#foo_minute option[value="30"][selected="selected"]')->getValue(), 30, '->render() renders a select tag for the minute'); - $this->is($css->matchSingle('#foo_second option[value="35"][selected="selected"]')->getValue(), 35, '->render() renders a select tag for the second'); + $this->is($css->matchSingle('#foo_hour option[value="12"][selected="selected"]')->getValue(), '12', '->render() renders a select tag for the hour'); + $this->is($css->matchSingle('#foo_minute option[value="30"][selected="selected"]')->getValue(), '30', '->render() renders a select tag for the minute'); + $this->is($css->matchSingle('#foo_second option[value="35"][selected="selected"]')->getValue(), '35', '->render() renders a select tag for the second'); } // time as an array $this->diag('time as an array'); $dom->loadHTML($w->render('foo', array('hour' => 12, 'minute' => '30', 'second' => 35))); $css = new sfDomCssSelector($dom); - $this->is($css->matchSingle('#foo_hour option[value="12"][selected="selected"]')->getValue(), 12, '->render() renders a select tag for the hour'); - $this->is($css->matchSingle('#foo_minute option[value="30"][selected="selected"]')->getValue(), 30, '->render() renders a select tag for the minute'); - $this->is($css->matchSingle('#foo_second option[value="35"][selected="selected"]')->getValue(), 35, '->render() renders a select tag for the second'); + $this->is($css->matchSingle('#foo_hour option[value="12"][selected="selected"]')->getValue(), '12', '->render() renders a select tag for the hour'); + $this->is($css->matchSingle('#foo_minute option[value="30"][selected="selected"]')->getValue(), '30', '->render() renders a select tag for the minute'); + $this->is($css->matchSingle('#foo_second option[value="35"][selected="selected"]')->getValue(), '35', '->render() renders a select tag for the second'); // time as an array - single digits $this->diag('time as an array - single digits'); @@ -65,7 +65,7 @@ public function testTodoMigrate() $dom->loadHTML($w->render('foo', array('hour' => null, 'minute' => 30))); $css = new sfDomCssSelector($dom); $this->is($css->matchSingle('#foo_hour option[selected="selected"]')->getValue(), '', '->render() renders a select tag for the hour'); - $this->is($css->matchSingle('#foo_minute option[selected="selected"]')->getValue(), 30, '->render() renders a select tag for the minute'); + $this->is($css->matchSingle('#foo_minute option[selected="selected"]')->getValue(), '30', '->render() renders a select tag for the minute'); $this->is($css->matchSingle('#foo_second option[selected="selected"]')->getValue(), '', '->render() renders a select tag for the second'); $dom->loadHTML($w->render('foo', 'invalidtime')); diff --git a/tests/widget/sfWidgetTest.php b/tests/widget/sfWidgetTest.php index ef581bd5e..4610d8ecb 100644 --- a/tests/widget/sfWidgetTest.php +++ b/tests/widget/sfWidgetTest.php @@ -127,6 +127,7 @@ public function testTodoMigrate() // ::getCharset() ::setCharset() $this->diag('::getCharset() ::setCharset()'); + sfWidget::setCharset('UTF-8'); $this->is(sfWidget::getCharset(), 'UTF-8', '::getCharset() returns the charset to use for widgets'); sfWidget::setCharset('ISO-8859-1'); $this->is(sfWidget::getCharset(), 'ISO-8859-1', '::setCharset() changes the charset to use for widgets');