Passed
Push — master ( 252c51...fbb2a0 )
by dima
06:40
created

testAddMappingField_PrimaryKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 12

Duplication

Lines 22
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 22
loc 22
rs 9.2
cc 1
eloc 12
nc 1
nop 0
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
62% 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
84% 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
Duplication introduced by
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
Documentation introduced by
'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
Duplication introduced by
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
Documentation introduced by
'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
Duplication introduced by
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
Documentation introduced by
'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
Duplication introduced by
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
Documentation introduced by
'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
Documentation introduced by
'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
Duplication introduced by
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
Documentation introduced by
'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
Documentation introduced by
'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::getAdapter
158
	 * @todo   Implement testGetAdapter().
159
	 */
160
	public function testGetAdapter()
161
	{
162
		// Remove the following lines when you implement this test.
163
		$this->markTestIncomplete(
164
				'This test has not been implemented yet.'
165
		);
166
	}
167
168
	/**
169
	 * @covers SimpleORM\AbstractDataMapper::setAdapter
170
	 * @todo   Implement testSetAdapter().
171
	 */
172
	public function testSetAdapter()
173
	{
174
		// Remove the following lines when you implement this test.
175
		$this->markTestIncomplete(
176
				'This test has not been implemented yet.'
177
		);
178
	}
179
180
	/**
181
	 * @covers SimpleORM\AbstractDataMapper::findById
182
	 * @todo   Implement testFindById().
183
	 */
184
	public function testFindById()
185
	{
186
		// Remove the following lines when you implement this test.
187
		$this->markTestIncomplete(
188
				'This test has not been implemented yet.'
189
		);
190
	}
191
192
	/**
193
	 * @covers SimpleORM\AbstractDataMapper::save
194
	 * @todo   Implement testSave().
195
	 */
196
	public function testSave()
197
	{
198
		// Remove the following lines when you implement this test.
199
		$this->markTestIncomplete(
200
				'This test has not been implemented yet.'
201
		);
202
	}
203
204
	/**
205
	 * @covers SimpleORM\AbstractDataMapper::getFieldAlias
206
	 * @todo   Implement testGetFieldAlias().
207
	 */
208
	public function testGetFieldAlias()
209
	{
210
		// Remove the following lines when you implement this test.
211
		$this->markTestIncomplete(
212
				'This test has not been implemented yet.'
213
		);
214
	}
215
216
	/**
217
	 * @covers SimpleORM\AbstractDataMapper::findBySpecification
218
	 * @todo   Implement testFindBySpecification().
219
	 */
220
	public function testFindBySpecification()
221
	{
222
		// Remove the following lines when you implement this test.
223
		$this->markTestIncomplete(
224
				'This test has not been implemented yet.'
225
		);
226
	}
227
228
	/**
229
	 * @covers SimpleORM\AbstractDataMapper::delete
230
	 * @todo   Implement testDelete().
231
	 */
232
	public function testDelete()
233
	{
234
		// Remove the following lines when you implement this test.
235
		$this->markTestIncomplete(
236
				'This test has not been implemented yet.'
237
		);
238
	}
239
240
	/**
241
	 * @covers SimpleORM\AbstractDataMapper::findAllBySpecification
242
	 * @todo   Implement testFindAllBySpecification().
243
	 */
244
	public function testFindAllBySpecification()
245
	{
246
		// Remove the following lines when you implement this test.
247
		$this->markTestIncomplete(
248
				'This test has not been implemented yet.'
249
		);
250
	}
251
252
	/**
253
	 * @covers SimpleORM\AbstractDataMapper::findAll
254
	 * @todo   Implement testFindAll().
255
	 */
256
	public function testFindAll()
257
	{
258
		// Remove the following lines when you implement this test.
259
		$this->markTestIncomplete(
260
				'This test has not been implemented yet.'
261
		);
262
	}
263
264
	/**
265
	 * @covers SimpleORM\AbstractDataMapper::useJoins
266
	 * @todo   Implement testUseJoins().
267
	 */
268
	public function testUseJoins()
269
	{
270
		// Remove the following lines when you implement this test.
271
		$this->markTestIncomplete(
272
				'This test has not been implemented yet.'
273
		);
274
	}
275
276
	/**
277
	 * @covers SimpleORM\AbstractDataMapper::withDelete
278
	 * @todo   Implement testWithDelete().
279
	 */
280
	public function testWithDelete()
281
	{
282
		// Remove the following lines when you implement this test.
283
		$this->markTestIncomplete(
284
				'This test has not been implemented yet.'
285
		);
286
	}
287
}
288