Skip to content

Commit f63b5e3

Browse files
committed
First functional test for ping.
1 parent f15ac57 commit f63b5e3

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace org\nameapi\client\services;
4+
5+
6+
spl_autoload_register();
7+
8+
require_once(__DIR__.'/../../../../../../src/org/nameapi/client/services/ServiceFactory.php');
9+
10+
use org\nameapi\ontology\input\context\Context;
11+
use org\nameapi\ontology\input\context\Priority;
12+
use org\nameapi\ontology\input\context\TextCase;
13+
14+
15+
abstract class BaseServiceTest extends \PHPUnit_Framework_TestCase {
16+
17+
private $apiKey = null;
18+
19+
/**
20+
* @return Context
21+
*/
22+
protected function makeContext() {
23+
if (!$this->apiKey) {
24+
die("Put your api key in the \$apiKey variable to run these functional tests!");
25+
}
26+
return Context::builder()
27+
->apiKey($this->apiKey)
28+
->priority(Priority::REALTIME)
29+
->textCase(TextCase::TITLE_CASE)
30+
->build();
31+
}
32+
33+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace org\nameapi\client\services\system\ping;
4+
5+
require_once(__DIR__.'/../../BaseServiceTest.php');
6+
7+
use org\nameapi\client\services\BaseServiceTest;
8+
use org\nameapi\client\services\ServiceFactory;
9+
10+
class PingerServiceTest extends BaseServiceTest {
11+
12+
public function testPing() {
13+
$serviceFactory = new ServiceFactory($this->makeContext());
14+
$pinger = $serviceFactory->systemServices()->pingerService();
15+
$pong = $pinger->ping();
16+
$this->assertEquals($pong, 'pong');
17+
}
18+
19+
}

0 commit comments

Comments
 (0)