Google\Cloud\Tests\Snippets\Logging\LoggerTest::testEntriesWithFilter PHP Method

testEntriesWithFilter() public method

    public function testEntriesWithFilter()
    {
        $snippet = $this->snippetFromMethod(Logger::class, 'entries', 1);
        $snippet->addLocal('logger', $this->logger);
        $this->connection->listEntries(Argument::that(function ($arg) {
            if (!isset($arg['filter'])) {
                return false;
            }
            if (strpos($arg['filter'], 'AND') === false) {
                return false;
            }
            return true;
        }))->shouldBeCalled()->willReturn(['entries' => [['textPayload' => 'foo'], ['textPayload' => 'bar']]]);
        $this->logger->setConnection($this->connection->reveal());
        $res = $snippet->invoke('entries');
        $this->assertInstanceOf(\Generator::class, $res->returnVal());
        $this->assertEquals('foo', explode(PHP_EOL, $res->output())[0]);
        $this->assertEquals('bar', explode(PHP_EOL, $res->output())[1]);
    }