1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* functional test suite for the EventStatusLinkResponseListener |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Graviton\RabbitMqBundle\Tests\Listener; |
7
|
|
|
|
8
|
|
|
use Graviton\RabbitMqBundle\Producer\Dummy; |
9
|
|
|
use Graviton\TestBundle\Test\RestTestCase; |
10
|
|
|
use Symfony\Component\HttpFoundation\Response; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class EventStatusLinkResponseListenerTest |
14
|
|
|
* |
15
|
|
|
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors> |
16
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
17
|
|
|
* @link http://swisscom.ch |
18
|
|
|
*/ |
19
|
|
|
class EventStatusLinkResponseListenerDBTest extends RestTestCase |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Verifies the correct workflow of the ResponseListener |
23
|
|
|
* |
24
|
|
|
* @return void |
25
|
|
|
*/ |
26
|
|
|
public function testEventStatusLinkResponseListener() |
27
|
|
|
{ |
28
|
|
|
// Create a test worker |
29
|
|
|
$worker = new \stdClass(); |
30
|
|
|
$worker->id = 'test-worker-listener'; |
31
|
|
|
$worker->subscription = []; |
32
|
|
|
$event = new \stdClass(); |
33
|
|
|
$event->event = 'document.core.app.create'; |
34
|
|
|
$worker->subscription[] = $event; |
35
|
|
|
$event = new \stdClass(); |
36
|
|
|
$event->event = 'document.core.app.update'; |
37
|
|
|
$worker->subscription[] = $event; |
38
|
|
|
|
39
|
|
|
$client = static::createRestClient(); |
40
|
|
|
$client->put('/event/worker/' . $worker->id, $worker); |
41
|
|
|
$response = $client->getResponse(); |
42
|
|
|
$this->assertEquals(Response::HTTP_NO_CONTENT, $response->getStatusCode()); |
43
|
|
|
|
44
|
|
|
$testApp = new \stdClass(); |
45
|
|
|
$testApp->id = "test-event-app"; |
46
|
|
|
$testApp->name = new \stdClass(); |
47
|
|
|
$testApp->name->en = "test-event-app"; |
48
|
|
|
$testApp->showInMenu = false; |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
$client = static::createRestClient(); |
52
|
|
|
/** @var Dummy $dbProducer */ |
53
|
|
|
$dbProducer = $client->getContainer()->get('graviton.rabbitmq.jobproducer'); |
54
|
|
|
$dbProducer->resetEventList(); |
55
|
|
|
|
56
|
|
|
$client->put('/core/app/' . $testApp->id, $testApp); |
57
|
|
|
$response = $client->getResponse(); |
58
|
|
|
$this->assertEquals(Response::HTTP_NO_CONTENT, $response->getStatusCode()); |
59
|
|
|
|
60
|
|
|
/** @var Dummy $dbProducer */ |
61
|
|
|
$events = $dbProducer->getEventList(); |
62
|
|
|
|
63
|
|
|
$this->assertCount(1, $events); |
64
|
|
|
$data = json_decode($events[0], true); |
65
|
|
|
$this->assertEquals('document.core.app.update', $data['event']); |
66
|
|
|
$this->assertEquals('anonymous', $data['coreUserId']); |
67
|
|
|
$this->assertEquals('http://localhost/core/app/test-event-app', $data['document']['$ref']); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
//public function testPrivateGenerateRoutingKey(){} |
71
|
|
|
//public function testPrivateGetStatusUrl(){} |
72
|
|
|
//public function testPrivateGetSubscribedWorkerIds(){} |
73
|
|
|
} |
74
|
|
|
|