Issues (115)

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/src/AbstractDataMapperTest.php (18 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 SimpleORM;
4
5
/**
6
 * Generated by PHPUnit_SkeletonGenerator on 2015-12-09 at 18:42:14.
7
 */
8
class AbstractDataMapperTest extends \PHPUnit_Framework_TestCase
9
{
10
11
	
12
	/**
13
	 * @var AbstractDataMapper
14
	 */
15
	protected $object;
16
17
	/**
18
	 * Sets up the fixture, for example, opens a network connection.
19
	 * This method is called before a test is executed.
20
	 */
21
	protected function setUp()
22
	{
23
		$this->object = $this->getMockBuilder('SimpleORM\AbstractDataMapper')
24
						//->disableOriginalConstructor()//можно отключать
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
25
//						->setConstructorArgs([
26
//							$DI, 
27
//							$adapter
28
//								])//в конструктор
29
						->disableOriginalConstructor()
30
						//->setMethods(null)
31
						->setMethods(['setMappingFields','createEntity'])
32
						//->setMethods(null) //не использовать заглушки методов иначе буде возвращать NULL
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
33
						->getMock();
34
	}
35
36
	/**
37
	 * Tears down the fixture, for example, closes a network connection.
38
	 * This method is called after a test is executed.
39
	 */
40
	protected function tearDown()
41
	{
42
		
43
	}
44
	
45
	/**
46
	 * @covers SimpleORM\AbstractDataMapper::AddMappingField
47
	 */
48 View Code Duplication
	public function testAddMappingField_SimpleField(){
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...
49
		
50
		\TestHelper::callMethod($this->object,'addMappingField',['myfield']);
51
		
52
		$correct = [
53
			  'myfield'	=>	[
54
				  'field'	=>	'myfield'
55
			  ]
56
		  ];
57
		
58
		//-----------------
59
		$mapping_fields = \TestHelper::getProtectedAttribute($this->object,'mapping_fields');
0 ignored issues
show
'mapping_fields' is of type string, but the function expects a object<type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
60
61
        $this->assertEquals($mapping_fields, $correct);		
62
	}		
63
	
64
	/**
65
	 * @covers SimpleORM\AbstractDataMapper::AddMappingField
66
	 */
67 View Code Duplication
	public function testAddMappingField_FieldAndAlias(){
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...
68
		
69
		\TestHelper::callMethod($this->object,'addMappingField',['myfield','tb_mayfield']);
70
		
71
		$correct = [
72
			  'myfield'	=>	[
73
				  'field'	=>	'tb_mayfield'
74
			  ]
75
		  ];
76
		
77
		//-----------------
78
		$mapping_fields = \TestHelper::getProtectedAttribute($this->object,'mapping_fields');
0 ignored issues
show
'mapping_fields' is of type string, but the function expects a object<type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
79
80
        $this->assertEquals($mapping_fields, $correct);		
81
	}		
82
83
	/**
84
	 * @covers SimpleORM\AbstractDataMapper::AddMappingField
85
	 */
86 View Code Duplication
	public function testAddMappingField_ArrayField(){
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...
87
		
88
		\TestHelper::callMethod($this->object,'addMappingField',['myfield',[
89
			'field'	=>	'tb_mayfield'
90
		]]);
91
		
92
		$correct = [
93
			  'myfield'	=>	[
94
				  'field'	=>	'tb_mayfield'
95
			  ]
96
		  ];
97
		
98
		//-----------------
99
		$mapping_fields = \TestHelper::getProtectedAttribute($this->object,'mapping_fields');
0 ignored issues
show
'mapping_fields' is of type string, but the function expects a object<type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
100
101
        $this->assertEquals($mapping_fields, $correct);		
102
	}	
103
	
104
	/**
105
	 * @covers SimpleORM\AbstractDataMapper::AddMappingField
106
	 */
107 View Code Duplication
	public function testAddMappingField_PrimaryKey(){
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...
108
		
109
		\TestHelper::callMethod($this->object,'addMappingField',['myfield',[
110
			'field'		=>	'tb_mayfield',
111
			'primary'	=>	true
112
		]]);
113
		
114
		$correct = [
115
			  'myfield'	=>	[
116
				  'field'	=>	'tb_mayfield',
117
				  'primary'	=>	true
118
			  ]
119
		  ];
120
		
121
		//-----------------
122
		$mapping_fields = \TestHelper::getProtectedAttribute($this->object,'mapping_fields');
0 ignored issues
show
'mapping_fields' is of type string, but the function expects a object<type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
123
124
        $this->assertEquals($mapping_fields, $correct);		
125
		
126
		$key_field = \TestHelper::getProtectedAttribute($this->object,'key');
0 ignored issues
show
'key' is of type string, but the function expects a object<type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
127
		$this->assertEquals($key_field, 'tb_mayfield');	
128
	}	
129
	
130
	/**
131
	 * @covers SimpleORM\AbstractDataMapper::AddMappingField
132
	 */
133 View Code Duplication
	public function testAddMappingField_SoftDelete(){
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...
134
		
135
		\TestHelper::callMethod($this->object,'addMappingField',['myfield',[
136
			'field'			=>	'tb_mayfield',
137
			'softdelete'	=>	true
138
		]]);
139
		
140
		$correct = [
141
			  'myfield'	=>	[
142
				  'field'	=>	'tb_mayfield',
143
				  'softdelete'	=>	true
144
			  ]
145
		  ];
146
		
147
		//-----------------
148
		$mapping_fields = \TestHelper::getProtectedAttribute($this->object,'mapping_fields');
0 ignored issues
show
'mapping_fields' is of type string, but the function expects a object<type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
149
150
        $this->assertEquals($mapping_fields, $correct);		
151
		
152
		$soft_delete_key = \TestHelper::getProtectedAttribute($this->object,'soft_delete_key');
0 ignored issues
show
'soft_delete_key' is of type string, but the function expects a object<type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
153
		$this->assertEquals($soft_delete_key, 'tb_mayfield');	
154
	}	
155
	
156
	/**
157
	 * @covers SimpleORM\AbstractDataMapper::getPrimaryKey
158
	 */
159
	public function testGetPrimaryKey()
160
	{
161
		\TestHelper::setValueprotectedProperty($this->object,'key','tst_id');
0 ignored issues
show
'key' is of type string, but the function expects a object<type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
162
		$this->assertEquals(\TestHelper::callMethod($this->object,'GetPrimaryKey'), 'tst_id');	
163
	}
164
	
165
	/**
166
	 * @covers SimpleORM\AbstractDataMapper::setSoftDeleteKey
167
	 */
168
	public function testsetSoftDeleteKey()
169
	{
170
		\TestHelper::setValueprotectedProperty($this->object,'soft_delete_key','stc_deleted');
0 ignored issues
show
'soft_delete_key' is of type string, but the function expects a object<type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
171
		$this->assertEquals(\TestHelper::callMethod($this->object,'setSoftDeleteKey'), 'stc_deleted');	
172
	}	
173
	
174
	/**
175
	 *  @covers SimpleORM\AbstractDataMapper::getFieldAlias
176
	 */
177 View Code Duplication
	public function testGetFieldAlias(){
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...
178
		$mapping_fields_aliases = [
179
			'name'	=>	'stc_fullname'
180
		];
181
		\TestHelper::setValueprotectedProperty($this->object,'mapping_fields_aliases',$mapping_fields_aliases);
0 ignored issues
show
'mapping_fields_aliases' is of type string, but the function expects a object<type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
182
		$this->assertEquals(\TestHelper::callMethod($this->object,'getFieldAlias',['name']), 'stc_fullname');
183
	}
184
	
185
	
186
	/**
187
	 * @covers SimpleORM\AbstractDataMapper::getAdapter
188
	 * @todo   Implement testGetAdapter().
189
	 */
190
	public function testGetAdapter()
191
	{
192
		// Remove the following lines when you implement this test.
193
		$this->markTestIncomplete(
194
				'This test has not been implemented yet.'
195
		);
196
	}
197
198
	/**
199
	 * @covers SimpleORM\AbstractDataMapper::setAdapter
200
	 * @todo   Implement testSetAdapter().
201
	 */
202
	public function testSetAdapter()
203
	{
204
		// Remove the following lines when you implement this test.
205
		$this->markTestIncomplete(
206
				'This test has not been implemented yet.'
207
		);
208
	}
209
210
	/**
211
	 * @covers SimpleORM\AbstractDataMapper::findById
212
	 * @todo   Implement testFindById().
213
	 */
214
	public function testFindById()
215
	{
216
		// Remove the following lines when you implement this test.
217
		$this->markTestIncomplete(
218
				'This test has not been implemented yet.'
219
		);
220
	}
221
222
	/**
223
	 * @covers SimpleORM\AbstractDataMapper::save
224
	 * @todo   Implement testSave().
225
	 */
226
	public function testSave()
227
	{
228
		// Remove the following lines when you implement this test.
229
		$this->markTestIncomplete(
230
				'This test has not been implemented yet.'
231
		);
232
	}
233
234
235
	/**
236
	 * @covers SimpleORM\AbstractDataMapper::findBySpecification
237
	 * @todo   Implement testFindBySpecification().
238
	 */
239
	public function testFindBySpecification()
240
	{
241
		// Remove the following lines when you implement this test.
242
		$this->markTestIncomplete(
243
				'This test has not been implemented yet.'
244
		);
245
	}
246
247
	/**
248
	 * @covers SimpleORM\AbstractDataMapper::delete
249
	 * @todo   Implement testDelete().
250
	 */
251
	public function testDelete()
252
	{
253
		// Remove the following lines when you implement this test.
254
		$this->markTestIncomplete(
255
				'This test has not been implemented yet.'
256
		);
257
	}
258
259
	/**
260
	 * @covers SimpleORM\AbstractDataMapper::findAllBySpecification
261
	 * @todo   Implement testFindAllBySpecification().
262
	 */
263
	public function testFindAllBySpecification()
264
	{
265
		// Remove the following lines when you implement this test.
266
		$this->markTestIncomplete(
267
				'This test has not been implemented yet.'
268
		);
269
	}
270
271
	/**
272
	 * @covers SimpleORM\AbstractDataMapper::findAll
273
	 * @todo   Implement testFindAll().
274
	 */
275
	public function testFindAll()
276
	{
277
		// Remove the following lines when you implement this test.
278
		$this->markTestIncomplete(
279
				'This test has not been implemented yet.'
280
		);
281
	}
282
283
	/**
284
	 * @covers SimpleORM\AbstractDataMapper::useJoins
285
	 * @todo   Implement testUseJoins().
286
	 */
287
	public function testUseJoins()
288
	{
289
		// Remove the following lines when you implement this test.
290
		$this->markTestIncomplete(
291
				'This test has not been implemented yet.'
292
		);
293
	}
294
295
	/**
296
	 * @covers SimpleORM\AbstractDataMapper::withDelete
297
	 * @todo   Implement testWithDelete().
298
	 */
299
	public function testWithDelete()
300
	{
301
		// Remove the following lines when you implement this test.
302
		$this->markTestIncomplete(
303
				'This test has not been implemented yet.'
304
		);
305
	}
306
}
307