Basho\Tests\ObjectOperationsTest::testFetchAssociativeArray PHP Method

testFetchAssociativeArray() public method

    public function testFetchAssociativeArray()
    {
        $data = ['myData' => 42];
        $command = (new Command\Builder\StoreObject(static::$riak))->buildLocation(static::$key, 'users')->buildJsonObject($data)->build();
        $response = $command->execute();
        $this->assertEquals('204', $response->getCode());
        // Fetch as associative array
        $command = (new Command\Builder\FetchObject(static::$riak))->buildLocation(static::$key, 'users')->withDecodeAsAssociative()->build();
        $response = $command->execute();
        $this->assertEquals('200', $response->getCode());
        $this->assertEquals($data, $response->getObject()->getData());
        $this->assertEquals('array', gettype($response->getObject()->getData()));
        // Fetch normal to get as stdClass object
        $command = (new Command\Builder\FetchObject(static::$riak))->buildLocation(static::$key, 'users')->build();
        $response = $command->execute();
        $this->assertEquals('200', $response->getCode());
        $this->assertEquals('object', gettype($response->getObject()->getData()));
    }