@@ -20,37 +20,25 @@ public function testShouldImplementRegistryInterface()
20
20
$ this ->assertClassImplements (Registry::class, ContainerAwareRegistry::class);
21
21
}
22
22
23
- public function testCouldBeConstructedWithEventsMapAndTransformersMapAsArguments ()
24
- {
25
- new ContainerAwareRegistry ([], []);
26
- }
27
-
28
- public function testShouldSetContainerToContainerProperty ()
23
+ public function testShouldAllowGetTransportNameByEventName ()
29
24
{
30
25
$ container = new Container ();
31
26
32
- $ registry = new ContainerAwareRegistry ([], []);
33
-
34
- $ registry ->setContainer ($ container );
35
-
36
- $ this ->assertAttributeSame ($ container , 'container ' , $ registry );
37
- }
38
-
39
- public function testShouldAllowGetTransportNameByEventName ()
40
- {
41
27
$ registry = new ContainerAwareRegistry ([
42
- 'fooEvent ' => 'fooTrans ' ,
43
- ], []);
28
+ 'fooEvent ' => 'fooTrans ' ,
29
+ ], [], $ container );
44
30
45
31
$ this ->assertEquals ('fooTrans ' , $ registry ->getTransformerNameForEvent ('fooEvent ' ));
46
32
}
47
33
48
34
public function testShouldAllowDefineTransportNameAsRegExpPattern ()
49
35
{
36
+ $ container = new Container ();
37
+
50
38
$ registry = new ContainerAwareRegistry ([
51
39
'/.*/ ' => 'fooRegExpTrans ' ,
52
40
'fooEvent ' => 'fooTrans ' ,
53
- ], []);
41
+ ], [], $ container );
54
42
55
43
// guard
56
44
$ this ->assertEquals ('fooTrans ' , $ registry ->getTransformerNameForEvent ('fooEvent ' ));
@@ -60,9 +48,11 @@ public function testShouldAllowDefineTransportNameAsRegExpPattern()
60
48
61
49
public function testThrowIfNotSupportedEventGiven ()
62
50
{
51
+ $ container = new Container ();
52
+
63
53
$ registry = new ContainerAwareRegistry ([
64
54
'fooEvent ' => 'fooTrans ' ,
65
- ], []);
55
+ ], [], $ container );
66
56
67
57
$ this ->expectException (\LogicException::class);
68
58
$ this ->expectExceptionMessage ('There is no transformer registered for the given event fooNotSupportedEvent ' );
@@ -71,9 +61,11 @@ public function testThrowIfNotSupportedEventGiven()
71
61
72
62
public function testThrowIfThereIsNoRegisteredTransformerWithSuchName ()
73
63
{
64
+ $ container = new Container ();
65
+
74
66
$ registry = new ContainerAwareRegistry ([], [
75
67
'fooTrans ' => 'foo_trans_id ' ,
76
- ]);
68
+ ], $ container );
77
69
78
70
$ this ->expectException (\LogicException::class);
79
71
$ this ->expectExceptionMessage ('There is no transformer named fooNotRegisteredName ' );
@@ -87,8 +79,7 @@ public function testThrowIfContainerReturnsServiceNotInstanceOfEventTransformer(
87
79
88
80
$ registry = new ContainerAwareRegistry ([], [
89
81
'fooTrans ' => 'foo_trans_id ' ,
90
- ]);
91
- $ registry ->setContainer ($ container );
82
+ ], $ container );
92
83
93
84
$ this ->expectException (\LogicException::class);
94
85
$ this ->expectExceptionMessage ('The container must return instance of Enqueue\AsyncEventDispatcher\EventTransformer but got stdClass ' );
@@ -104,8 +95,7 @@ public function testShouldReturnEventTransformer()
104
95
105
96
$ registry = new ContainerAwareRegistry ([], [
106
97
'fooTrans ' => 'foo_trans_id ' ,
107
- ]);
108
- $ registry ->setContainer ($ container );
98
+ ], $ container );
109
99
110
100
$ this ->assertSame ($ eventTransformerMock , $ registry ->getTransformer ('fooTrans ' ));
111
101
}
0 commit comments