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");
}
}
|