-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
523 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* This file is part of the prooph/event-store-http-api. | ||
* (c) 2016-2017 prooph software GmbH <contact@prooph.de> | ||
* (c) 2016-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Prooph\EventStore\Http\Api\Action; | ||
|
||
use Interop\Http\ServerMiddleware\DelegateInterface; | ||
use Interop\Http\ServerMiddleware\MiddlewareInterface; | ||
use Prooph\EventStore\Projection\ProjectionManager; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Zend\Diactoros\Response\EmptyResponse; | ||
|
||
final class DeleteProjection implements MiddlewareInterface | ||
{ | ||
/** | ||
* @var ProjectionManager | ||
*/ | ||
private $projectionManager; | ||
|
||
public function __construct(ProjectionManager $projectionManager) | ||
{ | ||
$this->projectionManager = $projectionManager; | ||
} | ||
|
||
public function process(ServerRequestInterface $request, DelegateInterface $delegate) | ||
{ | ||
$projectionName = urldecode($request->getAttribute('name')); | ||
$deleteEmittedEvents = $request->getAttribute('deleteEmittedEvents'); | ||
|
||
switch ($deleteEmittedEvents) { | ||
case 'false': | ||
$deleteEmittedEvents = false; | ||
break; | ||
case 'true': | ||
$deleteEmittedEvents = true; | ||
break; | ||
} | ||
|
||
$this->projectionManager->deleteProjection($projectionName, $deleteEmittedEvents); | ||
|
||
return new EmptyResponse(204); | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
/** | ||
* This file is part of the prooph/event-store-http-api. | ||
* (c) 2016-2017 prooph software GmbH <contact@prooph.de> | ||
* (c) 2016-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Prooph\EventStore\Http\Api\Action; | ||
|
||
use Interop\Http\ServerMiddleware\DelegateInterface; | ||
use Interop\Http\ServerMiddleware\MiddlewareInterface; | ||
use Prooph\EventStore\Projection\ProjectionManager; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Zend\Diactoros\Response\EmptyResponse; | ||
|
||
final class ResetProjection implements MiddlewareInterface | ||
{ | ||
/** | ||
* @var ProjectionManager | ||
*/ | ||
private $projectionManager; | ||
|
||
public function __construct(ProjectionManager $projectionManager) | ||
{ | ||
$this->projectionManager = $projectionManager; | ||
} | ||
|
||
public function process(ServerRequestInterface $request, DelegateInterface $delegate) | ||
{ | ||
$projectionName = urldecode($request->getAttribute('name')); | ||
|
||
$this->projectionManager->resetProjection($projectionName); | ||
|
||
return new EmptyResponse(204); | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
/** | ||
* This file is part of the prooph/event-store-http-api. | ||
* (c) 2016-2017 prooph software GmbH <contact@prooph.de> | ||
* (c) 2016-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Prooph\EventStore\Http\Api\Action; | ||
|
||
use Interop\Http\ServerMiddleware\DelegateInterface; | ||
use Interop\Http\ServerMiddleware\MiddlewareInterface; | ||
use Prooph\EventStore\Projection\ProjectionManager; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Zend\Diactoros\Response\EmptyResponse; | ||
|
||
final class StopProjection implements MiddlewareInterface | ||
{ | ||
/** | ||
* @var ProjectionManager | ||
*/ | ||
private $projectionManager; | ||
|
||
public function __construct(ProjectionManager $projectionManager) | ||
{ | ||
$this->projectionManager = $projectionManager; | ||
} | ||
|
||
public function process(ServerRequestInterface $request, DelegateInterface $delegate) | ||
{ | ||
$projectionName = urldecode($request->getAttribute('name')); | ||
|
||
$this->projectionManager->stopProjection($projectionName); | ||
|
||
return new EmptyResponse(204); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
/** | ||
* This file is part of the prooph/event-store-http-api. | ||
* (c) 2016-2017 prooph software GmbH <contact@prooph.de> | ||
* (c) 2016-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Prooph\EventStore\Http\Api\Container\Action; | ||
|
||
use Prooph\EventStore\Http\Api\Action\DeleteProjection; | ||
use Prooph\EventStore\Projection\ProjectionManager; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class DeleteProjectionFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): DeleteProjection | ||
{ | ||
return new DeleteProjection($container->get(ProjectionManager::class)); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
/** | ||
* This file is part of the prooph/event-store-http-api. | ||
* (c) 2016-2017 prooph software GmbH <contact@prooph.de> | ||
* (c) 2016-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Prooph\EventStore\Http\Api\Container\Action; | ||
|
||
use Prooph\EventStore\Http\Api\Action\ResetProjection; | ||
use Prooph\EventStore\Projection\ProjectionManager; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class ResetProjectionFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): ResetProjection | ||
{ | ||
return new ResetProjection($container->get(ProjectionManager::class)); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
/** | ||
* This file is part of the prooph/event-store-http-api. | ||
* (c) 2016-2017 prooph software GmbH <contact@prooph.de> | ||
* (c) 2016-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Prooph\EventStore\Http\Api\Container\Action; | ||
|
||
use Prooph\EventStore\Http\Api\Action\StopProjection; | ||
use Prooph\EventStore\Projection\ProjectionManager; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class StopProjectionFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): StopProjection | ||
{ | ||
return new StopProjection($container->get(ProjectionManager::class)); | ||
} | ||
} |
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,67 @@ | ||
<?php | ||
/** | ||
* This file is part of the prooph/event-store-http-api. | ||
* (c) 2016-2017 prooph software GmbH <contact@prooph.de> | ||
* (c) 2016-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ProophTest\EventStore\Http\Api\Action; | ||
|
||
use Interop\Http\ServerMiddleware\DelegateInterface; | ||
use PHPUnit\Framework\TestCase; | ||
use Prooph\EventStore\Http\Api\Action\DeleteProjection; | ||
use Prooph\EventStore\Projection\ProjectionManager; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Zend\Diactoros\Response\EmptyResponse; | ||
|
||
class DeleteProjectionTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_will_delete_projection_incl_emitted_events(): void | ||
{ | ||
$projectionManager = $this->prophesize(ProjectionManager::class); | ||
$projectionManager->deleteProjection('runner', true)->shouldBeCalled(); | ||
|
||
$request = $this->prophesize(ServerRequestInterface::class); | ||
$request->getAttribute('name')->willReturn('runner')->shouldBeCalled(); | ||
$request->getAttribute('deleteEmittedEvents')->willReturn('true')->shouldBeCalled(); | ||
|
||
$delegate = $this->prophesize(DelegateInterface::class); | ||
|
||
$action = new DeleteProjection($projectionManager->reveal()); | ||
|
||
$response = $action->process($request->reveal(), $delegate->reveal()); | ||
|
||
$this->assertInstanceOf(EmptyResponse::class, $response); | ||
$this->assertEquals(204, $response->getStatusCode()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_will_delete_projection_without_emitted_events(): void | ||
{ | ||
$projectionManager = $this->prophesize(ProjectionManager::class); | ||
$projectionManager->deleteProjection('runner', false)->shouldBeCalled(); | ||
|
||
$request = $this->prophesize(ServerRequestInterface::class); | ||
$request->getAttribute('name')->willReturn('runner')->shouldBeCalled(); | ||
$request->getAttribute('deleteEmittedEvents')->willReturn('false')->shouldBeCalled(); | ||
|
||
$delegate = $this->prophesize(DelegateInterface::class); | ||
|
||
$action = new DeleteProjection($projectionManager->reveal()); | ||
|
||
$response = $action->process($request->reveal(), $delegate->reveal()); | ||
|
||
$this->assertInstanceOf(EmptyResponse::class, $response); | ||
$this->assertEquals(204, $response->getStatusCode()); | ||
} | ||
} |
Oops, something went wrong.