|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* PHP: Nelson Martell Library file |
|
4
|
|
|
* |
|
5
|
|
|
* Content: |
|
6
|
|
|
* - Trait definition |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright © 2016-2017 Nelson Martell (http://nelson6e65.github.io) |
|
9
|
|
|
* |
|
10
|
|
|
* Licensed under The MIT License (MIT) |
|
11
|
|
|
* For full copyright and license information, please see the LICENSE |
|
12
|
|
|
* Redistributions of files must retain the above copyright notice. |
|
13
|
|
|
* |
|
14
|
|
|
* @copyright 2016-2017 Nelson Martell |
|
15
|
|
|
* @link http://nelson6e65.github.io/php_nml/ |
|
16
|
|
|
* @since v0.6.0, v0.7.0 |
|
17
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License (MIT) |
|
18
|
|
|
* */ |
|
19
|
|
|
|
|
20
|
|
|
namespace NelsonMartell\Test\Helpers; |
|
21
|
|
|
|
|
22
|
|
|
use Cake\Utility\Inflector; |
|
23
|
|
|
use NelsonMartell\Extensions\Text; |
|
24
|
|
|
use NelsonMartell\IStrictPropertiesContainer; |
|
25
|
|
|
use SebastianBergmann\Exporter\Exporter; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Test helper for classes implementing ``NelsonMartell\IStrictPropertiesContainer`` interface and |
|
29
|
|
|
* ``NelsonMartell\PropertiesHandler`` trait. |
|
30
|
|
|
* |
|
31
|
|
|
* |
|
32
|
|
|
* @author Nelson Martell <[email protected]> |
|
33
|
|
|
* |
|
34
|
|
|
* @see HasReadOnlyProperties |
|
35
|
|
|
* @see HasReadWriteProperties |
|
36
|
|
|
* @see HasUnaccesibleProperties |
|
37
|
|
|
* @see HasWriteOnlyProperties |
|
38
|
|
|
* */ |
|
39
|
|
|
trait ImplementsIStrictPropertiesContainer |
|
40
|
|
|
{ |
|
41
|
|
|
public abstract function objectInstanceProvider(); |
|
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @dataProvider objectInstanceProvider |
|
45
|
|
|
* @todo Check returning value of dependency tests. |
|
46
|
|
|
*/ |
|
47
|
|
|
public function testImplementsIStrictPropertiesContainerInterface($obj) |
|
|
|
|
|
|
48
|
|
|
{ |
|
49
|
|
|
$this->assertInstanceOf(IStrictPropertiesContainer::class, $obj); |
|
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
return $obj; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @depends testImplementsIStrictPropertiesContainerInterface |
|
56
|
|
|
* @dataProvider objectInstanceProvider |
|
57
|
|
|
* @expectedException \BadMethodCallException |
|
58
|
|
|
*/ |
|
59
|
|
|
public function testIsUnableToCreateDirectAttributesOutsideOfClassDefinition(IStrictPropertiesContainer $obj) |
|
60
|
|
|
{ |
|
61
|
|
|
$obj->thisPropertyNameIsMaybeImposibleThatExistsInClassToBeUsedAsNameOfPropertyOfAnyClassGiven = 'No way'; |
|
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a
@returndoc comment to communicate to implementors of these methods what they are expected to return.