Skip to content

Commit af156db

Browse files
committed
Added test for Context and ContextBuilder.
1 parent b6b0505 commit af156db

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

src/org/nameapi/ontology/input/context/Context.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ static function builder() {
2424
* @param priority $priority
2525
* @param string $geo
2626
* @param TextCase $textCase
27-
* @param properties $properties
27+
* @param array $properties
2828
* @access public
2929
*/
3030
public function __construct($apiKey, $priority, $geo, $textCase, $properties) {
3131
$this->apiKey = $apiKey;
3232
$this->priority = $priority;
3333
$this->geo = $geo;
3434
$this->textCase = $textCase;
35-
$this->properties = $properties;
35+
$this->properties = isSet($properties) ? $properties : array();
3636
}
3737

3838

@@ -52,24 +52,24 @@ public function getGeo() {
5252
}
5353

5454
/**
55-
* @return null|\org\nameapi\Priority
55+
* @return null|Priority
5656
*/
5757
public function getPriority() {
5858
return $this->priority;
5959
}
6060

6161
/**
62-
* @return null|\org\nameapi\properties
62+
* @return null|TextCase
6363
*/
64-
public function getProperties() {
65-
return $this->properties;
64+
public function getTextCase() {
65+
return $this->textCase;
6666
}
6767

6868
/**
69-
* @return null|\org\nameapi\TextCase
69+
* @return null|array
7070
*/
71-
public function getTextCase() {
72-
return $this->textCase;
71+
public function getProperties() {
72+
return $this->properties;
7373
}
7474

7575
}

src/org/nameapi/ontology/input/context/ContextBuilder.php

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

55
class ContextBuilder {
66

7-
private $apiKey = null;
8-
private $priority = null;
9-
private $geo = null;
7+
private $apiKey = null;
8+
private $priority = null;
9+
private $geo = null;
1010
private $properties = null;
11-
private $textCase = null;
11+
private $textCase = null;
1212

1313

1414
/**
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace org\nameapi\ontology\input\context;
4+
5+
require_once(__DIR__.'/../../../../../../../src/org/nameapi/ontology/input/context/Context.php');
6+
7+
class ContextBuilderTest extends \PHPUnit_Framework_TestCase {
8+
9+
public function testOne() {
10+
$context = Context::builder()->apiKey('my-api-key')->geo('DE')->priority(Priority::REALTIME)->build();
11+
$this->assertEquals('my-api-key', $context->getApiKey());
12+
$this->assertEquals('DE', $context->getGeo());
13+
$this->assertEquals(Priority::REALTIME, $context->getPriority());
14+
$this->assertEquals(array(), $context->getProperties());
15+
}
16+
17+
}

0 commit comments

Comments
 (0)