This repository has been archived by the owner on Jan 4, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: Implement DataProvider\ObjectProvider
- Loading branch information
1 parent
5b0f606
commit 9bafac8
Showing
8 changed files
with
276 additions
and
4 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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2017-2020 Andreas Möller | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE.md file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ergebnis/test-util | ||
*/ | ||
|
||
namespace Ergebnis\Test\Util\DataProvider; | ||
|
||
use Ergebnis\Test\Util; | ||
|
||
final class ObjectProvider | ||
{ | ||
use Util\Helper; | ||
|
||
/** | ||
* @return \Generator<string, array{0: bool}> | ||
*/ | ||
public static function object(): \Generator | ||
{ | ||
yield from self::provideDataForValues([ | ||
'object' => new \stdClass(), | ||
]); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2017-2020 Andreas Möller | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE.md file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ergebnis/test-util | ||
*/ | ||
|
||
namespace Ergebnis\Test\Util\Test\Unit\DataProvider; | ||
|
||
use Ergebnis\Test\Util\DataProvider\ObjectProvider; | ||
use Ergebnis\Test\Util\Test\Util; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @covers \Ergebnis\Test\Util\DataProvider\ObjectProvider | ||
*/ | ||
final class ObjectProviderTest extends AbstractProviderTestCase | ||
{ | ||
/** | ||
* @dataProvider \Ergebnis\Test\Util\DataProvider\ObjectProvider::object() | ||
* | ||
* @param mixed $value | ||
*/ | ||
public function testObjectProvidesObject($value): void | ||
{ | ||
self::assertIsObject($value); | ||
} | ||
|
||
public function testObjectReturnsGeneratorThatProvidesObject(): void | ||
{ | ||
$specifications = [ | ||
'object' => Util\DataProvider\Specification\Equal::create(new \stdClass()), | ||
]; | ||
|
||
$provider = ObjectProvider::object(); | ||
|
||
self::assertProvidesDataSetsForValuesSatisfyingSpecifications($specifications, $provider); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2017-2020 Andreas Möller | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE.md file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ergebnis/test-util | ||
*/ | ||
|
||
namespace Ergebnis\Test\Util\Test\Util\DataProvider\Specification; | ||
|
||
final class Equal implements Specification | ||
{ | ||
private $value; | ||
|
||
private function __construct($value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
public static function create($value): self | ||
{ | ||
return new self($value); | ||
} | ||
|
||
public function isSatisfiedBy($value): bool | ||
{ | ||
return $this->value == $value; | ||
} | ||
} |