9
9
use Enqueue \Test \ClassExtensionTrait ;
10
10
use PHPUnit \Framework \TestCase ;
11
11
use Symfony \Component \Config \Definition \Builder \TreeBuilder ;
12
+ use Symfony \Component \Config \Definition \Exception \InvalidConfigurationException ;
12
13
use Symfony \Component \Config \Definition \Processor ;
13
14
use Symfony \Component \DependencyInjection \ContainerBuilder ;
14
15
use Symfony \Component \DependencyInjection \Reference ;
@@ -54,6 +55,7 @@ public function testShouldAllowAddConfiguration()
54
55
'vhost ' => '/ ' ,
55
56
'persisted ' => false ,
56
57
'lazy ' => true ,
58
+ 'receive_method ' => 'basic_get ' ,
57
59
], $ config );
58
60
}
59
61
@@ -76,6 +78,47 @@ public function testShouldAllowAddConfigurationAsString()
76
78
'vhost ' => '/ ' ,
77
79
'persisted ' => false ,
78
80
'lazy ' => true ,
81
+ 'receive_method ' => 'basic_get ' ,
82
+ ], $ config );
83
+ }
84
+
85
+ public function testThrowIfInvalidReceiveMethodIsSet ()
86
+ {
87
+ $ transport = new AmqpTransportFactory ();
88
+ $ tb = new TreeBuilder ();
89
+ $ rootNode = $ tb ->root ('foo ' );
90
+
91
+ $ transport ->addConfiguration ($ rootNode );
92
+ $ processor = new Processor ();
93
+
94
+ $ this ->expectException (InvalidConfigurationException::class);
95
+ $ this ->expectExceptionMessage ('The value "anInvalidMethod" is not allowed for path "foo.receive_method". Permissible values: "basic_get", "basic_consume" ' );
96
+ $ processor ->process ($ tb ->buildTree (), [[
97
+ 'receive_method ' => 'anInvalidMethod ' ,
98
+ ]]);
99
+ }
100
+
101
+ public function testShouldAllowChangeReceiveMethod ()
102
+ {
103
+ $ transport = new AmqpTransportFactory ();
104
+ $ tb = new TreeBuilder ();
105
+ $ rootNode = $ tb ->root ('foo ' );
106
+
107
+ $ transport ->addConfiguration ($ rootNode );
108
+ $ processor = new Processor ();
109
+ $ config = $ processor ->process ($ tb ->buildTree (), [[
110
+ 'receive_method ' => 'basic_consume ' ,
111
+ ]]);
112
+
113
+ $ this ->assertEquals ([
114
+ 'host ' => 'localhost ' ,
115
+ 'port ' => 5672 ,
116
+ 'user ' => 'guest ' ,
117
+ 'pass ' => 'guest ' ,
118
+ 'vhost ' => '/ ' ,
119
+ 'persisted ' => false ,
120
+ 'lazy ' => true ,
121
+ 'receive_method ' => 'basic_consume ' ,
79
122
], $ config );
80
123
}
81
124
0 commit comments