• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

PHPUnit - REST API testing

restphpunitguzzle


PHP Snippet 1:

$response = $this->call('POST', '/api/v1.0/pages', $parameters);
$data = $response->getData();

PHP Snippet 2:

var_dump($response->getBody()->getContents());

PHP Snippet 3:

$client = new GuzzleHttp\Client();
$response = $client->get('http://192.168.99.100/v1/hello');
var_dump($response->getBody()->getContents());

PHP Snippet 4:

string(13) "{"bar":"foo"}"

Related Snippets

How to create tests w/Doctrine entities without persisting them (how to set id)

Symfony - "framework.test" config is not set to true

Send POST data via raw JSON with Postman

Is there a way to use Foundry Model for Authentification inside Functional Tests?

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

Where do I need to place a hook for phpunit?

Custom API and cunsuming in php?

Phpunit partial mock + proxy Entity

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

How can I make Laravel return a custom error for a JSON REST API

PHP Fatal error: Class not found - PHPUnit

phpunit - testing is painfully slow

Trying to mock an http client that is inside a controller, using phpunit, but it doesn't work

GuzzleHttp Hangs When Using Localhost

How do I do HTTP basic authentication using Guzzle?

About Contact Privacy policy Terms and conditions