PHPUnit
This commit is contained in:
parent
b3bc9602f5
commit
0bf3c54a27
3
.gitignore
vendored
3
.gitignore
vendored
@ -26,3 +26,6 @@ vendor/
|
|||||||
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
|
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
|
||||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||||
composer.lock
|
composer.lock
|
||||||
|
|
||||||
|
# Gem
|
||||||
|
Gemfile.lock
|
||||||
|
9
Gemfile
Normal file
9
Gemfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
group :development do
|
||||||
|
gem 'guard'
|
||||||
|
gem 'guard-livereload', require: false
|
||||||
|
gem 'guard-shell'
|
||||||
|
gem 'guard-phpunit2'
|
||||||
|
gem 'rb-fsevent'
|
||||||
|
gem 'ruby_gntp'
|
||||||
|
gem 'growl'
|
||||||
|
end
|
21
Guardfile
21
Guardfile
@ -1,15 +1,15 @@
|
|||||||
# A sample Guardfile
|
# A sample Guardfile
|
||||||
# More info at https://github.com/guard/guard#readme
|
# More info at https://github.com/guard/guard#readme
|
||||||
|
|
||||||
group :development do
|
|
||||||
gem 'guard'
|
|
||||||
gem 'guard-livereload', require: false
|
|
||||||
gem 'guard-shell'
|
|
||||||
end
|
|
||||||
|
|
||||||
# Add files and commands to this file, like the example:
|
# Add files and commands to this file, like the example:
|
||||||
# watch(%r{file/path}) { `command(s)` }
|
# watch(%r{file/path}) { `command(s)` }
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Mac用的通知中心
|
||||||
|
notification :growl
|
||||||
|
# Linux用的通知中心
|
||||||
|
notification :libnotify
|
||||||
|
|
||||||
guard :shell do
|
guard :shell do
|
||||||
watch(%r{htdocs/.+\.(php)}) do
|
watch(%r{htdocs/.+\.(php)}) do
|
||||||
system 'phpdoc', '-d', './htdocs/lib', '-t', './docs/'
|
system 'phpdoc', '-d', './htdocs/lib', '-t', './docs/'
|
||||||
@ -20,3 +20,12 @@ end
|
|||||||
guard 'livereload' do
|
guard 'livereload' do
|
||||||
watch(%r{htdocs/.+\.(php|css|js|html)})
|
watch(%r{htdocs/.+\.(php|css|js|html)})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# PHPUnit
|
||||||
|
guard :phpunit2, :all_on_start => false, :tests_path => 'tests/', :cli => '--colors -c phpunit.xml' do
|
||||||
|
# Run any test in app/tests upon save.
|
||||||
|
watch(%r{^tests/.+Test\.php$})
|
||||||
|
|
||||||
|
# When a file is edited, try to run its associated test.
|
||||||
|
watch(%r{^htdocs/lib/(.+)\.php}) { |m| "tests/#{m[1]}Test.php" }
|
||||||
|
end
|
9
phpunit.xml
Normal file
9
phpunit.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<!-- colors為true可以讓測試結果加上顏色方塊
|
||||||
|
bootstrap可以自行定義init程式(例如define一些變數) -->
|
||||||
|
<phpunit colors="true" bootstrap="htdocs/config.php">
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="all">
|
||||||
|
<directory>tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
</phpunit>
|
31
tests/Database/DatabaseTest.php
Normal file
31
tests/Database/DatabaseTest.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* DatabaseTest
|
||||||
|
*
|
||||||
|
* @package UElearning
|
||||||
|
* @author Yuan Chiu <chyuaner@gmail.com>
|
||||||
|
*/
|
||||||
|
namespace UElearning;
|
||||||
|
|
||||||
|
require_once UELEARNING_LIB_ROOT.'/Database/DBAdmin.php';
|
||||||
|
|
||||||
|
class InstallTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 測試安裝初始化資料庫
|
||||||
|
*/
|
||||||
|
public function testInstallDatabase()
|
||||||
|
{
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 建立資料庫管理物件
|
||||||
|
$dbAdmin = new Database\DBAdmin();
|
||||||
|
|
||||||
|
}
|
||||||
|
// 若設定的DBMS不被支援 則丟出例外
|
||||||
|
catch (Database\Exception\DatabaseNoSupportException $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
namespace UElearning;
|
namespace UElearning;
|
||||||
|
|
||||||
require_once __DIR__.'/../htdocs/config.php';
|
|
||||||
require_once UELEARNING_LIB_ROOT.'/Database/DBAdmin.php';
|
require_once UELEARNING_LIB_ROOT.'/Database/DBAdmin.php';
|
||||||
|
|
||||||
class InstallTest extends \PHPUnit_Framework_TestCase
|
class InstallTest extends \PHPUnit_Framework_TestCase
|
||||||
|
Loading…
x
Reference in New Issue
Block a user