This commit is contained in:
Yuan Chiu 2014-08-17 02:17:54 -07:00
parent b3bc9602f5
commit 0bf3c54a27
6 changed files with 67 additions and 7 deletions

3
.gitignore vendored
View File

@ -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
View 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

View File

@ -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
View 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>

View 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;
}
}
}

View File

@ -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