Skip to content

Commit b8f86e1

Browse files
committed
Removes mocks in favor of required api_key for integration tests.
1 parent 214cb44 commit b8f86e1

File tree

3 files changed

+10
-27
lines changed

3 files changed

+10
-27
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language: php
2+
23
php:
34
- '7.0'
45
- '7.1'
@@ -7,3 +8,6 @@ php:
78
before_script:
89
- composer self-update
910
- composer install --dev
11+
12+
script:
13+
- phpunit -d api_key=$API_KEY

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@ To run the test suite, run the following commands from the root directory:
2727

2828
```
2929
composer install
30-
vendor/bin/phpunit
30+
vendor/bin/phpunit -d api_key=YOUR_SMMRY_API_KEY
3131
```
32+
33+
> **Note:** A valid Smmry API key is required when running the integration tests.

tests/Integration/SDKTest.php

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44

55
use DayRev\Smmry\SDK;
66
use Mockery;
7-
use ReflectionProperty;
87
use stdClass;
98

109
class SDKTest extends TestCase
1110
{
1211
protected $sdk;
13-
protected $mock = true;
1412

1513
public function setUp()
1614
{
@@ -19,14 +17,6 @@ public function setUp()
1917

2018
public function testSummarizesExpectedText()
2119
{
22-
if ($this->mock) {
23-
$requester = Mockery::mock('Curl')
24-
->shouldReceive('post')
25-
->andReturn($this->getExpectedTextSummary())
26-
->getMock();
27-
$this->setProtectedSDKProperty($this->sdk, 'requester', $requester);
28-
}
29-
3020
$response = $this->sdk->summarizeText($this->getTextToSummarize());
3121

3222
$this->assertInstanceOf('stdClass', $response);
@@ -36,28 +26,15 @@ public function testSummarizesExpectedText()
3626

3727
public function testSummarizesExpectedUrlText()
3828
{
39-
if ($this->mock) {
40-
$requester = Mockery::mock('Curl')
41-
->shouldReceive('get')
42-
->andReturn($this->getExpectedUrlTextSummary())
43-
->getMock();
44-
$this->setProtectedSDKProperty($this->sdk, 'requester', $requester);
45-
}
46-
47-
$response = $this->sdk->summarizeUrl('http://collegefootball.ap.org/article/mayfield-leads-oklahoma-35-19-sugar-bowl-win-over-auburn');
29+
$response = $this->sdk->summarizeUrl(
30+
'http://collegefootball.ap.org/article/mayfield-leads-oklahoma-35-19-sugar-bowl-win-over-auburn'
31+
);
4832

4933
$this->assertInstanceOf('stdClass', $response);
5034
$this->assertObjectHasAttribute('sm_api_content', $response);
5135
$this->assertEquals($this->getExpectedUrlTextSummary()->sm_api_content, $response->sm_api_content);
5236
}
5337

54-
protected function setProtectedSDKProperty(SDK $sdk, string $property, $value)
55-
{
56-
$reflected_property = new ReflectionProperty(get_class($sdk), $property);
57-
$reflected_property->setAccessible(true);
58-
$reflected_property->setValue($sdk, $value);
59-
}
60-
6138
protected function getExpectedSummary(string $text): stdClass
6239
{
6340
$summary = new stdClass();

0 commit comments

Comments
 (0)