-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* develop: (35 commits) remove dead code only cover the sources add use case specify next release typo add missing types update documentation change assertion method to display invalid generated data remove tests already covered by the Content properties remove unused lazy stream remove Content\OfStream add Content::oneShot() update license make sure there is always at least 1 chunk make sure Content::ofLines() and ::ofChunks() hold the properties make sure Content::none() hold the properties rename Content\IO to Content\AtPath remove unused Content\AtPath add Content\IO add File\Content properties ...
- Loading branch information
Showing
84 changed files
with
1,747 additions
and
2,941 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
ignore: | ||
- proofs/* | ||
- fixtures/* | ||
- properties/* | ||
- properties/**/* | ||
- .php-cs-fixer.dist.php | ||
- blackbox.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,27 @@ | ||
# Your own adapter | ||
|
||
This library allows you to extend its behaviour by creating new implementations of the exposed interfaces (`File`, `Directory` and `Adapter`). The interfaces are strict enough to guide you through the expected behaviour but the type system can't express all of them, leaving the door open to inconsistencies between implementations. That's why the library expose a set of properties (as declared by [`innmind/black-box`](https://packagist.org/packages/innmind/black-box)) to help you make sure your implementations fulfill the expected behaviours. | ||
This library allows you to extend its behaviour by creating new implementations of the exposed interface `Adapter`. The interface is strict enough to guide you through the expected behaviour but the type system can't express all of them, leaving the door open to inconsistencies between implementations. That's why the library expose a set of properties (as declared by [`innmind/black-box`](https://packagist.org/packages/innmind/black-box)) to help you make sure your implementations fulfill the expected behaviours. | ||
|
||
You can test properties on your adapter as follow (with PHPUnit): | ||
You can test properties on your adapter as follow: | ||
|
||
```php | ||
use Properties\Innmind\Filesystem\Adapter; | ||
use Innmind\BlackBox\PHPUnit\BlackBox; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class MyAdapterTest extends TestCase | ||
{ | ||
use BlackBox; | ||
|
||
/** | ||
* This test will make sure each property is held by your adapter | ||
* | ||
* @dataProvider properties | ||
*/ | ||
public function testHoldProperty($property) | ||
{ | ||
$this | ||
->forAll($property) | ||
->then(function($property) { | ||
$adapter = /* instanciate your implementation here */; | ||
|
||
if (!$property->applicableTo($adapter)) { | ||
$this->markTestSkipped(); | ||
} | ||
|
||
$property->ensureHeldBy($adapter); | ||
}); | ||
use Innmind\BlackBox\Set; | ||
|
||
return static function() { | ||
yield properties( | ||
'YourAdapter', | ||
Adapter::properties(), | ||
Set\Call::of(fn() => /* instanciate YourAdapter here */), | ||
); | ||
|
||
foreach (Adapter::alwaysApplicable() as $property) { | ||
yield property( | ||
$property, | ||
Set\Call::of(fn() => /* instanciate YourAdapter here */), | ||
)->named('YourAdapter'); | ||
} | ||
|
||
/** | ||
* This test will try to prove your adapter hold any sequence of property | ||
* | ||
* This is useful to find bugs due to state mismanage | ||
*/ | ||
public function testHoldProperties() | ||
{ | ||
$this | ||
->forAll(Adapter::properties()) | ||
->then(function($properties) { | ||
$properties->ensureHeldBy(/* instanciate your implementation here */); | ||
}); | ||
} | ||
|
||
public function properties(): iterable | ||
{ | ||
foreach (Adapter::list() as $property) { | ||
yield [$property]; | ||
} | ||
} | ||
} | ||
}; | ||
``` | ||
|
||
You can use the same logic to test `Directory` implementations with `Properties\Innmind\Filesystem\Directory`. | ||
|
||
**Note**: there is no properties for the `File` interface as it doesn't expose any behaviour. | ||
Then you can [run your proofs](https://github.com/Innmind/BlackBox/blob/develop/documentation/organize.md) via BlackBox. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.