for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Kunstmaan\AdminBundle\Tests\EventListener;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use Doctrine\ORM\Mapping\ClassMetadata;
use Kunstmaan\AdminBundle\Entity\AclChangeset;
use Kunstmaan\AdminBundle\EventListener\MappingListener;
use PHPUnit\Framework\TestCase;
class MappingListenerTest extends TestCase
{
public function testListener()
$args = $this->createMock(LoadClassMetadataEventArgs::class);
$meta = $this->createMock(ClassMetadata::class);
$args->expects($this->once())->method('getClassMetadata')->willReturn($meta);
$meta->expects($this->once())->method('getName')->willReturn(AclChangeset::class);
$meta->expects($this->once())->method('mapManyToOne')->willReturn(AclChangeset::class);
$meta->expects($this->once())->method('mapManyToMany')->willReturn(AclChangeset::class);
$listener = new MappingListener(AclChangeset::class);
$listener->loadClassMetadata($args);
$args
object<PHPUnit\Framework\MockObject\MockObject>
object<Doctrine\ORM\Even...ClassMetadataEventArgs>
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:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
}
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: