Skip to content

Commit e6e8ff2

Browse files
author
e1himself
committed
Fix revealed tests problems
1 parent 5ec94dd commit e6e8ff2

14 files changed

+41
-35
lines changed

test/unit/i18n/sfChoiceFormatTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of the symfony package.
55
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6-
*
6+
*
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
@@ -107,7 +107,7 @@
107107
$t->is($n->format($string, 0), 'are even numbers', '->format() can takes a set notation in the format string');
108108
$t->is($n->format($string, 2), 'are even numbers', '->format() can takes a set notation in the format string');
109109
$t->is($n->format($string, 4), 'are even numbers', '->format() can takes a set notation in the format string');
110-
$t->is(!$n->format($string, 1), 'are even numbers', '->format() can takes a set notation in the format string');
110+
$t->isnt($n->format($string, 1), 'are even numbers', '->format() can takes a set notation in the format string');
111111
$t->is($n->format($string, 5), 'are not even and greater than or equal to 5', '->format() can takes a set notation in the format string');
112112

113113
$t->diag('set notation for polish');

test/unit/log/sfLoggerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of the symfony package.
55
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6-
*
6+
*
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
@@ -78,7 +78,7 @@ class notaLogger
7878
$logger->log = '';
7979
$logger->log('foo', constant($levelConstant));
8080

81-
$t->is($logger->log, constant($logLevelConstant) >= constant($levelConstant), sprintf('->log() only logs if the level is >= to the defined log level (%s >= %s)', $logLevelConstant, $levelConstant));
81+
$t->is($logger->log, constant($logLevelConstant) >= constant($levelConstant) ? 'foo' : '', sprintf('->log() only logs if the level is >= to the defined log level (%s >= %s)', $logLevelConstant, $levelConstant));
8282
}
8383
}
8484

test/unit/util/sfBrowserTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public function getDefaultServerArray($name)
342342
list($method, $uri, $parameters) = $b->click('submit', array('myfile'=>$unexistentFilename));
343343
$files = $b->getFiles();
344344
$t->is($method, 'post', 'file upload is using right method');
345-
$t->is(!isset($parameters['myfile']), 'file upload key is removed from the main request');
345+
$t->ok(!isset($parameters['myfile']), 'file upload key is removed from the main request');
346346
$t->is(isset($files['myfile'])&&is_array($files['myfile']), true, 'file upload set up a _FILE entry for our test file');
347347
$t->is(array_keys($files['myfile']), array('name','type','tmp_name','error','size'), 'file upload returns correctly formatted array');
348348
$t->is($files['myfile']['error'], UPLOAD_ERR_NO_FILE, 'unexistent file does not exists (UPLOAD_ERR_NO_FILE)');
@@ -363,4 +363,4 @@ public function getDefaultServerArray($name)
363363
$t->diag('bug #106');
364364
list($method, $uri, $parameters) = $b->click('submit7');
365365
$t->is(isset($parameters['']), false, 'submit without name is not submitted');
366-
$t->is($parameters['text_default_value'], 'default', 'input field with name is still submitted');
366+
$t->is($parameters['text_default_value'], 'default', 'input field with name is still submitted');

