These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * This file is part of the Sonata Project package. |
||
7 | * |
||
8 | * (c) Thomas Rabaix <[email protected]> |
||
9 | * |
||
10 | * For the full copyright and license information, please view the LICENSE |
||
11 | * file that was distributed with this source code. |
||
12 | */ |
||
13 | |||
14 | namespace Sonata\NewsBundle\Tests\Model; |
||
15 | |||
16 | use PHPUnit\Framework\TestCase; |
||
17 | use Sonata\NewsBundle\Model\Comment; |
||
18 | use Sonata\NewsBundle\Model\PostInterface; |
||
19 | |||
20 | class ModelTest_Comment extends Comment |
||
21 | { |
||
22 | public function getId(): void |
||
23 | { |
||
24 | } |
||
25 | } |
||
26 | |||
27 | class CommentTest extends TestCase |
||
28 | { |
||
29 | public function testSettersGetters(): void |
||
30 | { |
||
31 | $date = new \DateTime(); |
||
32 | |||
33 | $comment = new ModelTest_Comment(); |
||
34 | $comment->setCreatedAt($date); |
||
35 | $comment->setEmail('[email protected]'); |
||
36 | $comment->setMessage('My message'); |
||
37 | $comment->setName('My name'); |
||
38 | $comment->setPost($post = $this->createMock(PostInterface::class)); |
||
0 ignored issues
–
show
|
|||
39 | $comment->setStatus(1); |
||
40 | $comment->setUpdatedAt($date); |
||
41 | $comment->setUrl('http://www.example.org'); |
||
42 | |||
43 | $this->assertSame($date, $comment->getCreatedAt()); |
||
44 | $this->assertSame('[email protected]', $comment->getEmail()); |
||
45 | $this->assertSame('My message', $comment->getMessage()); |
||
46 | $this->assertSame('My name', $comment->getName()); |
||
47 | $this->assertInstanceOf(PostInterface::class, $post); |
||
48 | $this->assertSame($post, $comment->getPost()); |
||
49 | $this->assertSame(1, $comment->getStatus()); |
||
50 | $this->assertSame($date, $comment->getUpdatedAt()); |
||
51 | $this->assertSame('http://www.example.org', $comment->getUrl()); |
||
52 | } |
||
53 | } |
||
54 |
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: