Skip to content

Commit 5bd691a

Browse files
dinamicdkarlovi
authored andcommitted
~ improved unit test for AuthorizeFormType
1 parent ec0988b commit 5bd691a

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

Tests/Form/Type/AuthorizeFormTypeTest.php

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,27 @@
1717
use Symfony\Component\Form\Test\TypeTestCase;
1818
use Symfony\Component\Form\FormBuilder;
1919
use Symfony\Component\Form\Forms;
20+
use Symfony\Component\OptionsResolver\OptionsResolver;
2021

2122
class AuthorizeFormTypeTest extends TypeTestCase
2223
{
24+
/**
25+
* @var AuthorizeFormType
26+
*/
27+
protected $instance;
28+
2329
protected function setUp()
2430
{
2531
parent::setUp();
2632

2733
$this->factory = Forms::createFormFactoryBuilder()
28-
->addTypes($this->getTypes())
29-
->getFormFactory();
34+
->addTypes($this->getTypes())
35+
->getFormFactory()
36+
;
3037

3138
$this->builder = new FormBuilder(null, null, $this->dispatcher, $this->factory);
39+
40+
$this->instance = new AuthorizeFormType();
3241
}
3342

3443
public function testSubmit()
@@ -60,6 +69,33 @@ public function testSubmit()
6069
}
6170
}
6271

72+
public function testConfigureOptionsWillSetDefaultsOnTheOptionsResolver()
73+
{
74+
/** @var \PHPUnit_Framework_MockObject_MockObject|OptionsResolver $resolver */
75+
$resolver = $this->createMock(OptionsResolver::class);
76+
77+
$resolver
78+
->expects($this->once())
79+
->method('setDefaults')
80+
->with([
81+
'data_class' => 'FOS\OAuthServerBundle\Form\Model\Authorize',
82+
])
83+
->willReturn($resolver)
84+
;
85+
86+
$this->assertNull($this->instance->configureOptions($resolver));
87+
}
88+
89+
public function testGetName()
90+
{
91+
$this->assertSame('fos_oauth_server_authorize', $this->instance->getName());
92+
}
93+
94+
public function testGetBlockPrefix()
95+
{
96+
$this->assertSame('fos_oauth_server_authorize', $this->instance->getBlockPrefix());
97+
}
98+
6399
protected function getTypes()
64100
{
65101
return array(

0 commit comments

Comments
 (0)