1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/** |
3
|
|
|
* PHP: Nelson Martell Library file |
4
|
|
|
* |
5
|
|
|
* Copyright © 2017-2019 Nelson Martell (http://nelson6e65.github.io) |
6
|
|
|
* |
7
|
|
|
* Licensed under The MIT License (MIT) |
8
|
|
|
* For full copyright and license information, please see the LICENSE |
9
|
|
|
* Redistributions of files must retain the above copyright notice. |
10
|
|
|
* |
11
|
|
|
* @copyright 2017-2019 Nelson Martell |
12
|
|
|
* @link http://nelson6e65.github.io/php_nml/ |
13
|
|
|
* @since v0.7.0 |
14
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License (MIT) |
15
|
|
|
* */ |
16
|
|
|
|
17
|
|
|
namespace NelsonMartell\Test\Helpers; |
18
|
|
|
|
19
|
|
|
use BadMethodCallException; |
20
|
|
|
|
21
|
|
|
use NelsonMartell\IStrictPropertiesContainer; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Split of ImplementsIStrictPropertiesContainer, for classes implementing any write-only property. |
25
|
|
|
* |
26
|
|
|
* @author Nelson Martell <[email protected]> |
27
|
|
|
* */ |
28
|
|
|
trait HasWriteOnlyProperties |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @returns IStrictPropertiesContainer |
32
|
|
|
*/ |
33
|
|
|
abstract public function testImplementsIStrictPropertiesContainerInterface($obj); |
34
|
|
|
|
35
|
|
|
abstract public function writeonlyPropertiesProvider(); |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @dataProvider writeonlyPropertiesProvider |
39
|
|
|
* |
40
|
|
|
* @param IStrictPropertiesContainer $obj |
41
|
|
|
* @param string $property |
42
|
|
|
* @param mixed $value |
43
|
|
|
*/ |
44
|
|
|
public function testWriteonlyPropertiesAreWritablesAreNotReadables( |
45
|
|
|
IStrictPropertiesContainer $obj, |
46
|
|
|
string $property, |
47
|
|
|
$value |
48
|
|
|
) : void { |
49
|
|
|
$obj->$property = $value; |
50
|
|
|
$this->addToAssertionCount(1); |
|
|
|
|
51
|
|
|
|
52
|
|
|
$this->expectException(BadMethodCallException::class); |
|
|
|
|
53
|
|
|
$actual = $obj->$property; |
|
|
|
|
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|