@@ -47,6 +47,7 @@ public function testFromDsn()
47
47
$ this ->assertSame ('default ' , $ configuration ['tube_name ' ]);
48
48
$ this ->assertSame (0 , $ configuration ['timeout ' ]);
49
49
$ this ->assertSame (90 , $ configuration ['ttr ' ]);
50
+ $ this ->assertFalse ($ configuration ['bury_on_reject ' ]);
50
51
51
52
$ this ->assertEquals (
52
53
$ connection = new Connection ([], Pheanstalk::create ('foobar ' , 15555 )),
@@ -58,22 +59,32 @@ public function testFromDsn()
58
59
$ this ->assertSame ('default ' , $ configuration ['tube_name ' ]);
59
60
$ this ->assertSame (0 , $ configuration ['timeout ' ]);
60
61
$ this ->assertSame (90 , $ configuration ['ttr ' ]);
62
+ $ this ->assertFalse ($ configuration ['bury_on_reject ' ]);
61
63
$ this ->assertSame ('default ' , $ connection ->getTube ());
62
64
}
63
65
64
66
public function testFromDsnWithOptions ()
65
67
{
66
68
$ this ->assertEquals (
67
- $ connection = Connection::fromDsn ('beanstalkd://localhost ' , ['tube_name ' => 'foo ' , 'timeout ' => 10 , 'ttr ' => 5000 ]),
68
- Connection::fromDsn ('beanstalkd://localhost?tube_name=foo&timeout=10&ttr=5000 ' )
69
+ $ connectionWithOptions = Connection::fromDsn ('beanstalkd://localhost ' , ['tube_name ' => 'foo ' , 'timeout ' => 10 , 'ttr ' => 5000 , ' bury_on_reject ' => true ]),
70
+ $ connectionWithQuery = Connection::fromDsn ('beanstalkd://localhost?tube_name=foo&timeout=10&ttr=5000&bury_on_reject=true ' )
69
71
);
70
72
71
- $ configuration = $ connection ->getConfiguration ();
73
+ $ configuration = $ connectionWithOptions ->getConfiguration ();
72
74
73
75
$ this ->assertSame ('foo ' , $ configuration ['tube_name ' ]);
74
76
$ this ->assertSame (10 , $ configuration ['timeout ' ]);
75
77
$ this ->assertSame (5000 , $ configuration ['ttr ' ]);
76
- $ this ->assertSame ('foo ' , $ connection ->getTube ());
78
+ $ this ->assertTrue ($ configuration ['bury_on_reject ' ]);
79
+ $ this ->assertSame ('foo ' , $ connectionWithOptions ->getTube ());
80
+
81
+ $ configuration = $ connectionWithQuery ->getConfiguration ();
82
+
83
+ $ this ->assertSame ('foo ' , $ configuration ['tube_name ' ]);
84
+ $ this ->assertSame (10 , $ configuration ['timeout ' ]);
85
+ $ this ->assertSame (5000 , $ configuration ['ttr ' ]);
86
+ $ this ->assertTrue ($ configuration ['bury_on_reject ' ]);
87
+ $ this ->assertSame ('foo ' , $ connectionWithOptions ->getTube ());
77
88
}
78
89
79
90
public function testFromDsnOptionsArrayWinsOverOptionsFromDsn ()
@@ -82,18 +93,20 @@ public function testFromDsnOptionsArrayWinsOverOptionsFromDsn()
82
93
'tube_name ' => 'bar ' ,
83
94
'timeout ' => 20 ,
84
95
'ttr ' => 6000 ,
96
+ 'bury_on_reject ' => false ,
85
97
];
86
98
87
99
$ this ->assertEquals (
88
100
$ connection = new Connection ($ options , Pheanstalk::create ('localhost ' , 11333 )),
89
- Connection::fromDsn ('beanstalkd://localhost:11333?tube_name=foo&timeout=10&ttr=5000 ' , $ options )
101
+ Connection::fromDsn ('beanstalkd://localhost:11333?tube_name=foo&timeout=10&ttr=5000&bury_on_reject=true ' , $ options )
90
102
);
91
103
92
104
$ configuration = $ connection ->getConfiguration ();
93
105
94
106
$ this ->assertSame ($ options ['tube_name ' ], $ configuration ['tube_name ' ]);
95
107
$ this ->assertSame ($ options ['timeout ' ], $ configuration ['timeout ' ]);
96
108
$ this ->assertSame ($ options ['ttr ' ], $ configuration ['ttr ' ]);
109
+ $ this ->assertSame ($ options ['bury_on_reject ' ], $ configuration ['bury_on_reject ' ]);
97
110
$ this ->assertSame ($ options ['tube_name ' ], $ connection ->getTube ());
98
111
}
99
112
@@ -214,6 +227,21 @@ public function testReject()
214
227
$ connection ->reject ((string ) $ id );
215
228
}
216
229
230
+ public function testRejectWithBury ()
231
+ {
232
+ $ id = 123456 ;
233
+
234
+ $ tube = 'baz ' ;
235
+
236
+ $ client = $ this ->createMock (PheanstalkInterface::class);
237
+ $ client ->expects ($ this ->once ())->method ('useTube ' )->with ($ tube )->willReturn ($ client );
238
+ $ client ->expects ($ this ->once ())->method ('bury ' )->with ($ this ->callback (fn (JobId $ jobId ): bool => $ jobId ->getId () === $ id ));
239
+
240
+ $ connection = new Connection (['tube_name ' => $ tube , 'bury_on_reject ' => true ], $ client );
241
+
242
+ $ connection ->reject ((string ) $ id );
243
+ }
244
+
217
245
public function testRejectWhenABeanstalkdExceptionOccurs ()
218
246
{
219
247
$ id = 123456 ;
0 commit comments