Completed
Push — master ( c3eba2...34879d )
by amaury
05:12 queued 01:44
created

Controller/EditNodeControllerTest.php (1 issue)

mismatching argument types.

Documentation Minor

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace OpenOrchestra\FunctionalTests\BackofficeBundle\Controller;
4
5
use OpenOrchestra\FunctionalTests\Utils\AbstractFormTest;
6
use OpenOrchestra\ModelInterface\Model\NodeInterface;
7
use OpenOrchestra\ModelInterface\Repository\NodeRepositoryInterface;
8
9
/**
10
 * Class EditNodeControllerTest
11
 *
12
 * @group backofficeTest
13
 */
14
class EditNodeControllerTest extends AbstractFormTest
15
{
16
    /**
17
     * @var NodeRepositoryInterface
18
     */
19
    protected $nodeRepository;
20
    protected $language = 'fr';
21
    protected $siteId = '2';
22
23
    /**
24
     * Set up the test
25
     */
26
    public function setUp()
27
    {
28
        parent::setUp();
29
        $this->nodeRepository = static::$kernel->getContainer()->get('open_orchestra_model.repository.node');
30
    }
31
32
    /**
33
     * @param string $expectedMeta
34
     * @param string $newMeta
35
     * @param string $nodeId
36
     *
37
     * @dataProvider provideMetaAndNodeId
38
     */
39
    public function testEditNode($expectedMeta, $newMeta, $nodeId)
40
    {
41
        $nodeDocument = $this->nodeRepository->findInLastVersion($nodeId, $this->language, $this->siteId);
42
43
        $url = '/admin/node/form/' . $this->siteId . '/' . $nodeDocument->getNodeId() . '/' . $this->language . '/' . $nodeDocument->getVersion();
44
45
        $crawler = $this->client->request('GET', $url);
46
        $formNode = $crawler->selectButton('Save')->form();
47
        $formNode['oo_node[metaDescription]'] = $newMeta;
48
49
        $crawler = $this->submitForm($formNode);
0 ignored issues
show
$formNode is of type array<string,string,{"oo...escription]":"string"}>, but the function expects a object<Symfony\Component\DomCrawler\Form>.

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
        $this->assertContains('alert alert-success', $this->client->getResponse()->getContent());
52
        $formNode = $crawler->selectButton('Save')->form();
53
        $this->assertSame($expectedMeta, $formNode['oo_node[metaDescription]']->getValue());
54
    }
55
56
    /**
57
     * @return array
58
     */
59
    public function provideMetaAndNodeId()
60
    {
61
        return array(
62
            array('foo', 'foo', NodeInterface::ROOT_NODE_ID),
63
            array('bar', 'bar', 'root'),
64
        );
65
    }
66
}
67