This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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\GroupBundle\Repository; |
||
4 | |||
5 | use OpenOrchestra\Backoffice\Repository\GroupRepositoryInterface; |
||
6 | use OpenOrchestra\BaseBundle\Tests\AbstractTest\AbstractKernelTestCase; |
||
7 | use OpenOrchestra\ModelBundle\Repository\SiteRepository; |
||
8 | use OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration; |
||
9 | use OpenOrchestra\GroupBundle\Document\Group; |
||
10 | |||
11 | /** |
||
12 | * Class GroupRepositoryTest |
||
13 | * |
||
14 | * @group integrationTest |
||
15 | */ |
||
16 | class GroupRepositoryTest extends AbstractKernelTestCase |
||
17 | { |
||
18 | /** |
||
19 | * @var GroupRepositoryInterface |
||
20 | */ |
||
21 | protected $repository; |
||
22 | |||
23 | /** |
||
24 | * @var SiteRepository |
||
25 | */ |
||
26 | protected $siteRepository; |
||
27 | |||
28 | /** |
||
29 | * Set up test |
||
30 | */ |
||
31 | View Code Duplication | protected function setUp() |
|
32 | { |
||
33 | parent::setUp(); |
||
34 | |||
35 | static::bootKernel(); |
||
36 | $this->repository = static::$kernel->getContainer()->get('open_orchestra_user.repository.group'); |
||
37 | $this->siteRepository = static::$kernel->getContainer()->get('open_orchestra_model.repository.site'); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @param PaginateFinderConfiguration $configuration |
||
42 | * @param array $siteIds |
||
43 | * @param int $count |
||
44 | * |
||
45 | * @dataProvider provideConfigurationAndSites |
||
46 | */ |
||
47 | public function testFindForPaginate(PaginateFinderConfiguration $configuration, array $siteIds, $count) |
||
48 | { |
||
49 | $siteIds = $this->generateMongoIdForSite($siteIds); |
||
50 | $groups = $this->repository->findForPaginate($configuration, $siteIds); |
||
51 | |||
52 | $this->assertCount($count, $groups); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * test count all user |
||
57 | * |
||
58 | * @param PaginateFinderConfiguration $configuration |
||
59 | * @param array $siteIds |
||
60 | * @param int $count |
||
61 | * |
||
62 | * @dataProvider provideConfigurationAndSites |
||
63 | */ |
||
64 | public function testCount(PaginateFinderConfiguration $configuration, array $siteIds, $count) |
||
65 | { |
||
66 | $siteIds = $this->generateMongoIdForSite($siteIds); |
||
67 | $groups = $this->repository->count($siteIds); |
||
68 | |||
69 | $this->assertEquals($count, $groups); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @return array |
||
74 | */ |
||
75 | public function provideConfigurationAndSites() |
||
76 | { |
||
77 | $configuration = new PaginateFinderConfiguration(); |
||
78 | $configuration->setPaginateConfiguration(null, 0, 100, array('label' => 'labels')); |
||
79 | return array( |
||
80 | array($configuration, array(), 0), |
||
81 | array($configuration, array('2'), 2), |
||
82 | array($configuration, array('2', '3'), 3), |
||
83 | array($configuration, array('test'), 0), |
||
84 | ); |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * @param PaginateFinderConfiguration $configuration |
||
89 | * @param array $siteIds |
||
90 | * @param int $count |
||
91 | * |
||
92 | * @dataProvider provideColumnsAndSearchAndCount |
||
93 | */ |
||
94 | public function testCountWithFilter(PaginateFinderConfiguration $configuration, array $siteIds, $count) |
||
95 | { |
||
96 | $siteIds = $this->generateMongoIdForSite($siteIds); |
||
97 | $groups = $this->repository->countWithFilter($configuration, $siteIds); |
||
98 | |||
99 | $this->assertEquals($count, $groups); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * @return array |
||
104 | */ |
||
105 | public function provideColumnsAndSearchAndCount(){ |
||
106 | |||
107 | $configuration = new PaginateFinderConfiguration(); |
||
108 | $configuration->setPaginateConfiguration(null, 0, 100, array('label' => 'labels')); |
||
109 | |||
110 | $configuration->setSearch(array('language' => 'en', 'label' => 'site')); |
||
111 | |||
112 | return array( |
||
113 | array($configuration, array(), 0), |
||
114 | array($configuration, array('2'), 1), |
||
115 | array($configuration, array('2', '3'), 1), |
||
116 | array($configuration, array('test'), 0), |
||
117 | ); |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * Test remove users |
||
122 | */ |
||
123 | public function testRemoveGroups() |
||
124 | { |
||
125 | $dm = static::$kernel->getContainer()->get('object_manager'); |
||
126 | |||
127 | $groupTest = new Group(); |
||
128 | $groupTest->setName('test'); |
||
129 | $dm->persist($groupTest); |
||
130 | $dm->flush(); |
||
131 | $dm->clear(); |
||
132 | |||
133 | $groupTest = $this->repository->findOneByName('test'); |
||
0 ignored issues
–
show
|
|||
134 | $groupIds = array($groupTest->getId()); |
||
135 | $this->repository->removeGroups($groupIds); |
||
136 | $dm->clear(); |
||
137 | $group = $this->repository->findOneByName('test'); |
||
0 ignored issues
–
show
The method
findOneByName() does not seem to exist on object<OpenOrchestra\Bac...oupRepositoryInterface> .
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...
|
|||
138 | $this->assertEquals(true, $group->isDeleted()); |
||
139 | $dm->remove($group); |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * Test remove users |
||
144 | */ |
||
145 | public function testSoftDeleteGroupBySite() |
||
146 | { |
||
147 | $dm = static::$kernel->getContainer()->get('object_manager'); |
||
148 | $site = $this->siteRepository->findOneBySiteId('3'); |
||
149 | $this->repository->softDeleteGroupsBySite($site); |
||
0 ignored issues
–
show
It seems like
$site defined by $this->siteRepository->findOneBySiteId('3') on line 148 can be null ; however, OpenOrchestra\Backoffice...oftDeleteGroupsBySite() does not accept null , maybe add an additional type check?
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: /** @return stdClass|null */
function mayReturnNull() { }
function doesNotAcceptNull(stdClass $x) { }
// With potential error.
function withoutCheck() {
$x = mayReturnNull();
doesNotAcceptNull($x); // Potential error here.
}
// Safe - Alternative 1
function withCheck1() {
$x = mayReturnNull();
if ( ! $x instanceof stdClass) {
throw new \LogicException('$x must be defined.');
}
doesNotAcceptNull($x);
}
// Safe - Alternative 2
function withCheck2() {
$x = mayReturnNull();
if ($x instanceof stdClass) {
doesNotAcceptNull($x);
}
}
Loading history...
|
|||
150 | |||
151 | $groups = $this->repository->findBy( |
||
152 | array('site.$id' => new \MongoId($site->getId())) |
||
153 | ); |
||
154 | |||
155 | foreach ($groups as $group) { |
||
156 | $this->assertTrue($group->isDeleted()); |
||
157 | $group->setDeleted(false); |
||
158 | } |
||
159 | $dm->flush(); |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * Generate columns of content with search value |
||
164 | * |
||
165 | * @param string $searchName |
||
166 | * @param string $globalSearch |
||
167 | * |
||
168 | * @return array |
||
169 | */ |
||
170 | protected function generateSearchProvider($searchName = '', $globalSearch = '') |
||
171 | { |
||
172 | $search = array(); |
||
173 | if (!empty($searchName)) { |
||
174 | $search['columns'] = array('name' => $searchName); |
||
175 | } |
||
176 | if (!empty($globalSearch)) { |
||
177 | $search['global'] = $globalSearch; |
||
178 | } |
||
179 | |||
180 | return $search; |
||
181 | } |
||
182 | |||
183 | /** |
||
184 | * @param array $siteIds |
||
185 | * |
||
186 | * @return array |
||
187 | */ |
||
188 | protected function generateMongoIdForSite(array $siteIds) |
||
189 | { |
||
190 | foreach ($siteIds as $key => $siteId) { |
||
191 | $site = $this->siteRepository->findOneBySiteId($siteId); |
||
192 | if (null !== $site) { |
||
193 | $siteIds[$key] = $site->getId(); |
||
194 | } else { |
||
195 | unset($siteIds[$key]); |
||
196 | } |
||
197 | } |
||
198 | |||
199 | return $siteIds; |
||
200 | } |
||
201 | |||
202 | /** |
||
203 | * Generate relation between columns names and entities attributes |
||
204 | * |
||
205 | * @return array |
||
206 | */ |
||
207 | protected function getDescriptionColumnEntity() |
||
208 | { |
||
209 | |||
210 | return array( |
||
211 | 'name' => array('key' => 'name', 'field' => 'name', 'type' => 'string') |
||
212 | ); |
||
213 | } |
||
214 | |||
215 | } |
||
216 |
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.