Skip to content

Commit 1a080e8

Browse files
authored
Merge pull request #443 from pajon/refactor-namespaces
Refactor class namespaces (Change from PSR0 to PSR4)
2 parents 01025d0 + 289fdcf commit 1a080e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+649
-384
lines changed

.ci/common_env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
SELENIUM_HUB_URL='http://127.0.0.1:4444'
44
SELENIUM_JAR=/usr/share/selenium/selenium-server-standalone.jar
55
SELENIUM_DOWNLOAD_URL=https://selenium-release.storage.googleapis.com/3.4/selenium-server-standalone-3.4.0.jar
6-
GECKODRIVER_DOWNLOAD_URL=https://github.com/mozilla/geckodriver/releases/download/v0.17.0/geckodriver-v0.17.0-linux64.tar.gz
6+
GECKODRIVER_DOWNLOAD_URL=https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz
77
GECKODRIVER_TAR=/tmp/geckodriver.tar.gz
88
PHP_VERSION=$(php -v)

.ci/setup.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/bin/bash
22

3-
if [ ! -f "/usr/local/bin/composer" ]; then
3+
sudo apt-get update
4+
5+
if [ ! -x "$(command -v composer)" ]; then
46
echo "Installing Composer"
57
php -r "readfile('https://getcomposer.org/installer');" | sudo php -d apc.enable_cli=0 -- --install-dir=/usr/local/bin --filename=composer
68
else
79
echo "Updating Composer"
8-
sudo /usr/local/bin/composer self-update
10+
sudo composer self-update
911
fi
1012

1113
echo "Installing dependencies"

.ci/vagrant_pre_setup.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
#!/bin/sh
22

3-
sed -i "/mirror:\\/\\//d" /etc/apt/sources.list
4-
sed -i "1ideb mirror://mirrors.ubuntu.com/mirrors.txt precise main restricted universe multiverse" /etc/apt/sources.list
5-
sed -i "1ideb mirror://mirrors.ubuntu.com/mirrors.txt precise-updates main restricted universe multiverse" /etc/apt/sources.list
6-
sed -i "1ideb mirror://mirrors.ubuntu.com/mirrors.txt precise-backports main restricted universe multiverse" /etc/apt/sources.list
7-
sed -i "1ideb mirror://mirrors.ubuntu.com/mirrors.txt precise-security main restricted universe multiverse" /etc/apt/sources.list
3+
apt-add-repository ppa:ondrej/php -y
84

95
apt-get update
106

117
apt-get install software-properties-common -y
128
apt-get install python-software-properties -y
139

14-
apt-add-repository ppa:ondrej/php -y
15-
16-
apt-get update
17-
1810
# installing xvfb, java and php
19-
apt-get install xvfb php5.6-cli php5.6-curl php5.6-xml php5.6-mbstring php-xdebug ncurses-term unzip xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic vim -y --no-install-recommends
11+
apt-get install xvfb php7.2-cli php7.2-curl php7.2-xml php7.2-mbstring php-xdebug ncurses-term unzip xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic vim -y --no-install-recommends
2012

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
language: php
2-
dist: trusty
2+
dist: xenial
33
php:
4-
- 7
5-
- 7.1
4+
- 7.2
5+
- 7.3
6+
- 7.4
67

78
matrix:
89
allow_failures:

