77
88namespace Queue \Test \TestCase \Model \Table ;
99
10+ use Cake \Datasource \ConnectionManager ;
1011use Cake \I18n \Time ;
1112use Cake \ORM \TableRegistry ;
1213use Cake \TestSuite \TestCase ;
@@ -100,6 +101,8 @@ public function testCreateAndCount() {
100101 * @return void
101102 */
102103 public function testCreateAndFetch () {
104+ $ this ->_needsConnection ();
105+
103106 //$capabilities is a list of tasks the worker can run.
104107 $ capabilities = [
105108 'task1 ' => [
@@ -152,6 +155,8 @@ public function testCreateAndFetch() {
152155 * @return void
153156 */
154157 public function testSequence () {
158+ $ this ->_needsConnection ();
159+
155160 //$capabilities is a list of tasks the worker can run.
156161 $ capabilities = [
157162 'task1 ' => [
@@ -176,9 +181,7 @@ public function testSequence() {
176181 foreach (range (0 , 4 ) as $ num ) {
177182 $ this ->QueuedJobs ->clearKey ();
178183 $ array [$ num ] = $ this ->QueuedJobs ->requestJob ($ capabilities );
179- //debug($job);ob_flush();
180184 $ jobData = unserialize ($ array [$ num ]['data ' ]);
181- //debug($jobData);ob_flush();
182185 $ this ->assertEquals ($ num , $ jobData ['tasknum ' ]);
183186 }
184187 // now mark them as done
@@ -217,9 +220,11 @@ public function testNotBefore() {
217220 * Test Job reordering depending on 'notBefore' field.
218221 * Jobs with an expired notbefore field should be executed before any other job without specific timing info.
219222 *
220- * @return null
223+ * @return void
221224 */
222225 public function testNotBeforeOrder () {
226+ $ this ->_needsConnection ();
227+
223228 $ capabilities = [
224229 'task1 ' => [
225230 'name ' => 'task1 ' ,
@@ -279,6 +284,8 @@ public function testNotBeforeOrder() {
279284 * @return void
280285 */
281286 public function testRateLimit () {
287+ $ this ->_needsConnection ();
288+
282289 $ capabilities = [
283290 'task1 ' => [
284291 'name ' => 'task1 ' ,
@@ -363,7 +370,7 @@ public function testRateLimit() {
363370 }
364371
365372 /**
366- * Are those tests still valid?
373+ * Are those tests still valid? //FIXME
367374 *
368375 * @return void
369376 */
@@ -401,7 +408,7 @@ public function _testRequeueAfterTimeout() {
401408 * Tests whether the timeout of second tasks doesn't interfere with
402409 * requeue of tasks
403410 *
404- * Are those tests still valid?
411+ * Are those tests still valid? //FIXME
405412 *
406413 * @return void
407414 */
@@ -444,6 +451,8 @@ public function _testRequeueAfterTimeout2() {
444451 * @return void
445452 */
446453 public function testRequestGroup () {
454+ $ this ->_needsConnection ();
455+
447456 $ capabilities = [
448457 'task1 ' => [
449458 'name ' => 'task1 ' ,
@@ -513,6 +522,8 @@ public function testRequestGroup() {
513522 * @return void
514523 */
515524 public function testPriority () {
525+ $ this ->_needsConnection ();
526+
516527 $ capabilities = [
517528 'task1 ' => [
518529 'name ' => 'task1 ' ,
@@ -536,4 +547,14 @@ public function testPriority() {
536547 $ this ->assertSame (['key ' => 'k2 ' ], $ data );
537548 }
538549
550+ /**
551+ * Helper method for skipping tests that need a real connection.
552+ *
553+ * @return void
554+ */
555+ protected function _needsConnection () {
556+ $ config = ConnectionManager::config ('test ' );
557+ $ this ->skipIf (strpos ($ config ['driver ' ], 'Mysql ' ) === false , 'Only Mysql is working yet for this. ' );
558+ }
559+
539560}
0 commit comments