1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-27 11:32:30 +01:00
guzzle/tests/Guzzle/Tests/Service/JsonLoaderTest.php
Michael Dowling f8e8c0302b Refactoring service builders and service factories
[BC] [Service] Moving Guzzle\Service\Builder to
Guzzle\Service\Builder\ServiceBuilder
[Service] Creating an AbstractFactory used to delegate class
instantiation to a concrete factory. Used with service builders and
service descriptions
[Service] Making service descriptions and builders cacheable
[Service] Adding the ability to set global option overrides to service
builder configs. These options are applied to each service owned by a
service builder.  This can be used to globally specify access keys for
example.
[Service] Adding the ability to include other service builder config
files from within XML and JSON files.
[Service] Changing the format of XML and JSON configs.  Old format still
works too.
[Service] Moving XML service description includes to the end of
execution, so that includes are at the beginning of the parsed array.
[Service] Adding a Guzzle\Service\JsonLoader for loading JSON files that
have an { "includes": [] } array
2012-05-13 23:30:13 -07:00

46 lines
1.3 KiB
PHP

<?php
namespace Guzzle\Tests\Service;
use Guzzle\Service\JsonLoader;
/**
* @covers Guzzle\Service\JsonLoader
*/
class JsonLoaderTest extends \Guzzle\Tests\GuzzleTestCase
{
/**
* @expectedException Guzzle\Service\Exception\JsonException
* @expectedExceptionMessage Unable to open
*/
public function testFileMustBeReadable()
{
$loader = new JsonLoader();
$loader->parseJsonFile('fooooooo!');
}
/**
* @expectedException Guzzle\Service\Exception\JsonException
* @expectedExceptionMessage Error loading JSON data from
*/
public function testJsonMustBeValue()
{
$loader = new JsonLoader();
$loader->parseJsonFile(__FILE__);
}
public function testFactoryCanCreateFromJson()
{
$file = dirname(__DIR__) . '/TestData/services/json1.json';
$loader = new JsonLoader();
$data = $loader->parseJsonFile($file);
$this->assertArrayHasKey('includes', $data);
$this->assertArrayHasKey('services', $data);
$this->assertInternalType('array', $data['services']['foo']);
$this->assertInternalType('array', $data['services']['abstract']);
$this->assertInternalType('array', $data['services']['mock']);
$this->assertEquals('bar', $data['services']['foo']['params']['baz']);
}
}