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 | namespace TildBJ\Seeder\Tests\Unit\Provider; |
||
3 | |||
4 | /*************************************************************** |
||
5 | * |
||
6 | * Copyright notice |
||
7 | * |
||
8 | * (c) 2016 Dennis Römmich <[email protected]> |
||
9 | * |
||
10 | * All rights reserved |
||
11 | * |
||
12 | * This script is part of the TYPO3 project. The TYPO3 project is |
||
13 | * free software; you can redistribute it and/or modify |
||
14 | * it under the terms of the GNU General Public License as published by |
||
15 | * the Free Software Foundation; either version 3 of the License, or |
||
16 | * (at your option) any later version. |
||
17 | * |
||
18 | * The GNU General Public License can be found at |
||
19 | * http://www.gnu.org/copyleft/gpl.html. |
||
20 | * |
||
21 | * This script is distributed in the hope that it will be useful, |
||
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
24 | * GNU General Public License for more details. |
||
25 | * |
||
26 | * This copyright notice MUST APPEAR in all copies of the script! |
||
27 | ***************************************************************/ |
||
28 | use TildBJ\Seeder\Provider\Faker; |
||
29 | use Nimut\TestingFramework\TestCase\UnitTestCase; |
||
30 | |||
31 | /** |
||
32 | * Test case for class \TildBJ\Seeder\Provider\Faker |
||
33 | * |
||
34 | * @author Dennis Römmich <[email protected]> |
||
35 | */ |
||
36 | class FakerTest extends UnitTestCase |
||
37 | { |
||
38 | /** |
||
39 | * @var Faker $subject |
||
40 | */ |
||
41 | protected $subject; |
||
42 | |||
43 | protected function setUp() |
||
44 | { |
||
45 | $faker = \Faker\Factory::create(); |
||
46 | $faker->seed(1234); |
||
47 | $this->subject = new Faker($faker); |
||
48 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['seeder']['provider']['customdata'] = |
||
49 | \TildBJ\Seeder\Tests\Unit\Provider\CustomDataProvider::class; |
||
50 | } |
||
51 | |||
52 | protected function tearDown() |
||
53 | { |
||
54 | unset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['seeder']['provider']['customdata']); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @method guessProviderName |
||
59 | * @test |
||
60 | * @throws \TildBJ\Seeder\Provider\NotFoundException |
||
61 | */ |
||
62 | public function guessProviderNameByKeyWithEmptyArgumentThrowsNotFoundException() |
||
63 | { |
||
64 | $this->expectException( |
||
65 | \TildBJ\Seeder\Provider\NotFoundException::class |
||
66 | ); |
||
67 | $this->subject->guessProviderName(''); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @method guessProviderName |
||
72 | * @test |
||
73 | * @throws \TildBJ\Seeder\Provider\NotFoundException |
||
74 | */ |
||
75 | public function guessProviderNameReturnsProvidername() |
||
76 | { |
||
77 | $this->assertSame('postcode', $this->subject->guessProviderName('zip')); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * @method guessProviderNameByKey |
||
82 | * @test |
||
83 | * @throws \TildBJ\Seeder\Provider\NotFoundException |
||
84 | */ |
||
85 | public function guessProviderNameByKeyReturnsNullIfNotFound() |
||
86 | { |
||
87 | $this->assertSame(null, $this->subject->guessProviderName('doesnotexist')); |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * @method get |
||
92 | * @test |
||
93 | * @throws \TildBJ\Seeder\Provider\NotFoundException |
||
94 | */ |
||
95 | public function getThrowsExceptionIfNoProviderWasFound() |
||
96 | { |
||
97 | $this->expectException(\TildBJ\Seeder\Provider\NotFoundException::class); |
||
98 | $this->subject->get('doesnotexist'); |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * @method get |
||
103 | * @test |
||
104 | * @throws \TildBJ\Seeder\Provider\NotFoundException |
||
105 | */ |
||
106 | public function getZipReturnsPostcode() |
||
107 | { |
||
108 | $this->assertSame('49766-3666', $this->subject->get('zip')); |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * @method get |
||
113 | * @test |
||
114 | * @throws \TildBJ\Seeder\Provider\NotFoundException |
||
115 | */ |
||
116 | public function getPostcodeReturnsPostcode() |
||
117 | { |
||
118 | $this->assertSame('49766-3666', $this->subject->get('postcode')); |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * @method get |
||
123 | * @test |
||
124 | * @throws \TildBJ\Seeder\Provider\NotFoundException |
||
125 | */ |
||
126 | public function getPostcodeWithUnderscoreReturnsPostcode() |
||
127 | { |
||
128 | $this->assertSame('49766-3666', $this->subject->get('post_code')); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @method get |
||
133 | * @test |
||
134 | * @throws \TildBJ\Seeder\Provider\NotFoundException |
||
135 | */ |
||
136 | public function getPostcodeWithWeiredCaseReturnsPostcode() |
||
137 | { |
||
138 | $this->assertSame('49766-3666', $this->subject->get('poSt_COde')); |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * @method get |
||
143 | * @test |
||
144 | * @throws \TildBJ\Seeder\Provider\NotFoundException |
||
145 | */ |
||
146 | public function getPostcodeWithUpperCaseReturnsPostcode() |
||
147 | { |
||
148 | $this->assertSame('49766-3666', $this->subject->get('POSTCODE')); |
||
149 | } |
||
150 | |||
151 | /** |
||
152 | * @method get |
||
153 | * @test |
||
154 | * @throws \TildBJ\Seeder\Provider\NotFoundException |
||
155 | */ |
||
156 | public function guessProviderNameReturnsNullWithSkippedFieldName() |
||
157 | { |
||
158 | $skippedFieldName = 'l10n_parent'; |
||
159 | $this->assertSame(null, $this->subject->guessProviderName($skippedFieldName)); |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * @method __call |
||
164 | * @test |
||
165 | */ |
||
166 | public function returnCustomDataIfCustomProviderIsAvailable() |
||
167 | { |
||
168 | $this->assertSame('customData', $this->subject->getCustomData()); |
||
0 ignored issues
–
show
|
|||
169 | } |
||
170 | } |
||
171 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: