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\SeoBundle\Tests\Block\Social; |
||
15 | |||
16 | use Sonata\AdminBundle\Form\FormMapper; |
||
17 | use Sonata\BlockBundle\Block\BlockContext; |
||
18 | use Sonata\BlockBundle\Model\Block; |
||
19 | use Sonata\BlockBundle\Test\AbstractBlockServiceTestCase; |
||
20 | use Sonata\BlockBundle\Util\OptionsResolver; |
||
21 | use Sonata\SeoBundle\Block\Social\FacebookSendButtonBlockService; |
||
22 | |||
23 | class FacebookSendButtonBlockServiceTest extends AbstractBlockServiceTestCase |
||
24 | { |
||
25 | public function testService(): void |
||
26 | { |
||
27 | $service = new FacebookSendButtonBlockService( |
||
28 | 'sonata.block.service.facebook.send_button', |
||
29 | $this->templating |
||
30 | ); |
||
31 | |||
32 | $block = new Block(); |
||
33 | $block->setType('core.text'); |
||
34 | $block->setSettings([ |
||
35 | 'url' => 'url_setting', |
||
36 | 'width' => 'width_setting', |
||
37 | 'height' => 'height_setting', |
||
38 | 'colorscheme' => 'colorscheme_setting', |
||
39 | ]); |
||
40 | |||
41 | $optionResolver = new OptionsResolver(); |
||
42 | $service->setDefaultSettings($optionResolver); |
||
43 | |||
44 | $blockContext = new BlockContext($block, $optionResolver->resolve($block->getSettings())); |
||
45 | |||
46 | $formMapper = $this->createMock(FormMapper::class, [], [], '', false); |
||
47 | $formMapper->expects($this->exactly(2))->method('add'); |
||
48 | |||
49 | $service->buildCreateForm($formMapper, $block); |
||
0 ignored issues
–
show
|
|||
50 | $service->buildEditForm($formMapper, $block); |
||
0 ignored issues
–
show
$formMapper is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Sonata\AdminBundle\Form\FormMapper> .
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);
Loading history...
|
|||
51 | |||
52 | $service->execute($blockContext); |
||
53 | |||
54 | $this->assertSame('url_setting', $this->templating->parameters['settings']['url']); |
||
55 | $this->assertSame('width_setting', $this->templating->parameters['settings']['width']); |
||
56 | $this->assertSame('height_setting', $this->templating->parameters['settings']['height']); |
||
57 | $this->assertSame('colorscheme_setting', $this->templating->parameters['settings']['colorscheme']); |
||
58 | } |
||
59 | } |
||
60 |
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: