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 | * @param bool $currentlyPublished |
||
37 | * |
||
38 | * @dataProvider provideStatusName |
||
39 | */ |
||
40 | View Code Duplication | public function testChangeContentStatus($name, $currentlyPublished) |
|
0 ignored issues
–
show
|
|||
41 | { |
||
42 | $content = $this->contentRepository->findOneByLanguageAndVersion('206_3_portes', 'fr', 2); |
||
43 | $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...
|
|||
44 | $newStatusId = $newStatus->getId(); |
||
45 | |||
46 | $this->client->request( |
||
47 | 'POST', |
||
48 | '/api/content/' . $content->getId() . '/update', |
||
49 | array(), |
||
50 | array(), |
||
51 | array(), |
||
52 | json_encode(array('status_id' => $newStatusId)) |
||
53 | ); |
||
54 | |||
55 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); |
||
56 | |||
57 | $newcontent = $this->contentRepository->findOneByLanguageAndVersion('206_3_portes', 'fr', 2); |
||
58 | $this->assertEquals($currentlyPublished, $newcontent->isCurrentlyPublished()); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @return array |
||
63 | */ |
||
64 | public function provideStatusName() |
||
65 | { |
||
66 | return array( |
||
67 | array('draft', false), |
||
68 | array('pending', false), |
||
69 | array('published', true), |
||
70 | ); |
||
71 | } |
||
72 | } |
||
73 |
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.