Skip to content

Commit

Permalink
[test] several fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
connorhu committed Dec 19, 2023
1 parent 3083918 commit 1e125d4
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 27 deletions.
2 changes: 1 addition & 1 deletion tests/fixtures/mySfUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function getCulture()
/**
* @param string $culture
*/
public function setCulture(string $culture): void
public function setCulture($culture)
{
$this->culture = $culture;
}
Expand Down
1 change: 1 addition & 0 deletions tests/generator/sfGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion tests/helper/DateHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 0 additions & 1 deletion tests/response/sfResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/storage/sfCacheSessionStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class sfCacheSessionStorageTest extends TestCase

public function testTodoMigrate()
{
$this->markTestSkipped();
return;

$app = 'frontend';
Expand Down
2 changes: 1 addition & 1 deletion tests/storage/sfMySQLiStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions tests/storage/sfSessionStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class sfSessionStorageTest extends TestCase

public function testTodoMigrate()
{
$this->markTestSkipped();
return;

$app = 'frontend';
Expand Down
1 change: 1 addition & 0 deletions tests/storage/sfStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class sfStorageTest extends TestCase

public function testTodoMigrate()
{
$this->markTestSkipped();
// TODO tests?
}
}
1 change: 1 addition & 0 deletions tests/task/cache/sfCacheClearTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/task/sfBaseTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
11 changes: 6 additions & 5 deletions tests/user/sfUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down Expand Up @@ -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()');
Expand All @@ -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()
Expand All @@ -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');

Expand All @@ -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';
Expand Down
1 change: 1 addition & 0 deletions tests/validator/sfValidatorBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
8 changes: 4 additions & 4 deletions tests/widget/sfWidgetFormDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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');
Expand All @@ -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'));
Expand Down
8 changes: 4 additions & 4 deletions tests/widget/sfWidgetFormDateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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');
Expand All @@ -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');
Expand Down
6 changes: 3 additions & 3 deletions tests/widget/sfWidgetFormSchemaFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -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()');
Expand All @@ -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();
}
}
14 changes: 7 additions & 7 deletions tests/widget/sfWidgetFormTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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'));
Expand Down
1 change: 1 addition & 0 deletions tests/widget/sfWidgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 1e125d4

Please sign in to comment.