MongoQueueTest::getUnsupportedItemTypes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\MongoHandler;
15
16
/**
17
 * @requires function MongoClient::connect
18
 */
19
class MongoQueueTest extends QueueTest
20
{
21
    use Performance;
22
    use Concurrency;
23
24
    protected function getUnsupportedItemTypes()
25
    {
26
        return [Types::TYPE_BINARY_STRING, Types::TYPE_OBJECT];
27
    }
28
29
    /**
30
     * @dataProvider provideItemsOfUnsupportedTypes
31
     * @expectedException Exception
32
     * @expectedExceptionMessageRegExp /zero-length keys are not allowed|non-utf8 string|Objects are not identical/
33
     */
34
    public function testUnsupportedItemType($item, $type)
35
    {
36
        $this->queue->push($item);
37
38
        if (Types::TYPE_OBJECT === $type && $item !== $this->queue->pop()) {
39
            throw new \Exception('Objects are not identical');
40
        }
41
    }
42
43
    public static function createHandler(array $config)
44
    {
45
        return new MongoHandler([
46
            'server'    => $config['PHIVE_MONGO_SERVER'],
47
            'db_name'   => $config['PHIVE_MONGO_DB_NAME'],
48
            'coll_name' => $config['PHIVE_MONGO_COLL_NAME'],
49
        ]);
50
    }
51
}
52