File: YamlResponseParserTest.php

package info (click to toggle)
php-pda-pheanstalk 4.0.5-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 608 kB
  • sloc: php: 2,658; xml: 60; makefile: 15
file content (32 lines) | stat: -rw-r--r-- 912 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php


namespace Pheanstalk;

use Pheanstalk\Exception\ClientException;
use PHPUnit\Framework\TestCase;

class YamlResponseParserTest extends TestCase
{

    public function testList()
    {
        $parser = new YamlResponseParser(YamlResponseParser::MODE_LIST);
        $response = $parser->parseResponse('OK 1', "---\n- a\n- b");
        $this->assertEquals(['a', 'b'], iterator_to_array($response));
    }

    public function testInvalidList()
    {
        $this->expectException(ClientException::class);
        $parser = new YamlResponseParser(YamlResponseParser::MODE_LIST);
        $response = $parser->parseResponse('OK 1', "---\n- a\nb");
    }

    public function testInvalidDictionary()
    {
        $this->expectException(ClientException::class);
        $parser = new YamlResponseParser(YamlResponseParser::MODE_DICT);
        $response = $parser->parseResponse('OK 1', "---\n: b\n");
    }
}