Skip to content

Commit

Permalink
[gearman] fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
makasim committed Jun 27, 2017
1 parent c74f774 commit 27ee35e
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 30 deletions.
17 changes: 8 additions & 9 deletions Tests/GearmanConnectionFactoryConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@

/**
* The class contains the factory tests dedicated to configuration.
*
* @group functional
*/
class GearmanConnectionFactoryConfigTest extends TestCase
{
use ClassExtensionTrait;
use SkipIfGearmanExtensionIsNotInstalledTrait;

public function testThrowNeitherArrayStringNorNullGivenAsConfig()
{
Expand Down Expand Up @@ -57,24 +56,24 @@ public static function provideConfigs()
yield [
null,
[
'host' => \GEARMAN_DEFAULT_TCP_HOST,
'port' => \GEARMAN_DEFAULT_TCP_PORT,
'host' => 'localhost',
'port' => 4730,
],
];

yield [
'gearman://',
[
'host' => \GEARMAN_DEFAULT_TCP_HOST,
'port' => \GEARMAN_DEFAULT_TCP_PORT,
'host' => 'localhost',
'port' => 4730,
],
];

yield [
[],
[
'host' => \GEARMAN_DEFAULT_TCP_HOST,
'port' => \GEARMAN_DEFAULT_TCP_PORT,
'host' => 'localhost',
'port' => 4730,
],
];

Expand All @@ -98,7 +97,7 @@ public static function provideConfigs()
['host' => 'theHost'],
[
'host' => 'theHost',
'port' => \GEARMAN_DEFAULT_TCP_PORT,
'port' => 4730,
],
];
}
Expand Down
1 change: 1 addition & 0 deletions Tests/GearmanContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
class GearmanContextTest extends TestCase
{
use ClassExtensionTrait;
use SkipIfGearmanExtensionIsNotInstalledTrait;

public function testShouldImplementPsrContextInterface()
{
Expand Down
4 changes: 1 addition & 3 deletions Tests/GearmanDestinationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
use Enqueue\Test\ClassExtensionTrait;
use PHPUnit\Framework\TestCase;

/**
* @group functional
*/
class GearmanDestinationTest extends TestCase
{
use ClassExtensionTrait;
use SkipIfGearmanExtensionIsNotInstalledTrait;

public function testShouldImplementPsrQueueInterface()
{
Expand Down
4 changes: 1 addition & 3 deletions Tests/GearmanMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
use Enqueue\Test\ClassExtensionTrait;
use PHPUnit\Framework\TestCase;

/**
* @group functional
*/
class GearmanMessageTest extends TestCase
{
use ClassExtensionTrait;
use SkipIfGearmanExtensionIsNotInstalledTrait;

public function testShouldAllowGetJobPreviouslySet()
{
Expand Down
4 changes: 1 addition & 3 deletions Tests/GearmanProducerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
use Enqueue\Test\ClassExtensionTrait;
use PHPUnit\Framework\TestCase;

/**
* @group functional
*/
class GearmanProducerTest extends TestCase
{
use ClassExtensionTrait;
use SkipIfGearmanExtensionIsNotInstalledTrait;

public function testCouldBeConstructedWithGearmanClientAsFirstArgument()
{
Expand Down
15 changes: 15 additions & 0 deletions Tests/SkipIfGearmanExtensionIsNotInstalledTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Enqueue\Gearman\Tests;

trait SkipIfGearmanExtensionIsNotInstalledTrait
{
public function setUp()
{
if (false == class_exists(\GearmanClient::class)) {
$this->markTestSkipped('The gearman extension is not installed');
}

parent::setUp();
}
}
6 changes: 3 additions & 3 deletions Tests/Spec/GearmanConnectionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace Enqueue\Gearman\Tests\Spec;

use Enqueue\Gearman\GearmanConnectionFactory;
use Enqueue\Gearman\Tests\SkipIfGearmanExtensionIsNotInstalledTrait;
use Enqueue\Psr\Spec\PsrConnectionFactorySpec;

/**
* @group functional
*/
class GearmanConnectionFactoryTest extends PsrConnectionFactorySpec
{
use SkipIfGearmanExtensionIsNotInstalledTrait;

/**
* {@inheritdoc}
*/
Expand Down
6 changes: 3 additions & 3 deletions Tests/Spec/GearmanMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace Enqueue\Gearman\Tests\Spec;

use Enqueue\Gearman\GearmanMessage;
use Enqueue\Gearman\Tests\SkipIfGearmanExtensionIsNotInstalledTrait;
use Enqueue\Psr\Spec\PsrMessageSpec;

/**
* @group functional
*/
class GearmanMessageTest extends PsrMessageSpec
{
use SkipIfGearmanExtensionIsNotInstalledTrait;

/**
* {@inheritdoc}
*/
Expand Down
6 changes: 3 additions & 3 deletions Tests/Spec/GearmanQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace Enqueue\Gearman\Tests\Spec;

use Enqueue\Gearman\GearmanDestination;
use Enqueue\Gearman\Tests\SkipIfGearmanExtensionIsNotInstalledTrait;
use Enqueue\Psr\Spec\PsrQueueSpec;

/**
* @group functional
*/
class GearmanQueueTest extends PsrQueueSpec
{
use SkipIfGearmanExtensionIsNotInstalledTrait;

/**
* {@inheritdoc}
*/
Expand Down
6 changes: 3 additions & 3 deletions Tests/Spec/GearmanTopicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace Enqueue\Gearman\Tests\Spec;

use Enqueue\Gearman\GearmanDestination;
use Enqueue\Gearman\Tests\SkipIfGearmanExtensionIsNotInstalledTrait;
use Enqueue\Psr\Spec\PsrTopicSpec;

/**
* @group functional
*/
class GearmanTopicTest extends PsrTopicSpec
{
use SkipIfGearmanExtensionIsNotInstalledTrait;

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 27ee35e

Please sign in to comment.