|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Basho\Tests\Riak\Search; |
| 4 | + |
| 5 | +use Basho\Riak\Search\Doc; |
| 6 | +use PHPUnit_Framework_TestCase as TestCase; |
| 7 | + |
| 8 | +/** |
| 9 | + * Search result document test |
| 10 | + * |
| 11 | + * @author Michael Mayer <[email protected]> |
| 12 | + */ |
| 13 | +class DocTest extends TestCase |
| 14 | +{ |
| 15 | + /** |
| 16 | + * @var Doc |
| 17 | + */ |
| 18 | + protected $doc; |
| 19 | + |
| 20 | + public function setUp() |
| 21 | + { |
| 22 | + $data = new \stdClass(); |
| 23 | + $data->_yz_id = '1*tests*test*5*39'; |
| 24 | + $data->_yz_rk = '5'; |
| 25 | + $data->_yz_rt = 'tests'; |
| 26 | + $data->_yz_rb = 'test'; |
| 27 | + $data->foo = 'bar'; |
| 28 | + $data->_status = 200; |
| 29 | + $this->doc = new Doc($data); |
| 30 | + } |
| 31 | + |
| 32 | + public function testGetLocation() |
| 33 | + { |
| 34 | + $result = $this->doc->getLocation(); |
| 35 | + $this->assertInstanceOf('\Basho\Riak\Location', $result); |
| 36 | + $this->assertInstanceOf('\Basho\Riak\Bucket', $result->getBucket()); |
| 37 | + $this->assertEquals('tests', $result->getBucket()->getType()); |
| 38 | + $this->assertEquals('test', $result->getBucket()->getName()); |
| 39 | + $this->assertEquals('5', $result->getKey()); |
| 40 | + } |
| 41 | + |
| 42 | + public function testGetData() |
| 43 | + { |
| 44 | + $result = $this->doc->getData(); |
| 45 | + $this->assertInternalType('array', $result); |
| 46 | + $this->assertEquals('bar', $result['foo']); |
| 47 | + $this->assertEquals(200, $result['_status']); |
| 48 | + } |
| 49 | + |
| 50 | + public function testMagicGetter() |
| 51 | + { |
| 52 | + $this->assertEquals('bar', $this->doc->foo); |
| 53 | + $this->assertEquals(200, $this->doc->_status); |
| 54 | + } |
| 55 | +} |
0 commit comments