Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5ba3714

Browse files
committed
Merge pull request giorgiosironi#336 from zerkms/windows-selenium-id-filename
Windows `PHPUNIT_SELENIUM_TEST_ID` cookie filename fix
2 parents 06d974c + 187672e commit 5ba3714

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

PHPUnit/Extensions/SeleniumCommon/append.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
$file = $_SERVER['SCRIPT_FILENAME'];
6363
}
6464

65-
file_put_contents(
66-
$name = $file . '.' . md5(uniqid(rand(), TRUE)) . '.' . $_COOKIE['PHPUNIT_SELENIUM_TEST_ID'],
67-
serialize($data)
68-
);
65+
$sanitizedCookieName = str_replace(array('\\'), '_', $_COOKIE['PHPUNIT_SELENIUM_TEST_ID']);
66+
$fullPath = $file . '.' . md5(uniqid(rand(), TRUE)) . '.' . $sanitizedCookieName;
67+
68+
file_put_contents($fullPath, serialize($data));
6969
}

PHPUnit/Extensions/SeleniumCommon/phpunit_coverage.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@
5959

6060
if (isset($_GET['PHPUNIT_SELENIUM_TEST_ID'])) {
6161
$facade = new File_Iterator_Facade;
62+
$sanitizedCookieName = str_replace(array('\\'), '_', $_GET['PHPUNIT_SELENIUM_TEST_ID']);
6263
$files = $facade->getFilesAsArray(
6364
$GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'],
64-
$_GET['PHPUNIT_SELENIUM_TEST_ID']
65+
$sanitizedCookieName
6566
);
6667

6768
$coverage = array();

Tests/Selenium2TestCase/Coverage/SingleFileTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class Tests_Selenium2TestCase_Coverage_SingleFileTest extends PHPUnit_Framework_TestCase
33
{
4-
private $dummyTestId = 'dummyTestId';
4+
private $dummyTestId = 'ns_dummyTestId';
55

66
public function setUp()
77
{

Tests/Selenium2TestCase/Coverage/singleFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
$_COOKIE['PHPUNIT_SELENIUM_TEST_ID'] = 'dummyTestId';
2+
$_COOKIE['PHPUNIT_SELENIUM_TEST_ID'] = 'ns\\dummyTestId';
33
require __DIR__ . '/../../../PHPUnit/Extensions/SeleniumCommon/prepend.php';
44

55
require_once 'DummyClass.php';

0 commit comments

Comments
 (0)