-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c500c9
commit 9cad8ab
Showing
3 changed files
with
6 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,29 +13,20 @@ | |
|
||
namespace Sonata\Form\Tests\Type; | ||
|
||
use PHPUnit\Framework\MockObject\Stub; | ||
use PHPUnit\Framework\TestCase; | ||
use Sonata\Form\Tests\Fixtures\Type\DummyPickerType; | ||
use Symfony\Component\Form\Form; | ||
use Symfony\Component\Form\FormConfigInterface; | ||
use Symfony\Component\Form\FormView; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
/** | ||
* @author Hugo Briand <[email protected]> | ||
*/ | ||
final class BasePickerTypeTest extends TestCase | ||
{ | ||
/** | ||
* @var Stub&TranslatorInterface | ||
*/ | ||
private TranslatorInterface $translator; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->translator = $this->createStub(TranslatorInterface::class); | ||
} | ||
|
||
/** | ||
|
@@ -46,10 +37,7 @@ protected function setUp(): void | |
*/ | ||
public function testFinishView(array $expectedOptions, array $options): void | ||
{ | ||
$type = new DummyPickerType( | ||
$this->translator, | ||
'en' | ||
); | ||
$type = new DummyPickerType(); | ||
|
||
$view = new FormView(); | ||
$form = new Form($this->createStub(FormConfigInterface::class)); | ||
|
@@ -83,10 +71,7 @@ public function testFinishView(array $expectedOptions, array $options): void | |
*/ | ||
public function testTimePickerIntlFormater(array $expectedOptions, array $options): void | ||
{ | ||
$type = new DummyPickerType( | ||
$this->translator, | ||
'en' | ||
); | ||
$type = new DummyPickerType(); | ||
|
||
$view = new FormView(); | ||
$form = new Form($this->createStub(FormConfigInterface::class)); | ||
|
@@ -152,14 +137,4 @@ public function provideTypeOptions(): iterable | |
], | ||
]; | ||
} | ||
|
||
public function testTimePickerUsesDefaultLocaleWithoutRequest(): void | ||
{ | ||
$type = new DummyPickerType( | ||
$this->translator, | ||
'en' | ||
); | ||
|
||
static::assertSame('en', $type->getLocale()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,44 +13,30 @@ | |
|
||
namespace Sonata\Form\Tests\Type; | ||
|
||
use PHPUnit\Framework\MockObject\Stub; | ||
use Sonata\Form\Type\DatePickerType; | ||
use Symfony\Component\Form\Extension\Core\Type\DateType; | ||
use Symfony\Component\Form\FormExtensionInterface; | ||
use Symfony\Component\Form\PreloadedExtension; | ||
use Symfony\Component\Form\Test\TypeTestCase; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
/** | ||
* @author Hugo Briand <[email protected]> | ||
*/ | ||
final class DatePickerTypeTest extends TypeTestCase | ||
{ | ||
/** | ||
* @var Stub&TranslatorInterface | ||
*/ | ||
private TranslatorInterface $translator; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->translator = $this->createStub(TranslatorInterface::class); | ||
|
||
parent::setUp(); | ||
} | ||
|
||
public function testParentIsDateType(): void | ||
{ | ||
$form = new DatePickerType( | ||
$this->translator, | ||
'en' | ||
); | ||
$form = new DatePickerType(); | ||
|
||
static::assertSame(DateType::class, $form->getParent()); | ||
} | ||
|
||
public function testGetName(): void | ||
{ | ||
$type = new DatePickerType($this->translator, 'en'); | ||
$type = new DatePickerType(); | ||
|
||
static::assertSame('sonata_type_date_picker', $type->getBlockPrefix()); | ||
} | ||
|
@@ -68,16 +54,4 @@ public function testSubmitValidData(): void | |
static::assertSame('2018-06-05', $form->getData()->format('Y-m-d')); | ||
static::assertTrue($form->isSynchronized()); | ||
} | ||
|
||
/** | ||
* @return FormExtensionInterface[] | ||
*/ | ||
protected function getExtensions(): array | ||
{ | ||
$type = new DatePickerType($this->translator, 'en'); | ||
|
||
return [ | ||
new PreloadedExtension([$type], []), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,47 +13,30 @@ | |
|
||
namespace Sonata\Form\Tests\Type; | ||
|
||
use PHPUnit\Framework\MockObject\Stub; | ||
use Sonata\Form\Type\DateTimePickerType; | ||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType; | ||
use Symfony\Component\Form\FormExtensionInterface; | ||
use Symfony\Component\Form\PreloadedExtension; | ||
use Symfony\Component\Form\Test\TypeTestCase; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
/** | ||
* @author Hugo Briand <[email protected]> | ||
*/ | ||
final class DateTimePickerTypeTest extends TypeTestCase | ||
{ | ||
/** | ||
* @var Stub&TranslatorInterface | ||
*/ | ||
private TranslatorInterface $translator; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->translator = $this->createStub(TranslatorInterface::class); | ||
|
||
parent::setUp(); | ||
} | ||
|
||
public function testParentIsDateTimeType(): void | ||
{ | ||
$form = new DateTimePickerType( | ||
$this->translator, | ||
'en' | ||
); | ||
$form = new DateTimePickerType(); | ||
|
||
static::assertSame(DateTimeType::class, $form->getParent()); | ||
} | ||
|
||
public function testGetName(): void | ||
{ | ||
$type = new DateTimePickerType( | ||
$this->translator, | ||
'en' | ||
); | ||
$type = new DateTimePickerType(); | ||
|
||
static::assertSame('sonata_type_datetime_picker', $type->getBlockPrefix()); | ||
} | ||
|
@@ -88,19 +71,4 @@ public function testSubmitMatchingDateFormat(): void | |
static::assertSame('1970-01-01 05:23:00', $form->getData()->format('Y-m-d H:i:s')); | ||
static::assertTrue($form->isSynchronized()); | ||
} | ||
|
||
/** | ||
* @return FormExtensionInterface[] | ||
*/ | ||
protected function getExtensions(): array | ||
{ | ||
$type = new DateTimePickerType( | ||
$this->translator, | ||
'en' | ||
); | ||
|
||
return [ | ||
new PreloadedExtension([$type], []), | ||
]; | ||
} | ||
} |