Skip to content

Commit e26f821

Browse files
committed
add: update tests to use phpunit
1 parent d2207e1 commit e26f821

File tree

15 files changed

+2094
-315
lines changed

15 files changed

+2094
-315
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
vendor
21
composer.phar
32
local.log
3+
vendor/
4+
bin/
5+
.DS_Store
6+
browserstack.err

README.md

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,57 @@
11
# php-selenium-browserstack
2-
Code samples for php selenium tests on browserstack.
3-
4-
## Prerequisites
5-
1. `php` and `composer` should be installed in your system.
6-
* If you don't already use Composer, you can download the composer.phar binary:
7-
```
8-
curl -sS https://getcomposer.org/installer | php
9-
```
10-
11-
## Steps to run test sessions
12-
1. Clone the repo
13-
```
14-
git clone https://github.com/browserstack/php-selenium-browserstack.git
15-
```
16-
2. Install dependencies
17-
```
18-
php composer.phar install
19-
```
20-
3. Set your credentials in the `config.php` file. Update `YOUR_USERNAME` and `YOUR_ACCESS_KEY` with your username and access key.
21-
You can also set them as environment variables `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY`, as follows:
22-
* For Unix-like or Mac machines:
2+
3+
This branch contains php tests using [PHPUnit](https://github.com/sebastianbergmann/phpunit).
4+
5+
## Prerequisites
6+
7+
1. Make sure that you have **PHP** installed on your system. You can download and install **PHP** using following commands in the terminal:
8+
9+
- **MacOS:**
10+
```bash
11+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
12+
brew install php
13+
```
14+
- **Windows:**
15+
```bash
16+
sudo apt-get install curl libcurl3 libcurl3-dev php
17+
```
18+
**Note:** For **Windows**, you can download **PHP** from [here](http://windows.php.net/download/). Also, refer to this [documentation](http://php.net/manual/en/install.windows.php) for ensuring the accessibility of PHP through the Command Prompt.
19+
20+
2. Download **composer** in the project directory ([Linux/MacOS](https://getcomposer.org/download/), [Windows](https://getcomposer.org/doc/00-intro.md#installation-windows)).
21+
22+
**Note:** To use the **composer** command directly, it either should have been downloaded in the project directory or should be accessible globally which can be done by the command below:
23+
24+
```bash
25+
mv composer.phar /usr/local/bin/composer
26+
```
27+
28+
## Setup
29+
30+
- Clone the repo
31+
- Install dependencies using: `composer install`
32+
- Update `test.conf.json` file inside the `config/` directory with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
33+
34+
## Running your tests
35+
36+
- To run tests, run: `composer test`
37+
- To run local tests, run: `composer local`
38+
39+
Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)
40+
41+
## Notes
42+
43+
- You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate)
44+
- To test on a different set of browsers, check out our [platform configurator](https://www.browserstack.com/automate/php#setting-os-and-browser)
45+
- You can export the environment variables for the Username and Access Key of your BrowserStack account
46+
2347
```
2448
export BROWSERSTACK_USERNAME=<browserstack-username> &&
2549
export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
2650
```
2751
28-
* For Windows:
29-
```
30-
set BROWSERSTACK_USERNAME=<browserstack-username>
31-
set BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
32-
```
52+
## Additional Resources
3353
34-
## To run tests
35-
### Single test
36-
Run single test session by running.
37-
```
38-
php scripts/single.php
39-
```
40-
### Parallel test
41-
Run parallel test session by running.
42-
```
43-
php scripts/parallel.php
44-
```
45-
### Local test
46-
Run local test session by running.
47-
```
48-
php scripts/local.php
49-
```
54+
- [Documentation for writing Automate test scripts in PHP](https://www.browserstack.com/automate/php)
55+
- [Customizing your tests on BrowserStack](https://www.browserstack.com/automate/capabilities)
56+
- [Browsers & mobile devices for selenium testing on BrowserStack](https://www.browserstack.com/list-of-browsers-and-platforms?product=automate)
57+
- [Using REST API to access information about your tests via the command-line interface](https://www.browserstack.com/automate/rest-api)

composer.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
{
2-
"require": {
3-
"browserstack/browserstack-local": "^1.1",
4-
"php-webdriver/webdriver": "^1.12"
5-
}
2+
"require": {
3+
"browserstack/browserstack-local": "dev-master",
4+
"phpunit/phpunit-selenium": "9.0.1",
5+
"php-webdriver/webdriver": "1.14.0"
6+
},
7+
"scripts": {
8+
"local": "CONFIG_FILE=config/test.conf.json TEST_FILE=tests/LocalTest.php /usr/bin/env php lib/runner.php",
9+
"test": "CONFIG_FILE=config/test.conf.json TEST_FILE=tests/Test.php /usr/bin/env php lib/runner.php"
10+
},
11+
"autoload": {
12+
"classmap": ["lib/"]
13+
}
614
}

0 commit comments

Comments
 (0)