public function testDelete() { StreamWrapper::emulate(HttpEmulation::fromCallable(function (RequestInterface $request) { $this->assertEquals('POST', $request->getMethod()); $this->assertEquals('/1.1/statuses/destroy/2.json', $request->getUri()->getPath()); return new \GuzzleHttp\Psr7\Response(200, [], json_encode(['id' => 2, 'text' => 'Status 2?'])); })); $query = new Query($this->webservice, new Endpoint(['endpoint' => 'statuses', 'connection' => $this->webservice->driver()])); $query->action(Query::ACTION_DELETE); $query->where(['id' => 2]); $this->assertTrue($this->webservice->execute($query)); }
/** * Execute the appropriate method for a query * * @param \Muffin\Webservice\Query $query The query to execute * @param array $options The options to use * * @return bool|int|\Muffin\Webservice\ResultSet */ protected function _executeQuery(Query $query, array $options = []) { switch ($query->action()) { case Query::ACTION_CREATE: return $this->_executeCreateQuery($query, $options); case Query::ACTION_READ: return $this->_executeReadQuery($query, $options); case Query::ACTION_UPDATE: return $this->_executeUpdateQuery($query, $options); case Query::ACTION_DELETE: return $this->_executeDeleteQuery($query, $options); } return false; }