|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright (c) 2017 DarkWeb Design |
| 4 | + * |
| 5 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | + * of this software and associated documentation files (the "Software"), to deal |
| 7 | + * in the Software without restriction, including without limitation the rights |
| 8 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 | + * copies of the Software, and to permit persons to whom the Software is |
| 10 | + * furnished to do so, subject to the following conditions: |
| 11 | + * |
| 12 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 13 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 14 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 15 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 16 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 17 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 18 | + * SOFTWARE. |
| 19 | + */ |
| 20 | + |
| 21 | +namespace DarkWebDesign\SymfonyAddon\FormType\Tests; |
| 22 | + |
| 23 | +use DarkWebDesign\SymfonyAddon\FormType\BirthdayType; |
| 24 | +use Symfony\Component\Form\Test\TypeTestCase; |
| 25 | + |
| 26 | +class BirthdayTypeTest extends TypeTestCase |
| 27 | +{ |
| 28 | + /** @var \DarkWebDesign\SymfonyAddon\FormType\BirthdayType */ |
| 29 | + private $type; |
| 30 | + |
| 31 | + protected function setUp() |
| 32 | + { |
| 33 | + parent::setUp(); |
| 34 | + |
| 35 | + $this->type = new BirthdayType(); |
| 36 | + } |
| 37 | + |
| 38 | + public function test() |
| 39 | + { |
| 40 | + $form = $this->factory->create($this->type); |
| 41 | + |
| 42 | + $choices = $form->get('year')->getConfig()->getOption('choices'); |
| 43 | + |
| 44 | + $this->assertCount(121, $choices); |
| 45 | + $this->assertSame(date('Y'), reset($choices)); |
| 46 | + $this->assertSame((string) (date('Y') - 120), end($choices)); |
| 47 | + } |
| 48 | +} |
0 commit comments