-
Notifications
You must be signed in to change notification settings - Fork 6
/
UnitTestCaseTest.php
65 lines (50 loc) · 2.43 KB
/
UnitTestCaseTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace TestTools\Tests\Buzz;
use TestTools\TestCase\UnitTestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
/**
* @author Michael Mayer <michael@lastzero.net>
* @package TestTools
* @license MIT
*/
class UnitTestCaseTest extends UnitTestCase
{
public function testGetFixturePath()
{
$fixturePath = $this->getContainer()->getParameter('fixture.path') . '/';
$this->assertStringEndsWith('src/Tests/_fixtures/TestCase/UnitTestCase/', $fixturePath);
$buzz = $this->get('buzz.fixture');
$this->assertInstanceOf('TestTools\Buzz\Client', $buzz);
$this->assertEquals($fixturePath, $buzz->getFixturePath());
$guzzle = $this->get('guzzle.request.factory');
$this->assertInstanceOf('TestTools\Guzzle\Http\RequestFactory', $guzzle);
$this->assertEquals($fixturePath, $guzzle->getFixturePath());
$dbal = $this->get('dbal.connection');
$this->assertInstanceOf('TestTools\Doctrine\DBAL\Connection', $dbal);
$this->assertEquals($fixturePath, $dbal->getFixturePath());
}
public function testContainerWithoutCloning()
{
$container = new ContainerBuilder();
$locator = new FileLocator(__DIR__);
$loader = new YamlFileLoader($container, $locator);
$loader->load('container.yml');
$container->setParameter('fixture.path', __DIR__ . '/foo/');
$container->setParameter('base.path', __DIR__);
$this->assertEquals(__DIR__ . '/foo/', $container->getParameter('fixture.path'));
$this->assertEquals(__DIR__, $container->getParameter('base.path'));
$buzz = $container->get('buzz.fixture');
$this->assertInstanceOf('TestTools\Buzz\Client', $buzz);
$this->assertEquals($container->getParameter('fixture.path'), $buzz->getFixturePath());
$container->reset();
$container->setParameter('fixture.path', __DIR__ . '/bar/');
$container->setParameter('base.path', __DIR__);
$this->assertEquals(__DIR__ . '/bar/', $container->getParameter('fixture.path'));
$this->assertEquals(__DIR__, $container->getParameter('base.path'));
$buzz = $container->get('buzz.fixture');
$this->assertInstanceOf('TestTools\Buzz\Client', $buzz);
$this->assertEquals($container->getParameter('fixture.path'), $buzz->getFixturePath());
}
}