Skip to content

Commit

Permalink
add getCost() to Number
Browse files Browse the repository at this point in the history
  • Loading branch information
arubacao authored and mheap committed Jan 7, 2018
1 parent 5a8229f commit 7c00032
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Numbers/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public function getType()
return $this->fromData('type');
}

public function getCost()
{
return $this->fromData('cost');
}

public function hasFeature($feature)
{
if(!isset($this->data['features'])){
Expand Down
19 changes: 19 additions & 0 deletions test/Numbers/NumberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@ public function testHydrate()
$this->assertCount(2, $this->number->getFeatures());
}

public function testAvailableNumbers()
{
$data = json_decode(file_get_contents(__DIR__ . '/responses/available-numbers.json'), true);
$this->number->jsonUnserialize($data['numbers'][0]);

$this->assertEquals('US', $this->number->getCountry());
$this->assertEquals('14155550100', $this->number->getNumber());
$this->assertEquals(Number::TYPE_MOBILE, $this->number->getType());
$this->assertEquals('0.67', $this->number->getCost());

$this->assertTrue($this->number->hasFeature(Number::FEATURE_VOICE));
$this->assertTrue($this->number->hasFeature(Number::FEATURE_SMS));

$this->assertTrue(in_array(Number::FEATURE_VOICE, $this->number->getFeatures()));
$this->assertTrue(in_array(Number::FEATURE_SMS, $this->number->getFeatures()));

$this->assertCount(2, $this->number->getFeatures());
}

public function testVoiceApplication()
{
$id = 'abcd-1234-edfg';
Expand Down

0 comments on commit 7c00032

Please sign in to comment.