diff --git a/src/Numbers/Number.php b/src/Numbers/Number.php index ffdc4559..c408d664 100644 --- a/src/Numbers/Number.php +++ b/src/Numbers/Number.php @@ -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'])){ diff --git a/test/Numbers/NumberTest.php b/test/Numbers/NumberTest.php index 4f3bf270..78363b49 100644 --- a/test/Numbers/NumberTest.php +++ b/test/Numbers/NumberTest.php @@ -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';