Completed
Push — update_deploy_config ( b1a6a1...508c77 )
by amaury
03:42
created

Controller/EditNodeControllerTest.php (1 issue)

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/' . $nodeDocument->getId();
44
        $crawler = $this->client->request('GET', $url);
45
        $formNode = $crawler->selectButton('Save')->form();
46
        $formNode['oo_node[metaKeywords]'] = $newMeta;
47
48
        $crawler = $this->submitForm($formNode);
0 ignored issues
show
$formNode is of type array<string,string,{"oo...taKeywords]":"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...
49
50
        $this->assertContains('alert alert-success', $this->client->getResponse()->getContent());
51
        $formNode = $crawler->selectButton('Save')->form();
52
        $this->assertSame($expectedMeta, $formNode['oo_node[metaKeywords]']->getValue());
53
    }
54
55
    /**
56
     * @return array
57
     */
58
    public function provideMetaAndNodeId()
59
    {
60
        return array(
61
            array('foo', 'foo', NodeInterface::ROOT_NODE_ID),
62
            array('', 'bar', 'fixture_page_news'),
63
        );
64
    }
65
}
66