info() public method

Currently this resource returns only the topic name, if the topic exists. It is mostly useful therefore for checking if a topic exists. Since this method will throw an exception if the topic is not found, you may find that Topic::exists() is a better fit for a true/false check. This method will use the previously cached result, if available. To force a refresh from the API, use {@see \Google\Cloud\Pubsub\Topic::reload()}. Example: $info = $topic->info(); echo $info['name']; // projects/my-awesome-project/topics/my-new-topic
See also: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/get Get Topic
public info ( array $options = [] ) : array
$options array [optional] Configuration Options
return array [A representation of a Topic](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics)
Beispiel #1
0
 public function testInfo()
 {
     $this->connection->getTopic(Argument::withEntry('foo', 'bar'))->willReturn(['name' => 'projects/project-name/topics/topic-name'])->shouldBeCalledTimes(1);
     $topic = new Topic($this->connection->reveal(), 'topic-name', 'project-name');
     $res = $topic->info(['foo' => 'bar']);
     $res2 = $topic->info();
     $this->assertEquals($res, $res2);
     $this->assertEquals($res['name'], 'projects/project-name/topics/topic-name');
 }