test/unit/util/sfParameterHolderTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
/*
44
* This file is part of the symfony package.
55
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6-
*
6+
*
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
1010

1111
require_once(__DIR__.'/../../bootstrap/unit.php');
1212

13-
$t = new lime_test(24);
13+
$t = new lime_test(27);
1414

1515
// ->clear()
1616
$t->diag('->clear()');
@@ -30,12 +30,19 @@
3030
$t->is($ph->get('bar'), null, '->get() returns null if the key does not exist');
3131

3232
// checks that get returns reference
33-
$ref = 'foobar';
34-
$ph->set('ref', $ref);
33+
$ph->set('ref', 'foobar');
34+
35+
$ref1 = null;
36+
$ref1 = & $ph->get('ref');
37+
$t->is($ref1, 'foobar');
38+
3539
$ref2 = null;
36-
$ref2 &= $ph->get('ref'); // obtain the very same reference and modify it
37-
$ref2 &= 'barfoo';
38-
$t->is($ref2 , $ref, '->get() returns a reference for the given key');
40+
$ref2 = & $ph->get('ref'); // obtain the very same reference and modify it
41+
$ref2 = 'barfoo';
42+
43+
$t->is($ref1, 'barfoo');
44+
$t->is($ref2, 'barfoo');
45+
$t->is($ref2 , $ref1, '->get() returns a reference for the given key');
3946

4047
$ph = new sfParameterHolder();
4148
$t->is('default_value', $ph->get('foo1', 'default_value'), '->get() takes the default value as its second argument');

test/unit/util/sfToolkitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
// ::isUTF8()
3939
$t->diag('::isUTF8()');
40-
$t->is('été', true, '::isUTF8() returns true if the parameter is an UTF-8 encoded string');
40+
$t->is(sfToolkit::isUTF8('été'), true, '::isUTF8() returns true if the parameter is an UTF-8 encoded string');
4141
$t->is(sfToolkit::isUTF8('AZERTYazerty1234-_'), true, '::isUTF8() returns true if the parameter is an UTF-8 encoded string');
4242
$t->is(sfToolkit::isUTF8('AZERTYazerty1234-_'.chr(254)), false, '::isUTF8() returns false if the parameter is not an UTF-8 encoded string');
4343
// check a very long string

test/unit/validator/sfValidatorAndTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
{
7171
$t->pass('->clean() throws an sfValidatorError exception if one of the validators fails');
7272
$t->is($e[0]->getCode(), 'max_length', '->clean() throws a sfValidatorSchemaError');
73-
$t->is($e instanceof sfValidatorErrorSchema, 'max_length', '->clean() throws a sfValidatorSchemaError');
73+
$t->ok($e instanceof sfValidatorErrorSchema, '->clean() throws a sfValidatorSchemaError');
7474
}
7575

7676
$v1->setOption('max_length', 2);
@@ -86,7 +86,7 @@
8686
$t->is(count($e), 2, '->clean() throws an error for every error');
8787
$t->is($e[0]->getCode(), 'max_length', '->clean() throws a sfValidatorSchemaError');
8888
$t->is($e[1]->getCode(), 'max_length', '->clean() throws a sfValidatorSchemaError');
89-
$t->is($e instanceof sfValidatorErrorSchema, 'max_length', '->clean() throws a sfValidatorSchemaError');
89+
$t->ok($e instanceof sfValidatorErrorSchema, '->clean() throws a sfValidatorSchemaError');
9090
}
9191

9292
$v->setOption('halt_on_error', true);
@@ -101,7 +101,7 @@
101101
$t->pass('->clean() throws an sfValidatorError exception if one of the validators fails');
102102
$t->is(count($e), 1, '->clean() only returns the first error if halt_on_error option is true');
103103
$t->is($e[0]->getCode(), 'max_length', '->clean() throws a sfValidatorSchemaError');
104-
$t->is($e instanceof sfValidatorErrorSchema, 'max_length', '->clean() throws a sfValidatorSchemaError');
104+
$t->ok($e instanceof sfValidatorErrorSchema, '->clean() throws a sfValidatorSchemaError');
105105
}
106106

107107
try
@@ -115,7 +115,7 @@
115115
{
116116
$t->pass('->clean() throws an sfValidatorError exception if one of the validators fails');
117117
$t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError if invalid message is not empty');
118-
$t->is(!$e instanceof sfValidatorErrorSchema, 'max_length', '->clean() throws a sfValidatorError if invalid message is not empty');
118+
$t->ok(!$e instanceof sfValidatorErrorSchema, '->clean() throws a sfValidatorError if invalid message is not empty');
119119
}
120120

121121
// ->asString()
@@ -127,5 +127,5 @@
127127
, '->asString() returns a string representation of the validator');
128128

129129
$v = new sfValidatorAnd(array($v1, $v2), array(), array('required' => 'This is required.'));
130-
$t->is($v->asString(), "(\n String({ max_length: 3 })\n and({}, { required: 'This is required.' })\n String({ min_length: 3 })\n)"
130+
$t->is($v->asString(), "(\n String({ max_length: 3 })\n and({}, { required: 'This is required.' })\n String({ min_length: 3 })\n)"
131131
, '->asString() returns a string representation of the validator');

test/unit/validator/sfValidatorDateRangeTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
require_once(__DIR__.'/../../bootstrap/unit.php');
1212

13-
$t = new lime_test(7);
13+
$t = new lime_test(6);
1414

1515
try
1616
{
@@ -20,8 +20,7 @@
2020
}
2121
catch (RuntimeException $e)
2222
{
23-
$t->pass('__construct() throws a sfValidatorError if you don\'t pass a from_date and a to_date option');
24-
$t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError');
23+
$t->pass('__construct() throws a RuntimeException if you don\'t pass a from_date and a to_date option');
2524
}
2625

2726
$v = new sfValidatorDateRange(array(

test/unit/validator/sfValidatorDateTimeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
$v = new sfValidatorDateTime();
1616

17-
$t->is($v instanceof sfValidatorDate, 'sfValidatorDateTime extends sfValidatorDate');
17+
$t->ok($v instanceof sfValidatorDate, 'sfValidatorDateTime extends sfValidatorDate');
1818

1919
// with_time option
2020
$t->diag('with_time option');

test/unit/validator/sfValidatorOrTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
$t->pass('->clean() throws an sfValidatorError exception if all the validators fails');
7373
$t->is(count($e), 2, '->clean() throws an exception with all error messages');
7474
$t->is($e[0]->getCode(), 'max_length', '->clean() throws a sfValidatorSchemaError');
75-
$t->is($e instanceof sfValidatorErrorSchema, 'max_length', '->clean() throws a sfValidatorSchemaError');
75+
$t->ok($e instanceof sfValidatorErrorSchema, '->clean() throws a sfValidatorSchemaError');
7676
}
7777

7878
try
@@ -86,7 +86,7 @@
8686
{
8787
$t->pass('->clean() throws an sfValidatorError exception if one of the validators fails');
8888
$t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError if invalid message is not empty');
89-
$t->is(!$e instanceof sfValidatorErrorSchema, 'max_length', '->clean() throws a sfValidatorError if invalid message is not empty');
89+
$t->ok(!$e instanceof sfValidatorErrorSchema, '->clean() throws a sfValidatorError if invalid message is not empty');
9090
}
9191

9292
$v1->setOption('max_length', 3);

test/unit/widget/i18n/sfWidgetFormI18nDateTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
$w = new sfWidgetFormI18nDate(array('culture' => 'fr', 'month_format' => 'number'));
3737
$months = $w->getOption('months');
38-
$t->is($months[2], 2, '->configure() automatically changes the date format for the given culture');
38+
$t->is($months[2], '02', '->configure() automatically changes the date format for the given culture');
3939

4040
try
4141
{

0 commit comments

Comments
 (0)