1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Phive Queue package. |
5
|
|
|
* |
6
|
|
|
* (c) Eugene Leonovich <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Phive\Queue\Tests\Queue; |
13
|
|
|
|
14
|
|
|
use Phive\Queue\Tests\Handler\TarantoolHandler; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @requires extension tarantool |
18
|
|
|
*/ |
19
|
|
|
class TarantoolQueueTest extends QueueTest |
20
|
|
|
{ |
21
|
|
|
use Performance; |
22
|
|
|
use Concurrency; |
23
|
|
|
|
24
|
|
|
protected $supportsExpiredEta = false; |
25
|
|
|
|
26
|
|
|
protected function getUnsupportedItemTypes() |
27
|
|
|
{ |
28
|
|
|
return [Types::TYPE_ARRAY, Types::TYPE_OBJECT]; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @dataProvider provideItemsOfUnsupportedTypes |
33
|
|
|
* @expectedException PHPUnit_Framework_Exception |
34
|
|
|
* @expectedExceptionMessageRegExp /could not be converted to string|Array to string conversion|unsupported field type/ |
35
|
|
|
*/ |
36
|
|
|
public function testUnsupportedItemType($item) |
37
|
|
|
{ |
38
|
|
|
$this->queue->push($item); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @see https://github.com/tarantool/tarantool/issues/336 |
43
|
|
|
*/ |
44
|
|
|
public function testItemsOfDifferentLength() |
45
|
|
|
{ |
46
|
|
|
for ($item = 'x'; strlen($item) < 9; $item .= 'x') { |
47
|
|
|
$this->queue->push($item); |
48
|
|
|
$this->assertEquals($item, $this->queue->pop()); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public static function createHandler(array $config) |
53
|
|
|
{ |
54
|
|
|
return new TarantoolHandler([ |
55
|
|
|
'host' => $config['PHIVE_TARANTOOL_HOST'], |
56
|
|
|
'port' => $config['PHIVE_TARANTOOL_PORT'], |
57
|
|
|
'space' => $config['PHIVE_TARANTOOL_SPACE'], |
58
|
|
|
'tube_name' => $config['PHIVE_TARANTOOL_TUBE_NAME'], |
59
|
|
|
]); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|