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\FacebookShareButtonBlockService; |
||
22 | |||
23 | class FacebookShareButtonBlockServiceTest extends AbstractBlockServiceTestCase |
||
24 | { |
||
25 | public function testService(): void |
||
26 | { |
||
27 | $service = new FacebookShareButtonBlockService( |
||
28 | 'sonata.block.service.facebook.share_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 | 'layout' => 'layout_setting', |
||
38 | ]); |
||
39 | |||
40 | $optionResolver = new OptionsResolver(); |
||
41 | $service->setDefaultSettings($optionResolver); |
||
42 | |||
43 | $blockContext = new BlockContext($block, $optionResolver->resolve($block->getSettings())); |
||
44 | |||
45 | $formMapper = $this->createMock(FormMapper::class, [], [], '', false); |
||
46 | $formMapper->expects($this->exactly(2))->method('add'); |
||
47 | |||
48 | $service->buildCreateForm($formMapper, $block); |
||
0 ignored issues
–
show
|
|||
49 | $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...
|
|||
50 | |||
51 | $service->execute($blockContext); |
||
52 | |||
53 | $this->assertSame('url_setting', $this->templating->parameters['settings']['url']); |
||
54 | $this->assertSame('width_setting', $this->templating->parameters['settings']['width']); |
||
55 | $this->assertSame('layout_setting', $this->templating->parameters['settings']['layout']); |
||
56 | } |
||
57 | } |
||
58 |
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: