Skip to content

Commit 7c00032

Browse files
arubacaomheap
authored andcommitted
add getCost() to Number
1 parent 5a8229f commit 7c00032

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/Numbers/Number.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ public function getType()
7070
return $this->fromData('type');
7171
}
7272

73+
public function getCost()
74+
{
75+
return $this->fromData('cost');
76+
}
77+
7378
public function hasFeature($feature)
7479
{
7580
if(!isset($this->data['features'])){

test/Numbers/NumberTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,25 @@ public function testHydrate()
6363
$this->assertCount(2, $this->number->getFeatures());
6464
}
6565

66+
public function testAvailableNumbers()
67+
{
68+
$data = json_decode(file_get_contents(__DIR__ . '/responses/available-numbers.json'), true);
69+
$this->number->jsonUnserialize($data['numbers'][0]);
70+
71+
$this->assertEquals('US', $this->number->getCountry());
72+
$this->assertEquals('14155550100', $this->number->getNumber());
73+
$this->assertEquals(Number::TYPE_MOBILE, $this->number->getType());
74+
$this->assertEquals('0.67', $this->number->getCost());
75+
76+
$this->assertTrue($this->number->hasFeature(Number::FEATURE_VOICE));
77+
$this->assertTrue($this->number->hasFeature(Number::FEATURE_SMS));
78+
79+
$this->assertTrue(in_array(Number::FEATURE_VOICE, $this->number->getFeatures()));
80+
$this->assertTrue(in_array(Number::FEATURE_SMS, $this->number->getFeatures()));
81+
82+
$this->assertCount(2, $this->number->getFeatures());
83+
}
84+
6685
public function testVoiceApplication()
6786
{
6887
$id = 'abcd-1234-edfg';

0 commit comments

Comments
 (0)