Issues (28)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

tests/Crud/CrudClientIntegrationTest.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 Hgraca\MicroDbal\Test\Crud;
4
5
use Hgraca\MicroDbal\Crud\CrudClient;
6
use Hgraca\MicroDbal\Crud\QueryBuilder\Sql\SqlQueryBuilder;
7
use Hgraca\MicroDbal\CrudClientInterface;
8
use Hgraca\MicroDbal\Raw\PdoClient;
9
use Hgraca\MicroDbal\Test\IntegrationTestAbstract;
10
use PDO;
11
12
final class CrudClientIntegrationTest extends IntegrationTestAbstract
13
{
14
    /** @var CrudClientInterface */
15
    private $crudClient;
16
17
    /**
18
     * @before
19
     */
20
    public function setUpCrudClient()
21
    {
22
        $dsn = 'sqlite:' . $this->getTestDbPath();
23
        $pdo = new PDO($dsn);
24
        $rawClient = new PdoClient($pdo);
25
        $this->crudClient = new CrudClient($rawClient, new SqlQueryBuilder());
26
    }
27
28
    /**
29
     * @test
30
     *
31
     * @small
32
     */
33
    public function create_ShouldCreateOneRecord()
34
    {
35
        $this->crudClient->create('Employees', self::EMPLOYEE_A);
36
        self::assertEquals(
37
            [
38
                self::EMPLOYEE_A,
39
            ],
40
            $this->crudClient->read('Employees', ['EmployeeID' => self::EMPLOYEE_A['EmployeeID']])
41
        );
42
    }
43
44
    /**
45
     * @test
46
     *
47
     * @small
48
     */
49
    public function create_ShouldCreateSeveralRecords()
50
    {
51
        $this->crudClient->create('Employees', [self::EMPLOYEE_A, self::EMPLOYEE_B]);
52
        self::assertEquals(
53
            [
54
                self::EMPLOYEE_A,
55
                self::EMPLOYEE_B,
56
            ],
57
            $this->crudClient->read(
58
                'Employees',
59
                [
60
                    'EmployeeID' => [
61
                        self::EMPLOYEE_A['EmployeeID'],
62
                        self::EMPLOYEE_B['EmployeeID'],
63
                    ],
64
                ]
65
            )
66
        );
67
    }
68
69
    /**
70
     * @test
71
     *
72
     * @small
73
     */
74
    public function read()
75
    {
76
        self::assertEquals(
77
            [
78
                self::EMPLOYEE_LIST[1],
79
                self::EMPLOYEE_LIST[2],
80
                self::EMPLOYEE_LIST[3],
81
                self::EMPLOYEE_LIST[4],
82
                self::EMPLOYEE_LIST[5],
83
                self::EMPLOYEE_LIST[6],
84
                self::EMPLOYEE_LIST[7],
85
                self::EMPLOYEE_LIST[8],
86
                self::EMPLOYEE_LIST[9],
87
            ],
88
            $this->crudClient->read('Employees')
89
        );
90
    }
91
92
    /**
93
     * @test
94
     *
95
     * @small
96
     */
97 View Code Duplication
    public function read_ShouldFilter()
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...
98
    {
99
        self::assertEquals(
100
            [
101
                self::EMPLOYEE_LIST[1],
102
                self::EMPLOYEE_LIST[8],
103
            ],
104
            $this->crudClient->read(
105
                'Employees',
106
                ['TitleOfCourtesy' => 'Ms.', 'City' => 'Seattle']
107
            )
108
        );
109
    }
110
111
    /**
112
     * @test
113
     *
114
     * @small
115
     */
116
    public function read_ShouldOrder()
117
    {
118
        self::assertEquals(
119
            [
120
                self::EMPLOYEE_LIST[2],
121
                self::EMPLOYEE_LIST[5],
122
                self::EMPLOYEE_LIST[6],
123
                self::EMPLOYEE_LIST[7],
124
                self::EMPLOYEE_LIST[4],
125
                self::EMPLOYEE_LIST[1],
126
                self::EMPLOYEE_LIST[8],
127
                self::EMPLOYEE_LIST[9],
128
                self::EMPLOYEE_LIST[3],
129
            ],
130
            $this->crudClient->read(
131
                'Employees',
132
                [],
133
                ['TitleOfCourtesy' => 'ASC', 'City' => 'DESC']
134
            )
135
        );
136
    }
137
138
    /**
139
     * @test
140
     *
141
     * @small
142
     */
143
    public function read_ShouldLimit()
144
    {
145
        self::assertEquals(
146
            [
147
                self::EMPLOYEE_LIST[1],
148
                self::EMPLOYEE_LIST[2],
149
                self::EMPLOYEE_LIST[3],
150
                self::EMPLOYEE_LIST[4],
151
            ],
152
            $this->crudClient->read(
153
                'Employees',
154
                [],
155
                [],
156
                4
157
            )
158
        );
159
    }
160
161
    /**
162
     * @test
163
     *
164
     * @small
165
     */
166 View Code Duplication
    public function read_ShouldOffset()
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...
167
    {
168
        self::assertEquals(
169
            [
170
                self::EMPLOYEE_LIST[6],
171
                self::EMPLOYEE_LIST[7],
172
            ],
173
            $this->crudClient->read(
174
                'Employees',
175
                [],
176
                [],
177
                2,
178
                5
179
            )
180
        );
181
    }
182
183
    /**
184
     * @test
185
     *
186
     * @small
187
     */
188
    public function update()
189
    {
190
        $this->crudClient->update('Employees', self::EMPLOYEE_C, ['EmployeeID' => '1']);
191
        self::assertEquals(
192
            [
193
                array_merge(self::EMPLOYEE_C, ['EmployeeID' => '1']),
194
            ],
195
            $this->crudClient->read('Employees', ['EmployeeID' => '1'])
196
        );
197
    }
198
199
    /**
200
     * @test
201
     *
202
     * @small
203
     */
204
    public function delete_DeletesOneRecord()
205
    {
206
        $this->crudClient->delete('Employees', ['EmployeeID' => '1']);
207
        self::assertEquals(
208
            [],
209
            $this->crudClient->read('Employees', ['EmployeeID' => '1'])
210
        );
211
    }
212
213
    /**
214
     * @test
215
     *
216
     * @small
217
     */
218
    public function delete_DeletesSeveralRecords()
219
    {
220
        $this->crudClient->delete('Employees', ['EmployeeID' => ['1', '2']]);
221
        self::assertEquals(
222
            [],
223
            $this->crudClient->read('Employees', ['EmployeeID' => ['1', '2']])
224
        );
225
    }
226
227
    const EMPLOYEE_LIST = [
228
        1 => [
229
            'EmployeeID' => '1',
230
            'LastName' => 'Davolio',
231
            'FirstName' => 'Nancy',
232
            'Title' => 'Sales Representative',
233
            'TitleOfCourtesy' => 'Ms.',
234
            'BirthDate' => '1948-12-08 00:00:00',
235
            'HireDate' => '1992-05-01 00:00:00',
236
            'Address' => '507 - 20th Ave. E.Apt. 2A',
237
            'City' => 'Seattle',
238
            'Region' => 'WA',
239
            'PostalCode' => '98122',
240
            'Country' => 'USA',
241
            'HomePhone' => '(206) 555-9857',
242
            'Extension' => '5467',
243
            'Photo' => '1.jpg',
244
            'Notes' => 'Education includes a BA in psychology from Colorado State University in 1970.  She also completed "The Art of the Cold Call."  Nancy is a member of Toastmasters International.',
245
            'ReportsTo' => '2',
246
            'PhotoPath' => 'http://accweb/emmployees/davolio.bmp',
247
            'Salary' => '2954.55',
248
        ],
249
        2 => [
250
            'EmployeeID' => '2',
251
            'LastName' => 'Fuller',
252
            'FirstName' => 'Andrew',
253
            'Title' => 'Vice President, Sales',
254
            'TitleOfCourtesy' => 'Dr.',
255
            'BirthDate' => '1952-02-19 00:00:00',
256
            'HireDate' => '1992-08-14 00:00:00',
257
            'Address' => '908 W. Capital Way',
258
            'City' => 'Tacoma',
259
            'Region' => 'WA',
260
            'PostalCode' => '98401',
261
            'Country' => 'USA',
262
            'HomePhone' => '(206) 555-9482',
263
            'Extension' => '3457',
264
            'Photo' => '2.jpg',
265
            'Notes' => 'Andrew received his BTS commercial in 1974 and a Ph.D. in international marketing from the University of Dallas in 1981.  He is fluent in French and Italian and reads German.  He joined the company as a sales representative, was promoted to sales manager in January 1992 and to vice president of sales in March 1993.  Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.',
266
            'ReportsTo' => null,
267
            'PhotoPath' => 'http://accweb/emmployees/fuller.bmp',
268
            'Salary' => '2254.49',
269
        ],
270
        3 => [
271
            'EmployeeID' => '3',
272
            'LastName' => 'Leverling',
273
            'FirstName' => 'Janet',
274
            'Title' => 'Sales Representative',
275
            'TitleOfCourtesy' => 'Ms.',
276
            'BirthDate' => '1963-08-30 00:00:00',
277
            'HireDate' => '1992-04-01 00:00:00',
278
            'Address' => '722 Moss Bay Blvd.',
279
            'City' => 'Kirkland',
280
            'Region' => 'WA',
281
            'PostalCode' => '98033',
282
            'Country' => 'USA',
283
            'HomePhone' => '(206) 555-3412',
284
            'Extension' => '3355',
285
            'Photo' => '3.jpg',
286
            'Notes' => 'Janet has a BS degree in chemistry from Boston College (1984).  She has also completed a certificate program in food retailing management.  Janet was hired as a sales associate in 1991 and promoted to sales representative in February 1992.',
287
            'ReportsTo' => '2',
288
            'PhotoPath' => 'http://accweb/emmployees/leverling.bmp',
289
            'Salary' => '3119.15',
290
        ],
291
        4 => [
292
            'EmployeeID' => '4',
293
            'LastName' => 'Peacock',
294
            'FirstName' => 'Margaret',
295
            'Title' => 'Sales Representative',
296
            'TitleOfCourtesy' => 'Mrs.',
297
            'BirthDate' => '1937-09-19 00:00:00',
298
            'HireDate' => '1993-05-03 00:00:00',
299
            'Address' => '4110 Old Redmond Rd.',
300
            'City' => 'Redmond',
301
            'Region' => 'WA',
302
            'PostalCode' => '98052',
303
            'Country' => 'USA',
304
            'HomePhone' => '(206) 555-8122',
305
            'Extension' => '5176',
306
            'Photo' => '4.jpg',
307
            'Notes' => 'Margaret holds a BA in English literature from Concordia College (1958) and an MA from the American Institute of Culinary Arts (1966).  She was assigned to the London office temporarily from July through November 1992.',
308
            'ReportsTo' => '2',
309
            'PhotoPath' => 'http://accweb/emmployees/peacock.bmp',
310
            'Salary' => '1861.08',
311
        ],
312
        5 => [
313
            'EmployeeID' => '5',
314
            'LastName' => 'Buchanan',
315
            'FirstName' => 'Steven',
316
            'Title' => 'Sales Manager',
317
            'TitleOfCourtesy' => 'Mr.',
318
            'BirthDate' => '1955-03-04 00:00:00',
319
            'HireDate' => '1993-10-17 00:00:00',
320
            'Address' => '14 Garrett Hill',
321
            'City' => 'London',
322
            'Region' => null,
323
            'PostalCode' => 'SW1 8JR',
324
            'Country' => 'UK',
325
            'HomePhone' => '(71) 555-4848',
326
            'Extension' => '3453',
327
            'Photo' => '5.jpg',
328
            'Notes' => 'Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree in 1976.  Upon joining the company as a sales representative in 1992, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London.  He was promoted to sales manager in March 1993.  Mr. Buchanan has completed the courses "Successful Telemarketing" and "International Sales Management."  He is fluent in French.',
329
            'ReportsTo' => '2',
330
            'PhotoPath' => 'http://accweb/emmployees/buchanan.bmp',
331
            'Salary' => '1744.21',
332
        ],
333
        6 => [
334
            'EmployeeID' => '6',
335
            'LastName' => 'Suyama',
336
            'FirstName' => 'Michael',
337
            'Title' => 'Sales Representative',
338
            'TitleOfCourtesy' => 'Mr.',
339
            'BirthDate' => '1963-07-02 00:00:00',
340
            'HireDate' => '1993-10-17 00:00:00',
341
            'Address' => 'Coventry House Miner Rd.',
342
            'City' => 'London',
343
            'Region' => null,
344
            'PostalCode' => 'EC2 7JR',
345
            'Country' => 'UK',
346
            'HomePhone' => '(71) 555-7773',
347
            'Extension' => '428',
348
            'Photo' => '6.jpg',
349
            'Notes' => 'Michael is a graduate of Sussex University (MA, economics, 1983) and the University of California at Los Angeles (MBA, marketing, 1986).  He has also taken the courses "Multi-Cultural Selling" and "Time Management for the Sales Professional."  He is fluent in Japanese and can read and write French, Portuguese, and Spanish.',
350
            'ReportsTo' => '5',
351
            'PhotoPath' => 'http://accweb/emmployees/davolio.bmp',
352
            'Salary' => '2004.07',
353
        ],
354
        7 => [
355
            'EmployeeID' => '7',
356
            'LastName' => 'King',
357
            'FirstName' => 'Robert',
358
            'Title' => 'Sales Representative',
359
            'TitleOfCourtesy' => 'Mr.',
360
            'BirthDate' => '1960-05-29 00:00:00',
361
            'HireDate' => '1994-01-02 00:00:00',
362
            'Address' => 'Edgeham Hollow Winchester Way',
363
            'City' => 'London',
364
            'Region' => null,
365
            'PostalCode' => 'RG1 9SP',
366
            'Country' => 'UK',
367
            'HomePhone' => '(71) 555-5598',
368
            'Extension' => '465',
369
            'Photo' => '7.jpg',
370
            'Notes' => 'Robert King served in the Peace Corps and traveled extensively before completing his degree in English at the University of Michigan in 1992, the year he joined the company.  After completing a course entitled "Selling in Europe," he was transferred to the London office in March 1993.',
371
            'ReportsTo' => '5',
372
            'PhotoPath' => 'http://accweb/emmployees/davolio.bmp',
373
            'Salary' => '1991.55',
374
        ],
375
        8 => [
376
            'EmployeeID' => '8',
377
            'LastName' => 'Callahan',
378
            'FirstName' => 'Laura',
379
            'Title' => 'Inside Sales Coordinator',
380
            'TitleOfCourtesy' => 'Ms.',
381
            'BirthDate' => '1958-01-09 00:00:00',
382
            'HireDate' => '1994-03-05 00:00:00',
383
            'Address' => '4726 - 11th Ave. N.E.',
384
            'City' => 'Seattle',
385
            'Region' => 'WA',
386
            'PostalCode' => '98105',
387
            'Country' => 'USA',
388
            'HomePhone' => '(206) 555-1189',
389
            'Extension' => '2344',
390
            'Photo' => '8.jpg',
391
            'Notes' => 'Laura received a BA in psychology from the University of Washington.  She has also completed a course in business French.  She reads and writes French.',
392
            'ReportsTo' => '2',
393
            'PhotoPath' => 'http://accweb/emmployees/davolio.bmp',
394
            'Salary' => '2100.5',
395
        ],
396
        9 => [
397
            'EmployeeID' => '9',
398
            'LastName' => 'Dodsworth',
399
            'FirstName' => 'Anne',
400
            'Title' => 'Sales Representative',
401
            'TitleOfCourtesy' => 'Ms.',
402
            'BirthDate' => '1966-01-27 00:00:00',
403
            'HireDate' => '1994-11-15 00:00:00',
404
            'Address' => '7 Houndstooth Rd.',
405
            'City' => 'London',
406
            'Region' => null,
407
            'PostalCode' => 'WG2 7LT',
408
            'Country' => 'UK',
409
            'HomePhone' => '(71) 555-4444',
410
            'Extension' => '452',
411
            'Photo' => '9.jpg',
412
            'Notes' => 'Anne has a BA degree in English from St. Lawrence College.  She is fluent in French and German.',
413
            'ReportsTo' => '5',
414
            'PhotoPath' => 'http://accweb/emmployees/davolio.bmp',
415
            'Salary' => '2333.33',
416
        ],
417
    ];
418
419
    const EMPLOYEE_A = [
420
        'EmployeeID' => '10',
421
        'LastName' => 'Architecture',
422
        'FirstName' => 'Lean',
423
        'Title' => 'Sales Representative',
424
        'TitleOfCourtesy' => 'Ms.',
425
        'BirthDate' => '1966-01-27 00:00:00',
426
        'HireDate' => '1994-11-15 00:00:00',
427
        'Address' => '7 Houndstooth Rd.',
428
        'City' => 'London',
429
        'Region' => null,
430
        'PostalCode' => 'WG2 7LT',
431
        'Country' => 'UK',
432
        'HomePhone' => '(71) 555-4444',
433
        'Extension' => '452',
434
        'Photo' => '10.jpg',
435
        'Notes' => '',
436
        'ReportsTo' => '5',
437
        'PhotoPath' => 'http://accweb/emmployees/architecture.bmp',
438
        'Salary' => '2333.33',
439
    ];
440
441
    const EMPLOYEE_B = [
442
        'EmployeeID' => '11',
443
        'LastName' => 'Cosburn',
444
        'FirstName' => 'Joan',
445
        'Title' => 'Sales Representative',
446
        'TitleOfCourtesy' => 'Ms.',
447
        'BirthDate' => '1966-01-27 00:00:00',
448
        'HireDate' => '1994-11-15 00:00:00',
449
        'Address' => '7 Houndstooth Rd.',
450
        'City' => 'London',
451
        'Region' => null,
452
        'PostalCode' => 'WG2 7LT',
453
        'Country' => 'UK',
454
        'HomePhone' => '(71) 555-4444',
455
        'Extension' => '452',
456
        'Photo' => '10.jpg',
457
        'Notes' => '',
458
        'ReportsTo' => '5',
459
        'PhotoPath' => 'http://accweb/emmployees/Cosburn.bmp',
460
        'Salary' => '2333.33',
461
    ];
462
463
    const EMPLOYEE_C = [
464
        'LastName' => 'Cosburn',
465
        'FirstName' => 'Joan',
466
        'Title' => 'Sales Representative',
467
        'TitleOfCourtesy' => 'Ms.',
468
        'BirthDate' => '1966-01-27 00:00:00',
469
        'HireDate' => '1994-11-15 00:00:00',
470
        'Address' => '7 Houndstooth Rd.',
471
        'City' => 'London',
472
        'Region' => null,
473
        'PostalCode' => 'WG2 7LT',
474
        'Country' => 'UK',
475
        'HomePhone' => '(71) 555-4444',
476
        'Extension' => '452',
477
        'Photo' => '10.jpg',
478
        'Notes' => '',
479
        'ReportsTo' => '5',
480
        'PhotoPath' => 'http://accweb/emmployees/Cosburn.bmp',
481
        'Salary' => '2333.33',
482
    ];
483
}
484