Skip to content

Commit 781e11d

Browse files
committed
[gearman] fix tests.
1 parent 29a9385 commit 781e11d

10 files changed

+39
-30
lines changed

pkg/gearman/Tests/GearmanConnectionFactoryConfigTest.php

+8-9
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88

99
/**
1010
* The class contains the factory tests dedicated to configuration.
11-
*
12-
* @group functional
1311
*/
1412
class GearmanConnectionFactoryConfigTest extends TestCase
1513
{
1614
use ClassExtensionTrait;
15+
use SkipIfGearmanExtensionIsNotInstalledTrait;
1716

1817
public function testThrowNeitherArrayStringNorNullGivenAsConfig()
1918
{
@@ -57,24 +56,24 @@ public static function provideConfigs()
5756
yield [
5857
null,
5958
[
60-
'host' => \GEARMAN_DEFAULT_TCP_HOST,
61-
'port' => \GEARMAN_DEFAULT_TCP_PORT,
59+
'host' => 'localhost',
60+
'port' => 4730,
6261
],
6362
];
6463

6564
yield [
6665
'gearman://',
6766
[
68-
'host' => \GEARMAN_DEFAULT_TCP_HOST,
69-
'port' => \GEARMAN_DEFAULT_TCP_PORT,
67+
'host' => 'localhost',
68+
'port' => 4730,
7069
],
7170
];
7271

7372
yield [
7473
[],
7574
[
76-
'host' => \GEARMAN_DEFAULT_TCP_HOST,
77-
'port' => \GEARMAN_DEFAULT_TCP_PORT,
75+
'host' => 'localhost',
76+
'port' => 4730,
7877
],
7978
];
8079

@@ -98,7 +97,7 @@ public static function provideConfigs()
9897
['host' => 'theHost'],
9998
[
10099
'host' => 'theHost',
101-
'port' => \GEARMAN_DEFAULT_TCP_PORT,
100+
'port' => 4730,
102101
],
103102
];
104103
}

pkg/gearman/Tests/GearmanContextTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
class GearmanContextTest extends TestCase
1616
{
1717
use ClassExtensionTrait;
18+
use SkipIfGearmanExtensionIsNotInstalledTrait;
1819

1920
public function testShouldImplementPsrContextInterface()
2021
{

pkg/gearman/Tests/GearmanDestinationTest.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
use Enqueue\Test\ClassExtensionTrait;
99
use PHPUnit\Framework\TestCase;
1010

11-
/**
12-
* @group functional
13-
*/
1411
class GearmanDestinationTest extends TestCase
1512
{
1613
use ClassExtensionTrait;
14+
use SkipIfGearmanExtensionIsNotInstalledTrait;
1715

1816
public function testShouldImplementPsrQueueInterface()
1917
{

pkg/gearman/Tests/GearmanMessageTest.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
use Enqueue\Test\ClassExtensionTrait;
77
use PHPUnit\Framework\TestCase;
88

9-
/**
10-
* @group functional
11-
*/
129
class GearmanMessageTest extends TestCase
1310
{
1411
use ClassExtensionTrait;
12+
use SkipIfGearmanExtensionIsNotInstalledTrait;
1513

1614
public function testShouldAllowGetJobPreviouslySet()
1715
{

pkg/gearman/Tests/GearmanProducerTest.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
use Enqueue\Test\ClassExtensionTrait;
1313
use PHPUnit\Framework\TestCase;
1414

15-
/**
16-
* @group functional
17-
*/
1815
class GearmanProducerTest extends TestCase
1916
{
2017
use ClassExtensionTrait;
18+
use SkipIfGearmanExtensionIsNotInstalledTrait;
2119

2220
public function testCouldBeConstructedWithGearmanClientAsFirstArgument()
2321
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Enqueue\Gearman\Tests;
4+
5+
trait SkipIfGearmanExtensionIsNotInstalledTrait
6+
{
7+
public function setUp()
8+
{
9+
if (false == class_exists(\GearmanClient::class)) {
10+
$this->markTestSkipped('The gearman extension is not installed');
11+
}
12+
13+
parent::setUp();
14+
}
15+
}

pkg/gearman/Tests/Spec/GearmanConnectionFactoryTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
namespace Enqueue\Gearman\Tests\Spec;
44

55
use Enqueue\Gearman\GearmanConnectionFactory;
6+
use Enqueue\Gearman\Tests\SkipIfGearmanExtensionIsNotInstalledTrait;
67
use Enqueue\Psr\Spec\PsrConnectionFactorySpec;
78

8-
/**
9-
* @group functional
10-
*/
119
class GearmanConnectionFactoryTest extends PsrConnectionFactorySpec
1210
{
11+
use SkipIfGearmanExtensionIsNotInstalledTrait;
12+
1313
/**
1414
* {@inheritdoc}
1515
*/

pkg/gearman/Tests/Spec/GearmanMessageTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
namespace Enqueue\Gearman\Tests\Spec;
44

55
use Enqueue\Gearman\GearmanMessage;
6+
use Enqueue\Gearman\Tests\SkipIfGearmanExtensionIsNotInstalledTrait;
67
use Enqueue\Psr\Spec\PsrMessageSpec;
78

8-
/**
9-
* @group functional
10-
*/
119
class GearmanMessageTest extends PsrMessageSpec
1210
{
11+
use SkipIfGearmanExtensionIsNotInstalledTrait;
12+
1313
/**
1414
* {@inheritdoc}
1515
*/

pkg/gearman/Tests/Spec/GearmanQueueTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
namespace Enqueue\Gearman\Tests\Spec;
44

55
use Enqueue\Gearman\GearmanDestination;
6+
use Enqueue\Gearman\Tests\SkipIfGearmanExtensionIsNotInstalledTrait;
67
use Enqueue\Psr\Spec\PsrQueueSpec;
78

8-
/**
9-
* @group functional
10-
*/
119
class GearmanQueueTest extends PsrQueueSpec
1210
{
11+
use SkipIfGearmanExtensionIsNotInstalledTrait;
12+
1313
/**
1414
* {@inheritdoc}
1515
*/

pkg/gearman/Tests/Spec/GearmanTopicTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
namespace Enqueue\Gearman\Tests\Spec;
44

55
use Enqueue\Gearman\GearmanDestination;
6+
use Enqueue\Gearman\Tests\SkipIfGearmanExtensionIsNotInstalledTrait;
67
use Enqueue\Psr\Spec\PsrTopicSpec;
78

8-
/**
9-
* @group functional
10-
*/
119
class GearmanTopicTest extends PsrTopicSpec
1210
{
11+
use SkipIfGearmanExtensionIsNotInstalledTrait;
12+
1313
/**
1414
* {@inheritdoc}
1515
*/

0 commit comments

Comments
 (0)