Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
shitoudev committed Dec 20, 2016
1 parent 493f0a4 commit a1951f0
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
install:
- composer self-update
- composer install --no-dev --quiet
script: phpunit -c phpunit.xml --coverage-text
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## 手机号码归属地查询
[![Build Status](https://travis-ci.org/shitoudev/phone-location.svg?branch=master&style=flat-square)](https://travis-ci.org/shitoudev/phone-location)

PHP 实现手机号码归属地查询,数据文件来自 [https://github.com/lovedboy/phone](https://github.com/lovedboy/phone)

### Installation
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@
"psr-4": {
"Shitoudev\\Phone\\": "src/"
}
},
"require-dev": {
"phpunit/phpunit": "^5.7"
}
}
19 changes: 19 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="Phone Location Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>

<php>
<ini name="date.timezone" value="UTC"/>
</php>
</phpunit>
36 changes: 36 additions & 0 deletions tests/PhoneTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

// require dirname(__DIR__) . '/src/PhoneLocation.php';
use Shitoudev\Phone\PhoneLocation;

/**
* Phone Test
*/
class PhoneTest extends PHPUnit_Framework_TestCase
{
protected $phone = null;

public function setUp()
{
$this->phone = new PhoneLocation();
}

public function testFileHandle()
{
$this->assertAttributeNotEquals(null, '_fileHandle', $this->phone);
}

public function testPhoneInfo()
{
$info = function () {
return $this->phone->phoneInfo('上海|上海|200000|021', 1);
};
$this->assertNotEmpty($info);
}

public function testPhoneFind()
{
$info = $this->phone->find(18621281566);
$this->assertNotEmpty($info);
}
}
4 changes: 4 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

date_default_timezone_set('UTC');
require dirname(__DIR__).'/vendor/autoload.php';

0 comments on commit a1951f0

Please sign in to comment.