99use Enqueue \Test \ClassExtensionTrait ;
1010use PHPUnit \Framework \TestCase ;
1111use Symfony \Component \Config \Definition \Builder \TreeBuilder ;
12+ use Symfony \Component \Config \Definition \Exception \InvalidConfigurationException ;
1213use Symfony \Component \Config \Definition \Processor ;
1314use Symfony \Component \DependencyInjection \ContainerBuilder ;
1415use Symfony \Component \DependencyInjection \Reference ;
@@ -54,6 +55,7 @@ public function testShouldAllowAddConfiguration()
5455 'vhost ' => '/ ' ,
5556 'persisted ' => false ,
5657 'lazy ' => true ,
58+ 'receive_method ' => 'basic_get ' ,
5759 ], $ config );
5860 }
5961
@@ -76,6 +78,47 @@ public function testShouldAllowAddConfigurationAsString()
7678 'vhost ' => '/ ' ,
7779 'persisted ' => false ,
7880 '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 ' ,
79122 ], $ config );
80123 }
81124
0 commit comments