From 3478dc4ac1f2e1db514dc8cd9a4a91a32943cef8 Mon Sep 17 00:00:00 2001 From: xamgore <xamgore@ya.ru> Date: Sat, 30 May 2015 03:01:26 +0300 Subject: [PATCH] Bootstrap configuration for unit-testing --- .../tests/classes/Model_Discipline_Test.php | 11 +++++++++++ ~dev_rating/modules/unittest/bootstrap.php | 9 +++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 ~dev_rating/application/tests/classes/Model_Discipline_Test.php diff --git a/~dev_rating/application/tests/classes/Model_Discipline_Test.php b/~dev_rating/application/tests/classes/Model_Discipline_Test.php new file mode 100644 index 000000000..7678ec5a3 --- /dev/null +++ b/~dev_rating/application/tests/classes/Model_Discipline_Test.php @@ -0,0 +1,11 @@ +<?php + +class Model_Discipline_Test extends PHPUnit_Framework_TestCase { + + /** @test */ + function idField() { + $d = Model_Discipline::load(1); + $this->assertEquals($d->id, 1); + } + +} diff --git a/~dev_rating/modules/unittest/bootstrap.php b/~dev_rating/modules/unittest/bootstrap.php index 177dae15a..493076b62 100644 --- a/~dev_rating/modules/unittest/bootstrap.php +++ b/~dev_rating/modules/unittest/bootstrap.php @@ -121,5 +121,10 @@ if (($ob_len = ob_get_length()) !== FALSE) } } -// Enable the unittest module -Kohana::modules(Kohana::modules() + array('unittest' => MODPATH.'unittest')); \ No newline at end of file +// Enable the unittest module if it is not already loaded - use the absolute path +$modules = Kohana::modules(); +$unittest_path = realpath(__DIR__).DIRECTORY_SEPARATOR; +if ( ! in_array($unittest_path, $modules)) { + $modules['unittest'] = $unittest_path; + Kohana::modules($modules); +} -- GitLab