slickframework /
event
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | /** |
||||||
| 4 | * This file is part of slick/event package |
||||||
| 5 | * |
||||||
| 6 | * For the full copyright and license information, please view the LICENSE |
||||||
| 7 | * file that was distributed with this source code. |
||||||
| 8 | */ |
||||||
| 9 | |||||||
| 10 | namespace spec\Slick\Event\Domain; |
||||||
| 11 | |||||||
| 12 | use Ramsey\Uuid\Uuid; |
||||||
| 13 | use Slick\Event\Domain\EventId; |
||||||
| 14 | use PhpSpec\ObjectBehavior; |
||||||
| 15 | |||||||
| 16 | /** |
||||||
| 17 | * EventIdSpec specs |
||||||
| 18 | * |
||||||
| 19 | * @package spec\Slick\Event\Event |
||||||
| 20 | */ |
||||||
| 21 | class EventIdSpec extends ObjectBehavior |
||||||
| 22 | { |
||||||
| 23 | |||||||
| 24 | private $identifier; |
||||||
| 25 | |||||||
| 26 | function let() |
||||||
| 27 | { |
||||||
| 28 | $this->identifier = (string)Uuid::uuid4(); |
||||||
| 29 | $this->beConstructedWith($this->identifier); |
||||||
| 30 | } |
||||||
| 31 | |||||||
| 32 | function it_is_initializable() |
||||||
|
0 ignored issues
–
show
|
|||||||
| 33 | { |
||||||
| 34 | $this->shouldHaveType(EventId::class); |
||||||
| 35 | } |
||||||
| 36 | |||||||
| 37 | function it_has_an_identifier() |
||||||
| 38 | { |
||||||
| 39 | $this->__toString()->shouldBe($this->identifier); |
||||||
|
0 ignored issues
–
show
The method
__toString() does not exist on spec\Slick\Event\Domain\EventIdSpec. Since you implemented __call, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 40 | } |
||||||
| 41 | |||||||
| 42 | function it_throws_an_exception_when_identifier_is_not_a_valid_uuid() |
||||||
| 43 | { |
||||||
| 44 | $this->beConstructedWith('test'); |
||||||
| 45 | $this->shouldThrow(\InvalidArgumentException::class) |
||||||
| 46 | ->duringInstantiation(); |
||||||
| 47 | } |
||||||
| 48 | |||||||
| 49 | function it_generate_an_uuid_internally() |
||||||
| 50 | { |
||||||
| 51 | $regEx = '/\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/i'; |
||||||
| 52 | $this->beConstructedWith(null); |
||||||
| 53 | $this->__toString()->shouldMatch($regEx); |
||||||
| 54 | } |
||||||
| 55 | } |
||||||
| 56 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.