Skip to content

Commit 392fe67

Browse files
committed
Adds support for providing cli params when running tests.
1 parent ec60e64 commit 392fe67

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ Extractor provides an elegant interface to extract content from a URL using a va
1313
$content = $extractor->extract($this->url);
1414

1515
## Tests
16-
To run the test suite, install [composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx) and then run the following commands from the root directory:
16+
To run the test suite, run the following commands from the root directory:
1717

1818
```
1919
composer install
20-
vendor/bin/phpunit
20+
vendor/bin/phpunit -d embedly_api_key=YOUR_EMBEDLY_API_KEY
2121
```
22+
23+
> **Note:** A valid Embedly API key is required when running the integration tests.

tests/Integration/TestCase.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,32 @@
44

55
class TestCase extends \PHPUnit_Framework_TestCase
66
{
7+
protected $config = [];
78

9+
public function __construct()
10+
{
11+
$this->parseParams();
12+
}
13+
14+
protected function parseParams()
15+
{
16+
$params = $_SERVER['argv'];
17+
foreach ($params as $index => $param) {
18+
if ($param != '-d') {
19+
continue;
20+
}
21+
22+
if (!$config = $params[$index + 1] ?? false) {
23+
continue;
24+
}
25+
26+
if (strpos($config, '=') === false) {
27+
continue;
28+
}
29+
30+
list($key, $value) = explode('=', $config);
31+
32+
$this->config[$key] = $value;
33+
}
34+
}
835
}

0 commit comments

Comments
 (0)