This repository has been archived by the owner on Jul 10, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.operating-system }} | ||
|
||
strategy: | ||
matrix: | ||
operating-system: [ubuntu-latest] | ||
php-versions: ['7.2', '7.3', '7.4'] | ||
|
||
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Dependencies | ||
uses: php-actions/composer@v5 | ||
with: | ||
php_version: ${{ matrix.php-versions }} | ||
|
||
- name: PHPUnit Tests | ||
uses: php-actions/phpunit@v2 | ||
with: | ||
version: 8.0.0 | ||
php_version: ${{ matrix.php-versions }} | ||
configuration: phpunit.xml | ||
bootstrap: vendor/autoload.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/.idea/ | ||
/vendor/ | ||
/composer.lock | ||
/.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit colors="true"> | ||
<testsuites> | ||
<testsuite name="main"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<?php | ||
/** | ||
* Copyright 2021 GoneTone | ||
* | ||
* HiNet hichannel 台灣電台 | ||
* https://github.com/GoneToneStudio/php-hinet-hichannel-taiwan-radio | ||
* | ||
* @author 張文相 Zhang Wenxiang (旋風之音 GoneTone) <https://blog.reh.tw> | ||
* @license MIT <https://github.com/GoneToneStudio/php-hinet-hichannel-taiwan-radio/blob/master/LICENSE> | ||
* | ||
* HiNetHichannel Test | ||
*/ | ||
|
||
use GoneTone\HiNetHichannel; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class ShrinkURLTest | ||
*/ | ||
class HiNetHichannelTest extends TestCase | ||
{ | ||
protected $_hichannel; | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
protected function setUp(): void { | ||
$this->_hichannel = new HiNetHichannel("KISS RADIO 大眾廣播電台"); | ||
$this->_hichannel->loadApi(); | ||
} | ||
|
||
/** | ||
* 測試取得播放網址 (m3u8) | ||
* | ||
* @throws Exception | ||
*/ | ||
public function testGetPlayUrl() { | ||
$playUrl = $this->_hichannel->playUrl(); | ||
$this->assertRegExp("/https?:\/\/(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\/live\/[a-zA-Z0-9]+\/chunklist\.m3u8\?token=(.*)&expires=(.*)/i", $playUrl); | ||
} | ||
|
||
/** | ||
* 測試取得頻道名稱 | ||
* | ||
* @throws Exception | ||
*/ | ||
public function testGetTitle() { | ||
$title = $this->_hichannel->title(); | ||
$this->assertIsString($title); | ||
} | ||
|
||
/** | ||
* 測試取得頻道 ID | ||
* | ||
* @throws Exception | ||
*/ | ||
public function testGetId() { | ||
$id = $this->_hichannel->id(); | ||
$this->assertIsString($id); | ||
} | ||
|
||
/** | ||
* 測試取得頻道描述 | ||
* | ||
* @throws Exception | ||
*/ | ||
public function testGetDesc() { | ||
$desc = $this->_hichannel->desc(); | ||
$this->assertIsString($desc); | ||
} | ||
|
||
/** | ||
* 測試取得頻道區域 | ||
* | ||
* @throws Exception | ||
*/ | ||
public function testGetArea() { | ||
$area = $this->_hichannel->area(); | ||
$this->assertIsString($area); | ||
} | ||
|
||
/** | ||
* 測試取得頻道類型 | ||
* | ||
* @throws Exception | ||
*/ | ||
public function testGetType() { | ||
$type = $this->_hichannel->type(); | ||
$this->assertIsString($type); | ||
} | ||
|
||
/** | ||
* 測試取得頻道圖片網址 | ||
* | ||
* @throws Exception | ||
*/ | ||
public function testGetImageUrl() { | ||
$imageUrl = $this->_hichannel->imageUrl(); | ||
$this->assertRegExp("/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/i", $imageUrl); | ||
} | ||
|
||
/** | ||
* 測試取得頻道目前節目名稱 | ||
* | ||
* @throws Exception | ||
*/ | ||
public function testGetNowProgramName() { | ||
$nowProgramName = $this->_hichannel->nowProgramName(); | ||
$this->assertIsString($nowProgramName); | ||
} | ||
|
||
/** | ||
* 測試取得頻道節目表 | ||
* | ||
* @throws Exception | ||
*/ | ||
public function testGetProgramList() { | ||
$programList = $this->_hichannel->programList(); | ||
$this->assertIsArray($programList); | ||
} | ||
} |