Welcome Guest, Not a member yet? Register   Sign In
Problems with CIUnit - redeclare class error

HI I’ve just downloaded CIUnit 0.17 to unit test my code igniter application.
PHPUnit version 3.4.3
CI version 1.7.2

I’m now learning CI and built a really simple blog model class (doesn’t really do any thing yet)
but when I try to test it I get the Fatal error that the class has already been declared
$ phpunit --verbose AllTests.php

Fatal error: Cannot redeclare class Blog_modelTest in /var/www/CodeIgniter/system/application/tests/models/blog_model_test.php on line 16

Call Stack:
    0.0004      61944   1. {main}() /usr/bin/phpunit:0
    0.1269    4480512   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:52
    0.1269    4481244   3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:147
    0.1290    4484292   4. PHPUnit_Runner_BaseTestRunner->getTest() /usr/share/php/PHPUnit/TextUI/Command.php:168
    0.1291    4484516   5. PHPUnit_Runner_BaseTestRunner->loadSuiteClass() /usr/share/php/PHPUnit/Runner/BaseTestRunner.php:112
    0.1291    4485004   6. PHPUnit_Runner_StandardTestSuiteLoader->load() /usr/share/php/PHPUnit/Runner/BaseTestRunner.php:170
    0.1294    4519536   7. PHPUnit_Util_Fileloader::checkAndLoad() /usr/share/php/PHPUnit/Runner/StandardTestSuiteLoader.php:102
    0.1294    4519796   8. PHPUnit_Util_Fileloader::load() /usr/share/php/PHPUnit/Util/Fileloader.php:91
    0.1298    4533212   9. include_once('/var/www/CodeIgniter/system/application/tests/AllTests.php') /usr/share/php/PHPUnit/Util/Fileloader.php:113
    0.1709    6438416  10. require_once('/var/www/CodeIgniter/system/application/tests/models/ModelsAllTests.php') /var/www/CodeIgniter/system/application/tests/AllTests.php:19

the test code itself is also very simple -

include_once dirname(__FILE__).'/../CIUnit.php';

class Blog_modelTest extends CIUnit_TestCase {

    public function setUp() {    

    function testGet_entries()
         $this->assertEquals(10, count($this->blog->get_entries));


any idea why this would happen ?

Ok never mind found the solution.

this was cosed becose my text editor saves back file ending with .php~ in the directory.
CIUnit thought they were tests and try to run them so it declared the test clases twice.

deleting the backups solved the problem

Hi, can you show more example how you use the CITest, because I can't get the understanding for how to use the test module.

As we know we use php CRUD, how can we implement it?
Sorry for this kind of basic question, but I know Test is important, but I dunno how to start for it, and automatic it.

Theme © iAndrew 2016 - Forum software by © MyBB