/** * @expectedException \CvoTechnologies\Twitter\Webservice\Exception\UnknownStreamEndpointException */ public function testUnknownStreamEndpoint() { $query = new Query($this->webservice, new Endpoint()); $query->read(); $query->applyOptions(['streamEndpoint' => 'test123']); $this->webservice->execute($query); }
public function testGeneralReadMultipleIds() { StreamWrapper::emulate(HttpEmulation::fromCallable(function (RequestInterface $request) { $this->assertEquals('GET', $request->getMethod()); $this->assertEquals('/1.1/statuses/lookup.json', $request->getUri()->getPath()); $this->assertEquals('id=1%2C2%2C3%2C4', $request->getUri()->getQuery()); return new \GuzzleHttp\Psr7\Response(200, [], json_encode([['id' => 2, 'text' => 'Status 2'], ['id' => 3, 'text' => 'Status 3']])); })); $query = new Query($this->webservice, new Endpoint(['endpoint' => 'statuses', 'connection' => $this->webservice->driver()])); $query->read(); $query->where(['id' => [1, 2, 3, 4]]); $query->applyOptions(['index' => 'user_timeline']); $resultSet = $this->webservice->execute($query); $this->assertInstanceOf('Muffin\\Webservice\\ResultSet', $resultSet); $this->assertInstanceOf('Muffin\\Webservice\\Model\\Resource', $resultSet->first()); $this->assertEquals('Status 2', $resultSet->first()->text); $this->assertEquals(2, $resultSet->count()); }
/** * Use the Twitter filter stream. * * @param \Muffin\Webservice\Query $query The query to modify. * @param array $options The conditions to apply to the query. * @return Query The modified query. */ public function findFilterStream(Query $query, array $options) { return $query->applyOptions(['streamEndpoint' => 'filter'])->where($options); }
/** * Calls a finder method directly and applies it to the passed query, * if no query is passed a new one will be created and returned * * @param string $type name of the finder to be called * @param \Muffin\Webservice\Query $query The query object to apply the finder options to * @param array $options List of options to pass to the finder * * @return \Muffin\Webservice\Query */ public function callFinder($type, Query $query, array $options = []) { $query->applyOptions($options); $options = $query->getOptions(); $finder = 'find' . $type; if (method_exists($this, $finder)) { return $this->{$finder}($query, $options); } throw new \BadMethodCallException(sprintf('Unknown finder method "%s"', $type)); }
public function testReadSwitchUser() { $this->webservice->driver()->client($this->_clientMock('get', '/issues.json', [], ['issues' => [['subject' => 'Hello']]], ['X-Redmine-Switch-User: marlinc'])); $query = new Query($this->webservice, new Endpoint(['connection' => new Connection(['name' => 'redmine', 'driver' => 'CvoTechnologies\\Redmine\\Webservice\\Driver\\Redmine']), 'endpoint' => 'issues', 'schema' => new Schema('issues')])); $query->read(); $query->applyOptions(['user' => 'marlinc']); $resultSet = $this->webservice->execute($query); $this->assertInstanceOf('Muffin\\Webservice\\ResultSet', $resultSet); $this->assertEquals(1, $resultSet->total()); $this->assertInstanceOf('Muffin\\Webservice\\Model\\Resource', $resultSet->first()); $this->assertEquals('Hello', $resultSet->first()->subject); }