Skip to content

Commit

Permalink
Fix values implementation manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
tbolier committed Sep 8, 2018
1 parent f568cf9 commit 08d4b83
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Query/Manipulation/ManipulationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function keys(): Keys
return new Keys($this->rethink, /** @scrutinizer ignore-type */ $this);
}

public function values(): QueryInterface
public function values(): Values
{
return new Values($this->rethink, /** @scrutinizer ignore-type */ $this);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Query/Manipulation/Values.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public function toArray(): array
{
return [
TermType::VALUES,
$this->query->toArray(),
[
$this->query->toArray()
],
];
}
}
12 changes: 7 additions & 5 deletions test/integration/Manipulation/ValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace TBolier\RethinkQL\IntegrationTest\Manipulation;

use TBolier\RethinkQL\IntegrationTest\Query\AbstractTableTest;
use TBolier\RethinkQL\Response\ResponseInterface;

class ValuesTest extends AbstractTableTest
{
Expand All @@ -12,16 +13,17 @@ class ValuesTest extends AbstractTableTest
*/
public function testValuesResult()
{
$this->insertDocumentWithNumber(1, 1);
$this->insertDocumentWithNumber(1, 777);

/** @var Cursor $cursor */
$cursor = $this->r()
/** @var ResponseInterface $cursor */
$response = $this->r()
->table('tabletest')
->get(1)
->values()
->run();

$this->assertInstanceOf(\Iterator::class, $cursor);
$this->assertEquals(1, $cursor->count());
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertCount(4, $response->getData());
$this->assertArraySubset([2 => 777], $response->getData());
}
}

0 comments on commit 08d4b83

Please sign in to comment.