PHPUnit/Extensions/Selenium2TestCase.php

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,30 @@
4141
* @link http://www.phpunit.de/
4242
* @since File available since Release 1.2.0
4343
*/
44+
45+
namespace PHPUnit\Extensions;
46+
47+
use Exception;
48+
use InvalidArgumentException;
49+
use PHPUnit\Extensions\Selenium2TestCase\Element;
50+
use PHPUnit\Extensions\Selenium2TestCase\Element\Select;
51+
use PHPUnit\Extensions\Selenium2TestCase\ElementCriteria;
52+
use PHPUnit\Extensions\Selenium2TestCase\KeysHolder;
53+
use PHPUnit\Extensions\Selenium2TestCase\NoSeleniumException;
54+
use PHPUnit\Extensions\Selenium2TestCase\Session;
55+
use PHPUnit\Extensions\Selenium2TestCase\Session\Timeouts;
56+
use PHPUnit\Extensions\Selenium2TestCase\SessionStrategy;
57+
use PHPUnit\Extensions\Selenium2TestCase\SessionStrategy\Isolated;
58+
use PHPUnit\Extensions\Selenium2TestCase\SessionStrategy\Shared;
59+
use PHPUnit\Extensions\Selenium2TestCase\URL;
60+
use PHPUnit\Extensions\Selenium2TestCase\WaitUntil;
61+
use PHPUnit\Extensions\Selenium2TestCase\Window;
62+
use PHPUnit\Extensions\SeleniumCommon\RemoteCoverage;
4463
use PHPUnit\Framework\TestCase;
4564
use PHPUnit\Framework\TestResult;
4665
use PHPUnit\Util\InvalidArgumentHelper;
66+
use RuntimeException;
67+
use Throwable;
4768

