8000 merged branch l3l0/add-options-resolver-test (PR #4545) · symfony/symfony@9a5b275 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9a5b275

Browse files
committed
merged branch l3l0/add-options-resolver-test (PR #4545)
Commits ------- 83ff200 [OptionsResolver] Added options resolver tests to improve coverage Discussion ---------- [OptionsResolver] Added options resolver tests Bug fix: no Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes [![Build Status](https://secure.travis-ci.org/l3l0/symfony.png?branch=add-options-resolver-test)](http://travis-ci.org/l3l0/symfony) License of the code: MIT --------------------------------------------------------------------------- by travisbot at 2012-06-10T09:14:34Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1581756) (merged 320617b6 into 6266b72). --------------------------------------------------------------------------- by l3l0 at 2012-06-10T11:41:15Z Fixed test names and replaced loop with iterator_to_array --------------------------------------------------------------------------- by travisbot at 2012-06-10T11:44:49Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1582569) (merged 68588202 into 6266b72). ---------------------------------------------------------------- 8000 ----------- by bschussek at 2012-06-10T12:38:47Z Could you please also squash the commits into one and prefix the commit message with "[OptionsResolver]"? --------------------------------------------------------------------------- by l3l0 at 2012-06-10T12:56:20Z Commits squashed --------------------------------------------------------------------------- by travisbot at 2012-06-10T13:01:35Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1583038) (merged 83ff200 into 6266b72). --------------------------------------------------------------------------- by bschussek at 2012-06-10T14:52:16Z Thanks! @fabpot 👍
2 parents 6266b72 + 83ff200 commit 9a5b275

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

src/Symfony/Component/OptionsResolver/Tests/OptionsTest.php

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,86 @@ public function testReplaceClearsAndSets()
215215
8000 'three' => '3',
216216
), $this->options->all());
217217
}
218+
219+
public function testClearRemovesAllOptions()
220+
{
221+
$this->options->set('one', 1);
222+
$this->options->set('two', 2);
223+
224+
$this->options->clear();
225+
226+
$this->assertEmpty($this->options->all());
227+
228+
}
229+
230+
/**
231+
* @covers Symfony\Component\OptionsResolver\Options::replace
232+
* @expectedException Symfony\Component\OptionsResolver\Exception\OptionDefinitionException
233+
*/
234+
public function testCannotReplaceAfterOptionWasRead()
235+
{
236+
$this->options->set('one', 1);
237+
$this->options->all();
238+
239+
$this->options->replace(array(
240+
'two' => '2',
241+
));
242+
}
243+
244+
/**
245+
* @covers Symfony\Component\OptionsResolver\Options::overload
246+
* @expectedException Symfony\Component\OptionsResolver\Exception\OptionDefinitionException
247+
*/
248+
public function testCannotOverloadAfterOptionWasRead()
249+
{
250+
$this->options->set('one', 1);
251+
$this->options->all();
252+
253+
$this->options->overload('one', 2);
254+
}
255+
256+
/**
257+
* @covers Symfony\Component\OptionsResolver\Options::clear
258+
* @expectedException Symfony\Component\OptionsResolver\Exception\OptionDefinitionException
259+
*/
260+
public function testCannotClearAfterOptionWasRead()
261+
{
262+
$this->options->set('one', 1);
263+
$this->options->all();
264+
265+
$this->options->clear();
266+
}
267+
268+
public function testOverloadCannotBeEvaluatedLazilyWithoutExpectedClousureParams()
269+
{
270+
$this->options->set('foo', 'bar');
271+
272+
$this->options->overload('foo', function () {
273+
return 'test';
274+
});
275+
276+
$this->assertNotEquals('test', $this->options->get('foo'));
277+
$this->assertTrue(is_callable($this->options->get('foo')));
278+
}
279+
280+
public function testOverloadCannotBeEvaluatedLazilyWithoutFirstParamTypeHint()
281+
{
282+
$this->options->set('foo', 'bar');
283+
284+
$this->options->overload('foo', function ($object) {
285+
return 'test';
286+
});
287+
288+
$this->assertNotEquals('test', $this->options->get('foo'));
289+
$this->assertTrue(is_callable($this->options->get('foo')));
290+
}
291+
292+
public function testOptionsIteration()
293+
{
294+
$this->options->set('foo', 'bar');
295+
$this->options->set('foo1', 'bar1');
296+
$expectedResult = array('foo' => 'bar', 'foo1' => 'bar1');
297+
298+
$this->assertEquals($expectedResult, iterator_to_array($this->options, true));
299+
}
218300
}

0 commit comments

Comments
 (0)
0