diff --git a/.gitignore b/.gitignore index 2d772a7..0008b19 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,6 @@ vendor/ # 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 composer.lock + +# Gem +Gemfile.lock diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..bf89039 --- /dev/null +++ b/Gemfile @@ -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 \ No newline at end of file diff --git a/Guardfile b/Guardfile index cee967f..9f83330 100644 --- a/Guardfile +++ b/Guardfile @@ -1,15 +1,15 @@ # A sample Guardfile # 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: # watch(%r{file/path}) { `command(s)` } # + +# Mac用的通知中心 +notification :growl +# Linux用的通知中心 +notification :libnotify + guard :shell do watch(%r{htdocs/.+\.(php)}) do system 'phpdoc', '-d', './htdocs/lib', '-t', './docs/' @@ -20,3 +20,12 @@ end guard 'livereload' do watch(%r{htdocs/.+\.(php|css|js|html)}) 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 \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..4091f0b --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,9 @@ + + + + + tests + + + \ No newline at end of file diff --git a/tests/Database/DatabaseTest.php b/tests/Database/DatabaseTest.php new file mode 100644 index 0000000..11e54b1 --- /dev/null +++ b/tests/Database/DatabaseTest.php @@ -0,0 +1,31 @@ + + */ +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; + } + } +} \ No newline at end of file diff --git a/tests/InstallTest.php b/tests/InstallTest.php index e0baafa..f0aff88 100644 --- a/tests/InstallTest.php +++ b/tests/InstallTest.php @@ -7,7 +7,6 @@ */ namespace UElearning; -require_once __DIR__.'/../htdocs/config.php'; require_once UELEARNING_LIB_ROOT.'/Database/DBAdmin.php'; class InstallTest extends \PHPUnit_Framework_TestCase