4869
/**
4970
* TestCase class that uses Selenium 2
@@ -60,33 +81,33 @@
6081
* @method void acceptAlert() Press OK on an alert, or confirms a dialog
6182
* @method mixed alertText() alertText($value = NULL) Gets the alert dialog text, or sets the text for a prompt dialog
6283
* @method void back()
63-
* @method \PHPUnit_Extensions_Selenium2TestCase_Element byClassName() byClassName($value)
64-
* @method \PHPUnit_Extensions_Selenium2TestCase_Element byCssSelector() byCssSelector($value)
65-
* @method \PHPUnit_Extensions_Selenium2TestCase_Element byId() byId($value)
66-
* @method \PHPUnit_Extensions_Selenium2TestCase_Element byLinkText() byLinkText($value)
67-
* @method \PHPUnit_Extensions_Selenium2TestCase_Element byPartialLinkText() byPartialLinkText($value)
68-
* @method \PHPUnit_Extensions_Selenium2TestCase_Element byName() byName($value)
69-
* @method \PHPUnit_Extensions_Selenium2TestCase_Element byTag() byTag($value)
70-
* @method \PHPUnit_Extensions_Selenium2TestCase_Element byXPath() byXPath($value)
84+
* @method Element byClassName() byClassName($value)
85+
* @method Element byCssSelector() byCssSelector($value)
86+
* @method Element byId() byId($value)
87+
* @method Element byLinkText() byLinkText($value)
88+
* @method Element byPartialLinkText() byPartialLinkText($value)
89+
* @method Element byName() byName($value)
90+
* @method Element byTag() byTag($value)
91+
* @method Element byXPath() byXPath($value)
7192
* @method void click() click(int $button = 0) Click any mouse button (at the coordinates set by the last moveto command).
7293
* @method void clickOnElement() clickOnElement($id)
7394
* @method string currentScreenshot() BLOB of the image file
7495
* @method void dismissAlert() Press Cancel on an alert, or does not confirm a dialog
7596
* @method void doubleclick() Double clicks (at the coordinates set by the last moveto command).
76-
* @method \PHPUnit_Extensions_Selenium2TestCase_Element element() element(\PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $criteria) Retrieves an element
77-
* @method array elements() elements(\PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $criteria) Retrieves an array of Element instances
97+
* @method Element element() element(ElementCriteria $criteria) Retrieves an element
98+
* @method array elements() elements(ElementCriteria $criteria) Retrieves an array of Element instances
7899
* @method string execute() execute($javaScriptCode) Injects arbitrary JavaScript in the page and returns the last
79100
* @method string executeAsync() executeAsync($javaScriptCode) Injects arbitrary JavaScript and wait for the callback (last element of arguments) to be called
80101
* @method void forward()
81-
* @method void frame() frame(mixed $element) Changes the focus to a frame in the page (by frameCount of type int, htmlId of type string, htmlName of type string or element of type \PHPUnit_Extensions_Selenium2TestCase_Element)
82-
* @method void moveto() moveto(\PHPUnit_Extensions_Selenium2TestCase_Element $element) Move the mouse by an offset of the specificed element.
102+
* @method void frame() frame(mixed $element) Changes the focus to a frame in the page (by frameCount of type int, htmlId of type string, htmlName of type string or element of type Element)
103+
* @method void moveto() moveto(Element $element) Move the mouse by an offset of the specificed element.
83104
* @method void refresh()
84-
* @method \PHPUnit_Extensions_Selenium2TestCase_Element_Select select() select($element)
105+
* @method Select select() select($element)
85106
* @method string source() Returns the HTML source of the page
86-
* @method \PHPUnit_Extensions_Selenium2TestCase_Session_Timeouts timeouts()
107+
* @method Timeouts timeouts()
87108
* @method string title()
88109
* @method void|string url() url($url = NULL)
89-
* @method PHPUnit_Extensions_Selenium2TestCase_ElementCriteria using() using($strategy) Factory Method for Criteria objects
110+
* @method ElementCriteria using() using($strategy) Factory Method for Criteria objects
90111
* @method void window() window($name) Changes the focus to another window
91112
* @method string windowHandle() Retrieves the current window handle
92113
* @method string windowHandles() Retrieves a list of all available window handles
@@ -96,10 +117,10 @@
96117
* @method array logTypes() Get available log types.
97118
* @method void closeWindow() Close the current window.
98119
* @method void stop() Close the current window and clear session data.
99-
* @method \PHPUnit_Extensions_Selenium2TestCase_Element active() Get the element on the page that currently has focus.
100-
* @method \PHPUnit_Extensions_Selenium2TestCase_Window currentWindow() get the current Window Object
120+
* @method Element active() Get the element on the page that currently has focus.
121+
* @method Window currentWindow() get the current Window Object
101122
*/
102-
abstract class PHPUnit_Extensions_Selenium2TestCase extends TestCase
123+
abstract class Selenium2TestCase extends TestCase
103124
{
104125
const VERSION = '7.0.1';
105126

@@ -109,7 +130,7 @@ abstract class PHPUnit_Extensions_Selenium2TestCase extends TestCase
109130
protected $coverageScriptUrl;
110131

111132
/**
112-
* @var PHPUnit_Extensions_Selenium2TestCase_Session
133+
* @var Session
113134
*/
114135
private $session;
115136

@@ -119,12 +140,12 @@ abstract class PHPUnit_Extensions_Selenium2TestCase extends TestCase
119140
private $parameters;
120141

121142
/**
122-
* @var PHPUnit_Extensions_Selenium2TestCase_SessionStrategy
143+
* @var SessionStrategy
123144
*/
124145
protected static $sessionStrategy;
125146

126147
/**
127-
* @var PHPUnit_Extensions_Selenium2TestCase_SessionStrategy
148+
* @var SessionStrategy
128149
*/
129150
protected static $browserSessionStrategy;
130151

@@ -143,7 +164,7 @@ abstract class PHPUnit_Extensions_Selenium2TestCase extends TestCase
143164
private static $defaultWaitUntilSleepInterval = 500;
144165

145166
/**
146-
* @var PHPUnit_Extensions_Selenium2TestCase_SessionStrategy
167+
* @var SessionStrategy
147168
*/
148169
protected $localSessionStrategy;
149170

@@ -163,7 +184,7 @@ abstract class PHPUnit_Extensions_Selenium2TestCase extends TestCase
163184
private $collectCodeCoverageInformation;
164185

165186
/**
166-
* @var PHPUnit_Extensions_Selenium2TestCase_KeysHolder
187+
* @var KeysHolder
167188
*/
168189
private $keysHolder;
169190

@@ -183,7 +204,7 @@ public static function shareSession($shareSession)
183204
if (!$shareSession) {
184205
self::$sessionStrategy = self::defaultSessionStrategy();
185206
} else {
186-
self::$sessionStrategy = new PHPUnit_Extensions_Selenium2TestCase_SessionStrategy_Shared(
207+
self::$sessionStrategy = new Shared(
187208
self::defaultSessionStrategy(), self::$keepSessionOnFailure
188209
);
189210
}
@@ -209,7 +230,7 @@ private static function sessionStrategy()
209230

210231
private static function defaultSessionStrategy()
211232
{
212-
return new PHPUnit_Extensions_Selenium2TestCase_SessionStrategy_Isolated;
233+
return new Isolated;
213234
}
214235

215236
/**
@@ -260,7 +281,7 @@ public function __construct($name = NULL, array $data = array(), $dataName = '')
260281
'secure' => FALSE
261282
);
262283

263-
$this->keysHolder = new PHPUnit_Extensions_Selenium2TestCase_KeysHolder();
284+
$this->keysHolder = new KeysHolder();
264285
}
265286

266287
public function setupSpecificBrowser($params)
@@ -293,9 +314,9 @@ protected function setUpSessionStrategy($params)
293314
if ($strat != "isolated" && $strat != "shared") {
294315
throw new InvalidArgumentException("Session strategy must be either 'isolated' or 'shared'");
295316
} elseif ($strat == "isolated") {
296-
self::$browserSessionStrategy = new PHPUnit_Extensions_Selenium2TestCase_SessionStrategy_Isolated;
317+
self::$browserSessionStrategy = new Isolated;
297318
} else {
298-
self::$browserSessionStrategy = new PHPUnit_Extensions_Selenium2TestCase_SessionStrategy_Shared(self::defaultSessionStrategy(), self::$keepSessionOnFailure);
319+
self::$browserSessionStrategy = new Shared(self::defaultSessionStrategy(), self::$keepSessionOnFailure);
299320
}
300321
} else {
301322
self::$browserSessionStrategy = self::defaultSessionStrategy();
@@ -320,7 +341,7 @@ public function prepareSession()
320341
if (!$this->session) {
321342
$this->session = $this->getStrategy()->session($this->parameters);
322343
}
323-
} catch (PHPUnit_Extensions_Selenium2TestCase_NoSeleniumException $e) {
344+
} catch (NoSeleniumException $e) {
324345
$this->markTestSkipped("The Selenium Server is not active on host {$this->parameters['host']} at port {$this->parameters['port']}.");
325346
}
326347
return $this->session;
@@ -339,7 +360,7 @@ public function run(TestResult $result = NULL): TestResult
339360
parent::run($result);
340361

341362
if ($this->collectCodeCoverageInformation) {
342-
$coverage = new PHPUnit_Extensions_SeleniumCommon_RemoteCoverage(
363+
$coverage = new RemoteCoverage(
343364
$this->coverageScriptUrl,
344365
$this->testId
345366
);
@@ -394,7 +415,7 @@ protected function runTest()
394415

395416
public static function suite($className)
396417
{
397-
return PHPUnit_Extensions_SeleniumTestSuite::fromTestCaseClass($className);
418+
return SeleniumTestSuite::fromTestCaseClass($className);
398419
}
399420

400421
public function onNotSuccessfulTest(Throwable $e): void
@@ -413,7 +434,7 @@ public function onNotSuccessfulTest(Throwable $e): void
413434
public function __call($command, $arguments)
414435
{
415436
if ($this->session === NULL) {
416-
throw new PHPUnit_Extensions_Selenium2TestCase_Exception("There is currently no active session to execute the '$command' command. You're probably trying to set some option in setUp() with an incorrect setter name. You may consider using setUpPage() instead.");
437+
throw new \PHPUnit\Extensions\Selenium2TestCase\Exception("There is currently no active session to execute the '$command' command. You're probably trying to set some option in setUp() with an incorrect setter name. You may consider using setUpPage() instead.");
417438
}
418439
$result = call_user_func_array(
419440
array($this->session, $command), $arguments
@@ -504,7 +525,7 @@ public function setBrowserUrl($browserUrl)
504525
throw InvalidArgumentHelper::factory(1, 'string');
505526
}
506527

507-
$this->parameters['browserUrl'] = new PHPUnit_Extensions_Selenium2TestCase_URL($browserUrl);
528+
$this->parameters['browserUrl'] = new URL($browserUrl);
508529
}
509530

510531
public function getBrowserUrl()
@@ -572,7 +593,7 @@ public function getSessionId()
572593
*/
573594
public function waitUntil($callback, $timeout = NULL)
574595
{
575-
$waitUntil = new PHPUnit_Extensions_Selenium2TestCase_WaitUntil($this);
596+
$waitUntil = new WaitUntil($this);
576597
return $waitUntil->run($callback, $timeout);
577598
}
578599

@@ -581,8 +602,8 @@ public function waitUntil($callback, $timeout = NULL)
581602
* Deprecated due to issues with IE webdriver. Use keys() method instead
582603
* @deprecated
583604
* @param string $name
584-
* @throws PHPUnit_Extensions_Selenium2TestCase_Exception
585-
* @see PHPUnit_Extensions_Selenium2TestCase_KeysHolder
605+
* @throws \PHPUnit\Extensions\Selenium2TestCase\Exception
606+
* @see KeysHolder
586607
*/
587608
public function keysSpecial($name)
588609
{

PHPUnit/Extensions/Selenium2TestCase/Command.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
* @since File available since Release 1.2.0
4343
*/
4444

45+
namespace PHPUnit\Extensions\Selenium2TestCase;
46+
47+
use InvalidArgumentException;
48+
4549
/**
4650
* Base class for implementing commands with special semantics.
4751
*
@@ -53,16 +57,15 @@
5357
* @link http://www.phpunit.de/
5458
* @since Class available since Release 1.2.0
5559
*/
56-
abstract class PHPUnit_Extensions_Selenium2TestCase_Command
60+
abstract class Command
5761
{
5862
protected $jsonParameters;
5963
private $commandName;
6064

6165
/**
6266
* @param array $jsonParameters null in case of no parameters
6367
*/
64-
public function __construct($jsonParameters,
65-
PHPUnit_Extensions_Selenium2TestCase_URL $url)
68+
public function __construct($jsonParameters, URL $url)
6669
{
6770
if (!is_array($jsonParameters) && $jsonParameters !== NULL) {
6871
throw new InvalidArgumentException("The JSON parameters must be an array, or a NULL value in case they are not required.");

PHPUnit/Extensions/Selenium2TestCase/CommandsHolder.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242
* @since File available since Release 1.2.4
4343
*/
4444

45+
namespace PHPUnit\Extensions\Selenium2TestCase;
46+
47+
use BadMethodCallException;
48+
use Exception;
49+
use InvalidArgumentException;
50+
4551
/**
4652
* Object representing elements, or everything that may have subcommands.
4753
*
@@ -53,10 +59,10 @@
5359
* @link http://www.phpunit.de/
5460
* @since Class available since Release 1.2.4
5561
*/
56-
abstract class PHPUnit_Extensions_Selenium2TestCase_CommandsHolder
62+
abstract class CommandsHolder
5763
{
5864
/**
59-
* @var PHPUnit_Extensions_Selenium2TestCase_Driver
65+
* @var Driver
6066
*/
6167
protected $driver;
6268

@@ -71,8 +77,7 @@ abstract class PHPUnit_Extensions_Selenium2TestCase_CommandsHolder
7177
*/
7278
protected $commands;
7379

74-
public function __construct($driver,
75-
PHPUnit_Extensions_Selenium2TestCase_URL $url)
80+
public function __construct($driver, URL $url)
7681
{
7782
$this->driver = $driver;
7883
$this->url = $url;
@@ -101,7 +106,7 @@ public function __call($commandName, $arguments)
101106
return $response->getValue();
102107
}
103108

104-
protected function postCommand($name, PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $criteria)
109+
protected function postCommand($name, ElementCriteria $criteria)
105110
{
106111
$response = $this->driver->curl('POST',
107112
$this->url->addCommand($name),
@@ -110,8 +115,7 @@ protected function postCommand($name, PHPUnit_Extensions_Selenium2TestCase_Eleme
110115
}
111116

112117
/**
113-
* @params string $commandClass a class name, descending from
114-
PHPUnit_Extensions_Selenium2TestCase_Command
118+
* @params string $commandClass a class name, descending from Command
115119
* @return callable
116120
*/
117121
private function factoryMethod($commandClass)
@@ -142,7 +146,7 @@ private function checkArguments($arguments)
142146
* @param string $commandName The called method name
143147
* defined as a key in initCommands()
144148
* @param array $jsonParameters
145-
* @return PHPUnit_Extensions_Selenium2TestCase_Command
149+
* @return Command
146150
*/
147151
protected function newCommand($commandName, $jsonParameters)
148152
{

0 commit comments

Comments
 (0)