Skip to content

Commit 953b7d9

Browse files
committed
generated docs for configuration classes
1 parent 33006c5 commit 953b7d9

File tree

3 files changed

+169
-0
lines changed

3 files changed

+169
-0
lines changed

RoboFile.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
require_once __DIR__.'/vendor/autoload.php';
23

34
class Robofile extends \Robo\Tasks
45
{
@@ -30,6 +31,22 @@ public function changed($description)
3031
->run();
3132
}
3233

34+
protected $docs = [
35+
'docs/GlobalConfig.md' => \Codeception\Specify\Config::class,
36+
'docs/LocalConfig.md' => \Codeception\Specify\ConfigBuilder::class,
37+
];
38+
39+
public function docs()
40+
{
41+
foreach ($this->docs as $file => $class) {
42+
class_exists($class, true);
43+
$this->taskGenDoc($file)
44+
->docClass($class)
45+
->processProperty(false)
46+
->run();
47+
}
48+
}
49+
3350

3451
public function test()
3552
{

docs/GlobalConfig.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
## Codeception\Specify\Config
3+
4+
5+
6+
Global Specify configuration. Should be set in bootstrap.
7+
8+
```php
9+
<?php
10+
// disable deep cloning of properties inside specify block
11+
\Codeception\Specify\Config::setDeepClone(false);
12+
?>
13+
```
14+
15+
16+
17+
18+
19+
20+
21+
#### *public* propertyIgnored($property)
22+
#### *public* classIgnored($value)
23+
#### *public* propertyIsShallowCloned($property)
24+
#### *public* propertyIsDeeplyCloned($property)
25+
#### *public static* setDeepClone($deepClone)
26+
Enable or disable using of deep cloning for objects by default.
27+
Deep cloning is the default.
28+
29+
* `param boolean` $deepClone
30+
31+
#### *public static* setIgnoredClasses($ignoredClasses)
32+
#### *public static* setIgnoredProperties($ignoredProperties)
33+
Globally set class properties are going to be ignored for cloning in specify blocks.
34+
35+
```php
36+
<?php
37+
\Codeception\Specify\Config::setIgnoredProperties(['users', 'repository']);
38+
```
39+
40+
* `param array` $ignoredProperties
41+
42+
#### *public static* addIgnoredClasses($ignoredClasses)
43+
Add specific classes to cloning ignore list. Instances of those classes won't be cloned for specify blocks.
44+
45+
```php
46+
<?php
47+
\Codeception\Specify\Config::addIgnoredClasses(['\Acme\Domain\UserRepo', '\Acme\Domain\PostRepo']);
48+
?>
49+
```
50+
51+
* `param` $ignoredClasses
52+
53+
54+
#### *public static* create()
55+
@return Config
56+

docs/LocalConfig.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
2+
## Codeception\Specify\ConfigBuilder
3+
4+
5+
6+
Configure Specify usage.
7+
8+
Specify copies properties of object and restores them for each specify block.
9+
Objects can be cloned deeply or using standard `clone` operator.
10+
Specify can be configured to prevent specific properties in specify blocks, to choose default cloning method,
11+
or cloning method for specific properties.
12+
13+
```php
14+
<?php
15+
$this->specifyConfig()
16+
->ignore('user') // do not clone
17+
?>
18+
```
19+
#### *public* __construct($config = null)
20+
#### *public* ignore($properties = null)
21+
Ignore cloning specific object properties in specify blocks.
22+
23+
```php
24+
<?php
25+
$this->user = new User;
26+
$this->specifyConfig()->ignore('user');
27+
$this->specify('change user name', function() {
28+
$this->user->name = 'davert';
29+
});
30+
$this->user->name == 'davert'; // name changed
31+
?>
32+
```
33+
34+
* `param array` $properties
35+
* `return` $this
36+
37+
#### *public* ignoreClasses($classes = null)
38+
Adds specific class to ignore list, if property is an instance of class it will not be cloned for specify block.
39+
40+
* `param array` $classes
41+
* `return` $this
42+
43+
#### *public* deepClone($properties = null)
44+
Turn on/off deep cloning mode.
45+
Deep cloning mode can also be specified for specific properties.
46+
47+
```php
48+
<?php
49+
$this->user = new User;
50+
$this->post = new Post;
51+
$this->tag = new Tag;
52+
53+
// turn on deep cloning by default
54+
$this->specifyConfig()->deepClone();
55+
56+
// turn off deep cloning by default
57+
$this->specifyConfig()->deepClone(false);
58+
59+
// deep clone only user and tag property
60+
$this->specifyConfig()->deepClone('user', 'tag');
61+
62+
// alternatively
63+
$this->specifyConfig()->deepClone(['user', 'tag']);
64+
?>
65+
```
66+
67+
* `param bool` $properties
68+
* `return` $this
69+
70+
#### *public* shallowClone($properties = null)
71+
Disable deep cloning mode, use shallow cloning by default, which is faster.
72+
Deep cloning mode can also be disabled for specific properties.
73+
74+
```php
75+
<?php
76+
$this->user = new User;
77+
$this->post = new Post;
78+
$this->tag = new Tag;
79+
80+
// turn off deep cloning by default
81+
$this->specifyConfig()->shallowClone();
82+
83+
// turn on deep cloning by default
84+
$this->specifyConfig()->shallowClone(false);
85+
86+
// shallow clone only user and tag property
87+
$this->specifyConfig()->shallowClone('user', 'tag');
88+
89+
// alternatively
90+
$this->specifyConfig()->shallowClone(['user', 'tag']);
91+
?>
92+
```
93+
94+
* `param bool` $properties
95+
* `return` $this
96+

0 commit comments

Comments
 (0)