-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adicionando Event Sourced Aggregates #31
base: master
Are you sure you want to change the base?
Changes from all commits
98c5a27
047b7f1
c7350eb
5db4eff
2d10867
1deefd3
afb1b20
8fc1a4e
afc97bd
640c1ea
5ae319e
654acf0
343401e
7dcd112
971198d
e0404ba
432d3b3
80a419d
a0f60e9
5a56ced
0654cbe
604baa7
8d521bc
0f46074
f38a6cc
a33f366
b9baa21
cb74529
a173b99
9a440b8
cb93649
33c9aab
31773ed
f6ed898
b6f3c8c
d9da9db
09f9e85
34c5852
72e9029
9e3aa6e
085523e
06f54b2
2c41c30
f70ed6a
5b27875
65c717d
3ac65bd
f32a792
28253d7
df8c9bb
af4bc72
4195114
db290dc
71a467c
f1ee208
2f90c02
9c88345
e26062a
c2038cc
52b48a6
cbb39f0
3da5028
edb6437
63d110a
a4ffc9d
d2fb3cf
5e382fe
b2e51bd
28db869
56f331b
e5f58cc
c841a5a
798e1c2
bcbad63
b5a5423
19aca11
4733a48
42b34d9
73cf2c8
db88b8c
fa0b846
d5278e9
3ca0b81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* This software consists of voluntary contributions made by many individuals | ||
* and is licensed under the MIT license. | ||
*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
DB_DSN=mysql:host=localhost;dbname=conticket | ||
DB_USER=root | ||
DB_PASSWORD= |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ composer.phar | |
composer.lock | ||
bin | ||
vendor/ | ||
.env | ||
app/cache/* | ||
app/logs/* | ||
app/phpunit.xml | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* This software consists of voluntary contributions made by many individuals | ||
* and is licensed under the MIT license. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Conticket\Conference\Factory\CommandHandler\CreateConferenceHandlerFactory; | ||
use Conticket\Conference\Domain\Command\CreateConference; | ||
|
||
return (function () { | ||
return [ | ||
'factories' => [ | ||
CreateConference::class => CreateConferenceHandlerFactory::class, | ||
], | ||
]; | ||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Conticket\Conference\Infrastructure\Middleware\CreateConferenceMiddleware; | ||
use Conticket\Conference\Factory\Middleware\CreateConferenceMiddlewareFactory; | ||
|
||
return (function () { | ||
return [ | ||
'factories' => [ | ||
CreateConferenceMiddleware::class => CreateConferenceMiddlewareFactory::class, | ||
], | ||
]; | ||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* This software consists of voluntary contributions made by many individuals | ||
* and is licensed under the MIT license. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Conticket\Conference\Domain\Repository\ConferenceRepositoryInterface; | ||
use Conticket\Conference\Factory\Repository\ConferenceRepositoryFactory; | ||
|
||
return (function () { | ||
return [ | ||
'factories' => [ | ||
ConferenceRepositoryInterface::class => ConferenceRepositoryFactory::class, | ||
], | ||
]; | ||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
// NOTE: Encapsulate in an IIFE to avoid future mistakes with | ||
// variables in global space. | ||
return (function () { | ||
return new \Zend\ServiceManager\ServiceManager( | ||
array_merge_recursive( | ||
require __DIR__ . '/services.php', | ||
require __DIR__ . '/commands.php', | ||
require __DIR__ . '/middlewares.php', | ||
require __DIR__ . '/repositories.php' | ||
) | ||
); | ||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Conticket\Conference\Infrastructure\Service\ApplicationFactory; | ||
use Conticket\Conference\Infrastructure\Service\CommandBusFactory; | ||
use Conticket\Conference\Infrastructure\Service\ConnectionFactory; | ||
use Conticket\Conference\Infrastructure\Service\EventStoreFactory; | ||
use Conticket\Conference\Infrastructure\Service\PDOFactory; | ||
use Doctrine\DBAL\Connection; | ||
use Prooph\EventStore\EventStore; | ||
use Prooph\ServiceBus\CommandBus; | ||
use Zend\Expressive\Application; | ||
use Zend\Expressive\Router\FastRouteRouter; | ||
use Zend\ServiceManager\Factory\InvokableFactory; | ||
|
||
return (function () { | ||
return [ | ||
'factories' => [ | ||
Application::class => ApplicationFactory::class, | ||
FastRouteRouter::class => InvokableFactory::class, | ||
CommandBus::class => CommandBusFactory::class, | ||
EventStore::class => EventStoreFactory::class, | ||
Connection::class => ConnectionFactory::class, | ||
\PDO::class => PDOFactory::class, | ||
], | ||
]; | ||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Conticket\Conference\Infrastructure\Middleware\CreateConferenceMiddleware; | ||
|
||
(function () { | ||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
(new \Dotenv\Dotenv(__DIR__ . '/..'))->load(); | ||
|
||
/* @var $serviceManager \Zend\ServiceManager\ServiceManager */ | ||
$serviceManager = require __DIR__ . '/../config/service-manager.php'; | ||
|
||
/* @var $app \Zend\Expressive\Application */ | ||
$app = $serviceManager->get(\Zend\Expressive\Application::class); | ||
|
||
// @todo change it to POST | ||
$app->get(CreateConferenceMiddleware::PATH, CreateConferenceMiddleware::class); | ||
|
||
$app->pipeRoutingMiddleware(); | ||
$app->pipeDispatchMiddleware(); | ||
$app->raiseThrowables(); | ||
$app->run(); | ||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace spec\Conticket\Model\Aggregates\Event; | ||
|
||
use Conticket\Model\Aggregates\Event\EventId; | ||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
use Conticket\Model\Aggregates\Event\Event; | ||
|
||
class EventSpec extends ObjectBehavior | ||
{ | ||
|
||
public function let() | ||
{ | ||
$this->beConstructedThrough('fromNameAndDescription', [ | ||
'Event specification by example', | ||
'Description of event specified by example' | ||
]); | ||
} | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(Event::class); | ||
} | ||
|
||
public function it_should_return_event_id() | ||
{ | ||
$this->aggregateId()->shouldReturnAnInstanceOf(EventId::class); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace spec\Conticket\Model\Aggregates\Event; | ||
|
||
use Conticket\Model\Aggregates\Event\TicketLifespan; | ||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
use Conticket\Model\Aggregates\Event\TicketEndDateMustBeGreaterThanStartDateException; | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. too much space in here, remove one line |
||
final class TicketLifespanSpec extends ObjectBehavior | ||
{ | ||
public function it_is_initializable() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. man, this Spec classes get broken when we set the return to :void |
||
{ | ||
$this->shouldHaveType(TicketLifespan::class); | ||
} | ||
|
||
public function it_throws_an_exception_when_start_date_is_greater_than_end_date() | ||
{ | ||
$this->shouldThrow(TicketEndDateMustBeGreaterThanStartDateException::class); | ||
$this->beConstructedThrough('fromStartAndEnd', [ | ||
new \DateTimeImmutable('2016-01-01'), | ||
new \DateTimeImmutable('2015-01-01'), | ||
]); | ||
} | ||
|
||
public function it_should_return_immutable_datetime_objects_on_start_and_end_methods() | ||
{ | ||
$this->beConstructedThrough('fromStartAndEnd', [ | ||
new \DateTimeImmutable('2016-01-01'), | ||
new \DateTimeImmutable('2016-04-01'), | ||
]); | ||
$this->start()->shouldReturnAnInstanceOf(\DateTimeImmutable::class); | ||
$this->end()->shouldReturnAnInstanceOf(\DateTimeImmutable::class); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
declare(strict_types=1);