Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #47 from punktDe/FIX-Functional-Tests
Browse files Browse the repository at this point in the history
BUGFIX: Functional Tests
  • Loading branch information
ursulaklinger authored Feb 18, 2018
2 parents aa898a5 + 391d38d commit 41558b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
22 changes: 10 additions & 12 deletions Tests/Functional/Utility/Lock/MySqlLockTestSecondInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,11 @@ class MySqlLockTestSecondInstance
protected $mySQLConnection;


public function __construct()
{
$this->connect();
}

protected function connect()
protected function connect($context)
{

// Load system specific configuration for Apache mode
$dpppConfiguration = __DIR__ . '/../../../../../../configurations/' . GeneralUtility::getApplicationContext() . '/AdditionalConfiguration.php';
$dpppConfiguration = __DIR__ . '/../../../../../../configurations/' . $context . '/AdditionalConfiguration.php';

if (file_exists($dpppConfiguration)) {
@include($dpppConfiguration);
Expand All @@ -61,13 +56,16 @@ protected function connect()

public function test()
{
if (!isset($_SERVER['argv']['1']) || !isset($_SERVER['argv']['2'])) {
throw new \Exception('You have to specify the lock identifier and the testType', 1428853716);
if (!isset($_SERVER['argv']['1']) || !isset($_SERVER['argv']['2']) || !isset($_SERVER['argv']['3'])) {
throw new \Exception('You have to specify the context, lock identifier and the testType', 1428853716);
}

$lockIdentifier = $_SERVER['argv']['1'];
$testType = $_SERVER['argv']['2'];
$timeout = $_SERVER['argv']['3'] ? $_SERVER['argv']['3'] : 0;
$context = $_SERVER['argv']['1'];
$lockIdentifier = $_SERVER['argv']['2'];
$testType = $_SERVER['argv']['3'];
$timeout = isset($_SERVER['argv']['4']) ? $_SERVER['argv']['4'] : 0;

$this->connect($context);

switch ($testType) {
case 'acquireExclusiveLock':
Expand Down
13 changes: 7 additions & 6 deletions Tests/Functional/Utility/Lock/MysqlLockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
***************************************************************/

use PunktDe\PtExtbase\Utility\Lock\Lock;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Wget Test Case
Expand All @@ -46,7 +47,7 @@ class MysqlLockTest extends \PunktDe\PtExtbase\Testing\Unit\AbstractBaseTestcase
*/
public function setUp()
{
$this->mysqlLock = $this->objectManager->get('PunktDe\\PtExtbase\\Utility\\Lock\\Lock', 'lockTest');
$this->mysqlLock = $this->objectManager->get(\PunktDe\PtExtbase\Utility\Lock\Lock::class, 'lockTest');
}

public function tearDown()
Expand All @@ -62,7 +63,7 @@ public function tearDown()
public function acquiringSharedLockThrowsException()
{
$this->mysqlLock->release();
$this->objectManager->get('PunktDe\\PtExtbase\\Utility\\Lock\\Lock', 'lockTest', 'PunktDe\\PtExtbase\\Utility\\Lock\\MySqlLockStrategy', false);
$this->objectManager->get(\PunktDe\PtExtbase\Utility\Lock\Lock::class, 'lockTest', \PunktDe\PtExtbase\Utility\Lock\MySqlLockStrategy::class , false);
}

/**
Expand All @@ -72,7 +73,7 @@ public function constructAcquiresLock()
{
$outputArray = [];
$returnValue = 0;
exec(__DIR__ . '/MySqlLockTestSecondInstance.php lockTest testIfLockIsFree', $outputArray, $returnValue);
exec(__DIR__ . '/MySqlLockTestSecondInstance.php ' . GeneralUtility::getApplicationContext() . ' lockTest testIfLockIsFree ', $outputArray, $returnValue);
$this->assertEquals(0, $returnValue);
}

Expand All @@ -87,7 +88,7 @@ public function afterReleaseLockIsFree()

$this->assertTrue($released);

exec(__DIR__ . '/MySqlLockTestSecondInstance.php lockTest testIfLockIsFree', $outputArray, $returnValue);
exec(__DIR__ . '/MySqlLockTestSecondInstance.php ' . GeneralUtility::getApplicationContext() . ' lockTest testIfLockIsFree', $outputArray, $returnValue);
$this->assertEquals(1, $returnValue);
}

Expand All @@ -98,7 +99,7 @@ public function acquiringLockASecondTimeIsNotPossible()
{
$outputArray = [];
$returnValue = 0;
exec(__DIR__ . '/MySqlLockTestSecondInstance.php lockTest acquireExclusiveLock', $outputArray, $returnValue);
exec(__DIR__ . '/MySqlLockTestSecondInstance.php ' . GeneralUtility::getApplicationContext() . ' lockTest acquireExclusiveLock', $outputArray, $returnValue);
$this->assertEquals(0, $returnValue);
}

Expand All @@ -110,7 +111,7 @@ public function freeingLockIsNotPossibleBySecondClient()
{
$outputArray = [];
$returnValue = 0;
exec(__DIR__ . '/MySqlLockTestSecondInstance.php lockTest freeLock', $outputArray, $returnValue);
exec(__DIR__ . '/MySqlLockTestSecondInstance.php ' . GeneralUtility::getApplicationContext() . ' lockTest freeLock', $outputArray, $returnValue);
$this->assertEquals(0, $returnValue);
}
}

0 comments on commit 41558b0

Please sign in to comment.