Skip to content

Commit 71926b1

Browse files
committed
Added package files
1 parent f56b4c1 commit 71926b1

File tree

13 files changed

+411
-1
lines changed

13 files changed

+411
-1
lines changed

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Exclude files that don't need to be present in packages (so they're not downloaded by Composer)
2+
/tests export-ignore
3+
/.gitattributes export-ignore
4+
/.gitignore export-ignore
5+
/Robofile.php export-ignore
6+
/*.md export-ignore
7+
/*.yml export-ignore

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.idea/
2+
/vendor/
3+
/composer.lock

.travis.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
language: php
2+
3+
php:
4+
- 5.6
5+
- 7.0
6+
- 7.1
7+
- 7.2
8+
- 7.3
9+
10+
# faster builds on new travis setup not using sudo
11+
sudo: false
12+
13+
services:
14+
- rabbitmq
15+
16+
install:
17+
- '[[ -z "$CI_USER_TOKEN" ]] || composer config github-oauth.github.com ${CI_USER_TOKEN};'
18+
- travis_retry composer self-update && composer --version
19+
- travis_retry composer update --prefer-dist --no-interaction
20+
21+
script:
22+
- php ./vendor/bin/codecept run

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2011 Michael Bodnarchuk and contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

Robofile.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
require __DIR__ . '/vendor/autoload.php';
4+
5+
use Codeception\Module\AMQP;
6+
use Codeception\Util\DocumentationHelpers;
7+
8+
class RoboFile extends \Robo\Tasks
9+
{
10+
use DocumentationHelpers;
11+
12+
public function buildDocs()
13+
{
14+
$className = AMQP::class;
15+
$classPath = str_replace('\\', '/', $className);
16+
$source = "https://github.com/Codeception/module-amqp/tree/master/src/$classPath.php";
17+
$sourceMessage = '<p>&nbsp;</p><div class="alert alert-warning">Module reference is taken from the source code. <a href="' . $source . '">Help us to improve documentation. Edit module reference</a></div>';
18+
$documentationFile = 'documentation.md';
19+
$this->generateDocumentationForClass($className, $documentationFile, $sourceMessage);
20+
}
21+
}

codeception.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
paths:
2+
tests: tests
3+
output: tests/_output
4+
data: tests/_data
5+
support: tests/_support
6+
envs: tests/_envs
7+
actor_suffix: Tester

composer.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name":"codeception/module-amqp",
3+
"description":"AMQP module for Codeception",
4+
"keywords":["codeception", "amqp"],
5+
"homepage":"http://codeception.com/",
6+
"type":"library",
7+
"license":"MIT",
8+
"authors":[
9+
{
10+
"name":"Michael Bodnarchuk"
11+
},
12+
{
13+
"name":"Gintautas Miselis"
14+
}
15+
],
16+
"minimum-stability": "RC",
17+
18+
"require": {
19+
"php": ">=5.6.0 <8.0",
20+
"codeception/codeception": "4.0.x-dev | ^4.0",
21+
"php-amqplib/php-amqplib": "^2.10.0"
22+
},
23+
"require-dev": {
24+
"codeception/util-robohelpers": "dev-master"
25+
},
26+
"autoload":{
27+
"classmap": ["src/"]
28+
},
29+
"config": {
30+
"classmap-authoritative": true
31+
}
32+
}

documentation.md

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
# AMQP
2+
3+
4+
This module interacts with message broker software that implements
5+
the Advanced Message Queuing Protocol (AMQP) standard. For example, RabbitMQ (tested).
6+
7+
<div class="alert alert-info">
8+
To use this module with Composer you need <em>"php-amqplib/php-amqplib": "~2.4"</em> package.
9+
</div>
10+
11+
## Config
12+
13+
* host: localhost - host to connect
14+
* username: guest - username to connect
15+
* password: guest - password to connect
16+
* vhost: '/' - vhost to connect
17+
* cleanup: true - defined queues will be purged before running every test.
18+
* queues: [mail, twitter] - queues to cleanup
19+
* single_channel - create and use only one channel during test execution
20+
21+
### Example
22+
23+
modules:
24+
enabled:
25+
- AMQP:
26+
host: 'localhost'
27+
port: '5672'
28+
username: 'guest'
29+
password: 'guest'
30+
vhost: '/'
31+
queues: [queue1, queue2]
32+
single_channel: false
33+
34+
## Public Properties
35+
36+
* connection - AMQPStreamConnection - current connection
37+
38+
## Actions
39+
40+
### bindQueueToExchange
41+
42+
Binds a queue to an exchange
43+
44+
This is an alias of method `queue_bind` of `PhpAmqpLib\Channel\AMQPChannel`.
45+
46+
```php
47+
<?php
48+
$I->bindQueueToExchange(
49+
'nameOfMyQueueToBind', // name of the queue
50+
'transactionTracking.transaction', // exchange name to bind to
51+
'your.routing.key' // Optionally, provide a binding key
52+
)
53+
```
54+
55+
* `param string` $queue
56+
* `param string` $exchange
57+
* `param string` $routing_key
58+
* `param bool` $nowait
59+
* `param array` $arguments
60+
* `param int` $ticket
61+
* `return` mixed|null
62+
63+
64+
### declareExchange
65+
66+
Declares an exchange
67+
68+
This is an alias of method `exchange_declare` of `PhpAmqpLib\Channel\AMQPChannel`.
69+
70+
```php
71+
<?php
72+
$I->declareExchange(
73+
'nameOfMyExchange', // exchange name
74+
'topic' // exchange type
75+
)
76+
```
77+
78+
* `param string` $exchange
79+
* `param string` $type
80+
* `param bool` $passive
81+
* `param bool` $durable
82+
* `param bool` $auto_delete
83+
* `param bool` $internal
84+
* `param bool` $nowait
85+
* `param array` $arguments
86+
* `param int` $ticket
87+
* `return` mixed|null
88+
89+
90+
### declareQueue
91+
92+
Declares queue, creates if needed
93+
94+
This is an alias of method `queue_declare` of `PhpAmqpLib\Channel\AMQPChannel`.
95+
96+
```php
97+
<?php
98+
$I->declareQueue(
99+
'nameOfMyQueue', // exchange name
100+
)
101+
```
102+
103+
* `param string` $queue
104+
* `param bool` $passive
105+
* `param bool` $durable
106+
* `param bool` $exclusive
107+
* `param bool` $auto_delete
108+
* `param bool` $nowait
109+
* `param array` $arguments
110+
* `param int` $ticket
111+
* `return` mixed|null
112+
113+
114+
### dontSeeQueueIsEmpty
115+
116+
Checks if queue is not empty.
117+
118+
``` php
119+
<?php
120+
$I->pushToQueue('queue.emails', 'Hello, davert');
121+
$I->dontSeeQueueIsEmpty('queue.emails');
122+
?>
123+
```
124+
125+
* `param string` $queue
126+
127+
128+
### grabMessageFromQueue
129+
130+
Takes last message from queue.
131+
132+
``` php
133+
<?php
134+
$message = $I->grabMessageFromQueue('queue.emails');
135+
?>
136+
```
137+
138+
* `param string` $queue
139+
* `return` \PhpAmqpLib\Message\AMQPMessage
140+
141+
142+
### purgeAllQueues
143+
144+
Purge all queues defined in config.
145+
146+
``` php
147+
<?php
148+
$I->purgeAllQueues();
149+
?>
150+
```
151+
152+
153+
### purgeQueue
154+
155+
Purge a specific queue defined in config.
156+
157+
``` php
158+
<?php
159+
$I->purgeQueue('queue.emails');
160+
?>
161+
```
162+
163+
* `param string` $queueName
164+
165+
166+
### pushToExchange
167+
168+
Sends message to exchange by sending exchange name, message
169+
and (optionally) a routing key
170+
171+
``` php
172+
<?php
173+
$I->pushToExchange('exchange.emails', 'thanks');
174+
$I->pushToExchange('exchange.emails', new AMQPMessage('Thanks!'));
175+
$I->pushToExchange('exchange.emails', new AMQPMessage('Thanks!'), 'severity');
176+
?>
177+
```
178+
179+
* `param string` $exchange
180+
* `param string|\PhpAmqpLib\Message\AMQPMessage` $message
181+
* `param string` $routing_key
182+
183+
184+
### pushToQueue
185+
186+
Sends message to queue
187+
188+
``` php
189+
<?php
190+
$I->pushToQueue('queue.jobs', 'create user');
191+
$I->pushToQueue('queue.jobs', new AMQPMessage('create'));
192+
?>
193+
```
194+
195+
* `param string` $queue
196+
* `param string|\PhpAmqpLib\Message\AMQPMessage` $message
197+
198+
199+
### scheduleQueueCleanup
200+
201+
Add a queue to purge list
202+
203+
* `param string` $queue
204+
205+
206+
### seeMessageInQueueContainsText
207+
208+
Checks if message containing text received.
209+
210+
**This method drops message from queue**
211+
**This method will wait for message. If none is sent the script will stuck**.
212+
213+
``` php
214+
<?php
215+
$I->pushToQueue('queue.emails', 'Hello, davert');
216+
$I->seeMessageInQueueContainsText('queue.emails','davert');
217+
?>
218+
```
219+
220+
* `param string` $queue
221+
* `param string` $text
222+
223+
224+
### seeNumberOfMessagesInQueue
225+
226+
Checks that queue have expected number of message
227+
228+
``` php
229+
<?php
230+
$I->pushToQueue('queue.emails', 'Hello, davert');
231+
$I->seeNumberOfMessagesInQueue('queue.emails',1);
232+
?>
233+
```
234+
235+
* `param string` $queue
236+
* `param int` $expected
237+
238+
239+
### seeQueueIsEmpty
240+
241+
Checks that queue is empty
242+
243+
``` php
244+
<?php
245+
$I->pushToQueue('queue.emails', 'Hello, davert');
246+
$I->purgeQueue('queue.emails');
247+
$I->seeQueueIsEmpty('queue.emails');
248+
?>
249+
```
250+
251+
* `param string` $queue
252+
* `param int` $expected
253+
254+
<p>&nbsp;</p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/module-amqp/tree/master/src/Codeception/Module/AMQP.php">Help us to improve documentation. Edit module reference</a></div>

readme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# AMQP module for Codeception
2+
3+
[![Build Status](https://travis-ci.org/Codeception/module-amqp.svg?branch=master)](https://travis-ci.org/Codeception/module-amqp)
4+
5+
## Installation
6+
7+
```
8+
composer require --dev "codeception/module-amqp"
9+
```
10+
11+
## Documentation
12+
13+
<a href="documentation.md">Look at documentation.md file</a>

0 commit comments

Comments
 (0)