|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
4
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|
5
|
|
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
6
|
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|
7
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
8
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace MpaCustomDoctrineHydratorTest\Form\Annotation; |
|
12
|
|
|
|
|
13
|
|
|
use MpaCustomDoctrineHydrator\Form\Annotation\AnnotationBuilder; |
|
14
|
|
|
use MpaCustomDoctrineHydratorTest\Assets\Entity\Birthday; |
|
15
|
|
|
use MpaCustomDoctrineHydratorTest\Util\ServiceManagerFactory; |
|
16
|
|
|
use PHPUnit\Framework\TestCase; |
|
17
|
|
|
use Zend\Form\Factory; |
|
18
|
|
|
use Zend\Form\Form; |
|
19
|
|
|
|
|
20
|
|
|
class AnnotationBuilderTest extends TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
protected $builder; |
|
23
|
|
|
protected $formElementManager; |
|
24
|
|
|
protected $entityManager; |
|
25
|
|
|
|
|
26
|
|
|
public function setUp() |
|
27
|
|
|
{ |
|
28
|
|
|
\Locale::setDefault('fr-FR'); |
|
29
|
|
|
$serviceManager = ServiceManagerFactory::getServiceManager(); |
|
30
|
|
|
|
|
31
|
|
|
$this->entityManager = $serviceManager->get('doctrine.entitymanager.orm_default'); |
|
32
|
|
|
$this->formElementManager = $serviceManager->get('FormElementManager'); |
|
33
|
|
|
$this->builder = new AnnotationBuilder( |
|
34
|
|
|
$this->entityManager, |
|
|
|
|
|
|
35
|
|
|
$this->formElementManager |
|
|
|
|
|
|
36
|
|
|
); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function testEntityIsBuilt() |
|
40
|
|
|
{ |
|
41
|
|
|
$entity = new Birthday(); |
|
42
|
|
|
$spec = $this->builder->getFormSpecification($entity); |
|
43
|
|
|
|
|
44
|
|
|
$this->assertCount(8, ($spec['elements'])); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function testAnnotationBuilderHasFormFactoryInjected() |
|
48
|
|
|
{ |
|
49
|
|
|
$this->assertInstanceOf(Factory::class, $this->builder->getFormFactory()); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function testAnnotationBuilderCanCreateForm() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->assertInstanceOf(Form::class, $this->builder->createForm(Birthday::class)); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: