示例#1
0
 public function testStoreAndFetchSchema()
 {
     $content = $this->getSchemaContent('schedule.xml');
     $schema = new YokozunaSchema('schedule', $content);
     $store = StoreSchema::builder()->withSchema($schema)->build();
     $fetch = FetchSchema::builder()->withSchemaName('schedule')->build();
     $storeResponse = $this->client->execute($store);
     $fetchResponse = $this->client->execute($fetch);
     $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\StoreSchemaResponse', $storeResponse);
     $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\FetchSchemaResponse', $fetchResponse);
     $this->assertInstanceOf('Riak\\Client\\Core\\Query\\Search\\YokozunaSchema', $fetchResponse->getSchema());
     $this->assertXmlStringEqualsXmlString($content, $fetchResponse->getSchema()->getContent());
     $this->assertEquals('schedule', $fetchResponse->getSchema()->getName());
 }
示例#2
0
 public function testExecuteCommand()
 {
     $response = new GetSchemaResponse();
     $command = FetchSchema::builder()->withSchemaName('schema-name')->build();
     $response->name = 'schema-name';
     $response->content = 'schema-content';
     $callback = function ($subject) {
         $this->assertInstanceOf('Riak\\Client\\Core\\Message\\Search\\GetSchemaRequest', $subject);
         $this->assertEquals('schema-name', $subject->name);
         return true;
     };
     $this->adapter->expects($this->once())->method('send')->with($this->callback($callback))->will($this->returnValue($response));
     $result = $this->client->execute($command);
     $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\FetchSchemaResponse', $result);
     $this->assertInstanceOf('Riak\\Client\\Core\\Query\\Search\\YokozunaSchema', $result->getSchema());
     $this->assertEquals('schema-content', $result->getSchema()->getContent());
     $this->assertEquals('schema-name', $result->getSchema()->getName());
 }