Google\Cloud\Tests\Snippets\Datastore\DatastoreClientTest::testKeysWithAncestors PHP Method

testKeysWithAncestors() public method

    public function testKeysWithAncestors()
    {
        $snippet = $this->snippetFromMethod(DatastoreClient::class, 'keys', 1);
        $snippet->addLocal('datastore', $this->client);
        $res = $snippet->invoke('keys');
        $this->assertTrue(is_array($res->returnVal()));
        $this->assertEquals(3, count($res->returnVal()));
        $this->assertInstanceOf(Key::class, $res->returnVal()[0]);
        $this->assertEquals(['kind' => 'Person'], $res->returnVal()[0]->keyObject()['path'][2]);
        $this->assertEquals(['kind' => 'Person', 'name' => 'Dad Mike'], $res->returnVal()[0]->keyObject()['path'][1]);
        $this->assertEquals(['kind' => 'Person', 'name' => 'Grandpa Joe'], $res->returnVal()[0]->keyObject()['path'][0]);
    }