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 FlexyProject\GitHub\Tests\Receiver; |
||
3 | |||
4 | use FlexyProject\GitHub\{ |
||
5 | Client, Receiver\Miscellaneous, Tests\AbstractClientTest |
||
6 | }; |
||
7 | |||
8 | /** |
||
9 | * Class MiscellaneousTest |
||
10 | * |
||
11 | * @package FlexyProject\GitHub\Tests |
||
12 | */ |
||
13 | class MiscellaneousTest extends AbstractClientTest |
||
14 | { |
||
15 | |||
16 | /** @var Miscellaneous */ |
||
17 | protected $miscellaneous; |
||
18 | |||
19 | /** @var Miscellaneous\Emojis */ |
||
20 | protected $emojis; |
||
21 | |||
22 | /** @var Miscellaneous\Gitignore */ |
||
23 | protected $gitIgnore; |
||
24 | |||
25 | /** @var Miscellaneous\Licenses */ |
||
26 | protected $licenses; |
||
27 | |||
28 | /** @var Miscellaneous\Markdown */ |
||
29 | protected $markdown; |
||
30 | |||
31 | /** @var Miscellaneous\Meta */ |
||
32 | protected $meta; |
||
33 | |||
34 | /** @var Miscellaneous\RateLimit */ |
||
35 | protected $rateLimit; |
||
36 | |||
37 | /** |
||
38 | * MiscellaneousTest constructor. |
||
39 | * |
||
40 | * @param null $name |
||
41 | * @param array $data |
||
42 | * @param string $dataName |
||
43 | */ |
||
44 | public function __construct($name = null, array $data = [], $dataName = '') |
||
45 | { |
||
46 | parent::__construct($name, $data, $dataName); |
||
47 | |||
48 | // Miscellaneous |
||
49 | $this->miscellaneous = $this->client->getReceiver(Client::MISCELLANEOUS); |
||
50 | |||
51 | // Emojis |
||
52 | $this->emojis = $this->miscellaneous->getReceiver(Miscellaneous::EMOJIS); |
||
53 | |||
54 | // GitIgnore |
||
55 | $this->gitIgnore = $this->miscellaneous->getReceiver(Miscellaneous::GITIGNORE); |
||
56 | |||
57 | // Licenses |
||
58 | $this->licenses = $this->miscellaneous->getReceiver(Miscellaneous::LICENSES); |
||
59 | |||
60 | // Markdown |
||
61 | $this->markdown = $this->miscellaneous->getReceiver(Miscellaneous::MARKDOWN); |
||
62 | |||
63 | // Meta |
||
64 | $this->meta = $this->miscellaneous->getReceiver(Miscellaneous::META); |
||
65 | |||
66 | // RateLimit |
||
67 | $this->rateLimit = $this->miscellaneous->getReceiver(Miscellaneous::RATE_LIMIT); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Test instance of Miscellaneous's class |
||
72 | */ |
||
73 | public function testMiscellaneous() |
||
74 | { |
||
75 | $this->assertInstanceOf(Miscellaneous::class, $this->miscellaneous); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * Test instance of Emojis's class |
||
80 | */ |
||
81 | public function testEmojis() |
||
82 | { |
||
83 | $this->assertInstanceOf(Miscellaneous\Emojis::class, $this->emojis); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Test instance of Gitignore's class |
||
88 | */ |
||
89 | public function testGitIgnore() |
||
90 | { |
||
91 | $this->assertInstanceOf(Miscellaneous\Gitignore::class, $this->gitIgnore); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * Test instance of Licenses's class |
||
96 | */ |
||
97 | public function testLicenses() |
||
98 | { |
||
99 | $this->assertInstanceOf(Miscellaneous\Licenses::class, $this->licenses); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * Test instance of Markdown's class |
||
104 | */ |
||
105 | public function testMarkdown() |
||
106 | { |
||
107 | $this->assertInstanceOf(Miscellaneous\Markdown::class, $this->markdown); |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * Test instance of Meta's class |
||
112 | */ |
||
113 | public function testMeta() |
||
114 | { |
||
115 | $this->assertInstanceOf(Miscellaneous\Meta::class, $this->meta); |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * Test instance of 's class |
||
120 | */ |
||
121 | public function testRateLimit() |
||
122 | { |
||
123 | $this->assertInstanceOf(Miscellaneous\RateLimit::class, $this->rateLimit); |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * Test list available Emojis |
||
128 | */ |
||
129 | public function testGetListEmojis() |
||
130 | { |
||
131 | $this->assertCount(1508, $this->emojis->get()); |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * Test listing available templates |
||
136 | */ |
||
137 | public function testListingAvailableTemplates() |
||
138 | { |
||
139 | $templates = $this->gitIgnore->listingAvailableTemplates(); |
||
140 | |||
141 | $this->assertContains('Android', $templates); |
||
142 | } |
||
143 | |||
144 | /** |
||
145 | * Test getting a single template |
||
146 | */ |
||
147 | public function testGetSingleTemplate() |
||
148 | { |
||
149 | $template = $this->gitIgnore->getSingleTemplate('Android'); |
||
150 | |||
151 | $this->assertArrayHasKey('name', $template); |
||
152 | $this->assertArrayHasKey('source', $template); |
||
153 | } |
||
154 | |||
155 | /** |
||
156 | * Test listing all licenses |
||
157 | */ |
||
158 | public function testListAllLicenses() |
||
159 | { |
||
160 | $licenses = $this->licenses->listAllLicenses(); |
||
161 | $license = array_pop($licenses); |
||
162 | |||
163 | $this->assertArrayHasKey('key', $license); |
||
164 | $this->assertArrayHasKey('name', $license); |
||
165 | $this->assertArrayHasKey('spdx_id', $license); |
||
166 | $this->assertArrayHasKey('url', $license); |
||
167 | $this->assertArrayHasKey('featured', $license); |
||
168 | } |
||
169 | |||
170 | /** |
||
171 | * Test getting individual license |
||
172 | */ |
||
173 | public function testGettingIndividualLicense() |
||
174 | { |
||
175 | $license = $this->licenses->getIndividualLicense('mit'); |
||
176 | |||
177 | $this->assertArrayHasKey('body', $license); |
||
178 | } |
||
179 | |||
180 | /** |
||
181 | * Test render markdown text |
||
182 | */ |
||
183 | View Code Duplication | public function testRender() |
|
0 ignored issues
–
show
|
|||
184 | { |
||
185 | $output = $this->markdown->render('Hello world FlexyProject/GitHubAPI#43 **cool**, and #43!'); |
||
186 | |||
187 | $this->assertEquals('<p>Hello world FlexyProject/GitHubAPI#43 <strong>cool</strong>, and #43!</p>', |
||
188 | str_replace(["\r\n", "\r", "\n"], "", $output[0])); |
||
189 | } |
||
190 | |||
191 | /** |
||
192 | * Test render markdown raw text |
||
193 | */ |
||
194 | View Code Duplication | public function testRenderRaw() |
|
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. ![]() |
|||
195 | { |
||
196 | $output = $this->markdown->renderRaw('**cool**'); |
||
197 | |||
198 | $this->assertEquals('<p>{"file":"<strong>cool</strong>"}</p>', |
||
199 | str_replace(["\r\n", "\r", "\n"], "", $output[0])); |
||
200 | } |
||
201 | |||
202 | /** |
||
203 | * Test getting meta about GitHub.com |
||
204 | */ |
||
205 | public function testGetMeta() |
||
206 | { |
||
207 | $meta = $this->meta->get(); |
||
208 | |||
209 | $this->assertTrue($meta['verifiable_password_authentication']); |
||
210 | } |
||
211 | |||
212 | /** |
||
213 | * Test rate limit |
||
214 | */ |
||
215 | public function testRate() |
||
216 | { |
||
217 | $rateLimit = $this->rateLimit->get(); |
||
218 | |||
219 | $this->assertArrayHasKey('rate', $rateLimit); |
||
220 | } |
||
221 | } |
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.