-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from codeliner/patch-5
Patch-5: Add message type Query
- Loading branch information
Showing
4 changed files
with
74 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/common. | ||
* (c) 2014-2015 prooph software GmbH <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 5/22/15 - 10:26 PM | ||
*/ | ||
namespace Prooph\Common\Messaging; | ||
|
||
/** | ||
* Class Query | ||
* | ||
* This is the base class for queries used to fetch data from read model. | ||
* | ||
* @package Prooph\Common\Messaging | ||
* @author Alexander Miertsch <[email protected]> | ||
*/ | ||
class Query extends DomainMessage | ||
{ | ||
/** | ||
* Should be either MessageHeader::TYPE_COMMAND or MessageHeader::TYPE_EVENT or MessageHeader::TYPE_QUERY | ||
* | ||
* @return string | ||
*/ | ||
protected function messageType() | ||
{ | ||
return MessageHeader::TYPE_QUERY; | ||
} | ||
} |
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,38 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/common. | ||
* (c) 2014-2015 prooph software GmbH <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 5/22/15 - 10:28 PM | ||
*/ | ||
namespace ProophTest\Common\Messaging; | ||
|
||
|
||
use Prooph\Common\Messaging\MessageHeader; | ||
use Prooph\Common\Messaging\Query; | ||
use Rhumsaa\Uuid\Uuid; | ||
|
||
final class QueryTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
function it_has_the_message_type_query() | ||
{ | ||
$query = Query::fromArray([ | ||
'name' => 'TestQuery', | ||
'uuid' => Uuid::uuid4()->toString(), | ||
'version' => 1, | ||
'created_at' => (new \DateTimeImmutable())->format(\DateTime::ISO8601), | ||
'payload' => ['query' => 'payload'], | ||
'metadata' => ['query' => 'metadata'] | ||
]); | ||
|
||
$remoteMessage = $query->toRemoteMessage(); | ||
|
||
$this->assertEquals(MessageHeader::TYPE_QUERY, $remoteMessage->header()->type()); | ||
} | ||
} |