Google\Cloud\Tests\PubSub\PubSubClientTest::testTopics PHP Method

testTopics() public method

public testTopics ( )
    public function testTopics()
    {
        $topicResult = [['name' => 'projects/project/topics/topic-a'], ['name' => 'projects/project/topics/topic-b'], ['name' => 'projects/project/topics/topic-c']];
        $this->connection->listTopics(Argument::withEntry('foo', 'bar'))->willReturn(['topics' => $topicResult])->shouldBeCalledTimes(1);
        $this->client->setConnection($this->connection->reveal());
        $topics = $this->client->topics(['foo' => 'bar']);
        $this->assertInstanceOf(Generator::class, $topics);
        $arr = iterator_to_array($topics);
        $this->assertInstanceOf(Topic::class, $arr[0]);
        $this->assertEquals($arr[0]->info()['name'], $topicResult[0]['name']);
        $this->assertEquals($arr[1]->info()['name'], $topicResult[1]['name']);
        $this->assertEquals($arr[2]->info()['name'], $topicResult[2]['name']);
    }