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

ApiBundle/Controller/ContentControllerTest.php (2 issues)

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\ApiBundle\Controller;
4
5
use OpenOrchestra\FunctionalTests\Utils\AbstractAuthenticatedTest;
6
use OpenOrchestra\ModelInterface\Repository\ContentRepositoryInterface;
7
use OpenOrchestra\ModelInterface\Repository\StatusRepositoryInterface;
8
9
/**
10
 * Class ContentControllerTest
11
 */
12
class ContentControllerTest extends AbstractAuthenticatedTest
13
{
14
    /**
15
     * @var StatusRepositoryInterface
16
     */
17
    protected $statusRepository;
18
19
    /**
20
     * @var ContentRepositoryInterface
21
     */
22
    protected $contentRepository;
23
24
    /**
25
     * Set up the test
26
     */
27
    public function setUp()
28
    {
29
        parent::setUp();
30
        $this->contentRepository = static::$kernel->getContainer()->get('open_orchestra_model.repository.content');
31
        $this->statusRepository = static::$kernel->getContainer()->get('open_orchestra_model.repository.status');
32
    }
33
34
    /**
35
     * @param string $name
36
     *
37
     * @dataProvider provideStatusName
38
     */
39 View Code Duplication
    public function testChangeContentStatus($name)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        $content = $this->contentRepository->findOneByLanguageAndVersion('206_3_portes', 'fr', '2');
42
        $newStatus = $this->statusRepository->findOneByName($name);
0 ignored issues
show
The method findOneByName() does not seem to exist on object<OpenOrchestra\Mod...tusRepositoryInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
44
        $content->setStatus($newStatus);
45
        $this->client->request(
46
            'PUT',
47
            '/api/content/update-status',
48
            array(),
49
            array(),
50
            array(),
51
            static::$kernel->getContainer()->get('jms_serializer')->serialize($content, 'json')
52
        );
53
54
        $this->assertSame(200, $this->client->getResponse()->getStatusCode());
55
56
        $newContent = $this->contentRepository->findOneByLanguageAndVersion('206_3_portes', 'fr', '2');
57
        $this->assertSame($name, $newContent->getStatus()->getName());
58
    }
59
60
    /**
61
     * @return array
62
     */
63
    public function provideStatusName()
64
    {
65
        return array(
66
            array('draft'),
67
            array('pending'),
68
            array('published'),
69
        );
70
    }
71
}
72