-
Notifications
You must be signed in to change notification settings - Fork 440
/
Copy pathMissingTransportFactoryTest.php
73 lines (58 loc) · 2.77 KB
/
MissingTransportFactoryTest.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
66
67
68
69
70
71
72
73
<?php
namespace Enqueue\Tests\Symfony;
use Enqueue\Symfony\MissingTransportFactory;
use Enqueue\Symfony\TransportFactoryInterface;
use Enqueue\Test\ClassExtensionTrait;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\Config\Definition\Processor;
class MissingTransportFactoryTest extends TestCase
{
use ClassExtensionTrait;
public function testShouldImplementTransportFactoryInterface()
{
$this->assertClassImplements(TransportFactoryInterface::class, MissingTransportFactory::class);
}
public function testCouldBeConstructedWithNameAndPackages()
{
$transport = new MissingTransportFactory('aMissingTransportName', ['aPackage', 'anotherPackage']);
$this->assertEquals('aMissingTransportName', $transport->getName());
}
public function testThrowOnProcessForOnePackageToInstall()
{
$transport = new MissingTransportFactory('aMissingTransportName', ['aFooPackage']);
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
$transport->addConfiguration($rootNode);
$processor = new Processor();
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage('Invalid configuration for path "foo": In order to use the transport "aMissingTransportName" install a package "aFooPackage"');
$processor->process($tb->buildTree(), [[]]);
}
public function testThrowOnProcessForSeveralPackagesToInstall()
{
$transport = new MissingTransportFactory('aMissingTransportName', ['aFooPackage', 'aBarPackage']);
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
$transport->addConfiguration($rootNode);
$processor = new Processor();
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage('Invalid configuration for path "foo": In order to use the transport "aMissingTransportName" install one of the packages "aFooPackage", "aBarPackage"');
$processor->process($tb->buildTree(), [[]]);
}
public function testThrowEvenIfThereAreSomeOptionsPassed()
{
$transport = new MissingTransportFactory('aMissingTransportName', ['aFooPackage', 'aBarPackage']);
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
$transport->addConfiguration($rootNode);
$processor = new Processor();
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage('In order to use the transport "aMissingTransportName"');
$processor->process($tb->buildTree(), [[
'foo' => 'fooVal',
'bar' => 'barVal',
]]);
}
}