使用phpspec测试Symfony 2与Guzzle API客户端的捆绑

Good morning!

I have recently created a Symfony 2 bundle that integrates with a third party API.
I have used Guzzle with the awesome service description to create the client and call the API.

Now I want to improve the quality and add some testing to it. After some reading I came up to use phpspec for the functional testing of the client and Behat for the behavior.
I have read that you can mock the API responses but I can’t figure out how. Though phpspec has a mocking library inside (prophecy), I can’t find any examples how to mock the responses in prophecy.

I have my spec created with

bin/phpspec desc NewFusion/Bundle/HyperMediaBundle/Service/VehicleService

And it has created my spec class in the Bundle/spec/ folder.

<?php

namespace spec\NewFusion\Bundle\HyperMediaBundle\Service;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class VehicleReferenceDataServiceSpec extends ObjectBehavior
{
    function it_is_initializable()
    {
        $this->shouldHaveType('NewFusion\Bundle\HyperMediaBundle\Service\VehicleReferenceDataService');
    }

    function it_should_return_make_name() {
        $this->getMake(array('makeCode' => 1))->shouldReturn(TRUE);
    }
}

This is the response I want the mock with this test:

HTTP/1.1 200 OK
Cache-Control: no-cache,no-store,must-revalidate
Connection: Keep-Alive
Content-Type: application/vnd.siren+json; charset=UTF-8
Date: 12 Feb 2014 07:43:00 GMT
Expires: Thu, 01 Jan 1970 00:00:00 GMT, 0
Keep-Alive: timeout=15, max=100
Pragma: no-cache
Server: Jetty(8.y.z-SNAPSHOT)
Transfer-Encoding: chunked
Via: 1.1 test.local

{
"class": [
"Make"
],
"properties": {
"makeCode": "1",
"name": "Alfa Romeo"
},
"links": [
{
"rel": [
"self"
],
"href": "https://test.local/v1/api/vehiclereferencedata/make/1"
},
{ "rel": [
"models"
],
"href": "https://test.local/make/1/model"
}
]
}

I hope someone will get me on track :)