Google\Cloud\Tests\Datastore\DatastoreSessionHandlerTest::testReadEntity PHP Method

testReadEntity() public method

public testReadEntity ( )
    public function testReadEntity()
    {
        $key = new Key('projectid');
        $key->pathElement(self::KIND, 'sessionid');
        $entity = new Entity($key, ['data' => 'sessiondata']);
        $this->transaction->lookup($key)->shouldBeCalledTimes(1)->willReturn($entity);
        $this->datastore->transaction()->shouldBeCalledTimes(1)->willReturn($this->transaction->reveal());
        $this->datastore->key(self::KIND, 'sessionid', ['namespaceId' => self::NAMESPACE_ID])->shouldBeCalledTimes(1)->willReturn($key);
        $datastoreSessionHandler = new DatastoreSessionHandler($this->datastore->reveal());
        $datastoreSessionHandler->open(self::NAMESPACE_ID, self::KIND);
        $ret = $datastoreSessionHandler->read('sessionid');
        $this->assertEquals('sessiondata', $ret);
    }