Welcome Guest, Not a member yet? Register   Sign In
ci-phpunit-test for CodeIgniter 3.0
#52

You misunderstand about `testing` environment.
ci-phpunit-test always sets `testsing` automatically, so you don't have to do anything to set environment.

Do you have `config/testing/database.php`? If you have it, you must configure it correclty.

(01-04-2016, 06:37 AM)resolv_25 Wrote:
(12-30-2015, 07:26 PM)kenjis Wrote: @resolv_25

Tests run on `testing` environment.
https://github.com/kenjis/ci-phpunit-tes...nvironment

Did you setup database.php for testing environment correctly?

Hi, 

I'm probably missing something.

I believe I did put 'testing' environment properly, in .htaccess i have:
SetEnv CI_ENV 'testing' 

On database.php I have:
'db_debug' => (ENVIRONMENT == 'testing'),

If I put in code:
echo $_SERVER['CI_ENV'];
I do get answer 'testing'

phpunit gives following error:

Code:
Error:         No code coverage driver is available

.......
PHP Fatal error:  Call to a member function order_by() on null in /var/www/html/lipa2016/application/models/Category_model.php on line 12

A PHP Error was encountered

Severity:    Notice
Message:     Undefined property: CI_Controller::$db
Filename:    /var/www/html/lipa2016/system/core/Model.php
Line Number: 77

Backtrace:
    File: /var/www/html/lipa2016/application/models/Category_model.php
    Line: 12
    Function: __get

    File: /var/www/html/lipa2016/application/tests/models/Category_model_test.php
    Line: 25
    Function: get_category_list

    File: phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php
    Line: 910
    Function: invokeArgs

    File: phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php
    Line: 770
    Function: runTest

    File: phar:///usr/local/bin/phpunit/phpunit/Framework/TestResult.php
    Line: 685
    Function: runBare

    File: phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php
    Line: 726
    Function: run

    File: phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php
    Line: 747
    Function: run

    File: phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php
    Line: 747
    Function: run

    File: phar:///usr/local/bin/phpunit/phpunit/TextUI/TestRunner.php
    Line: 429
    Function: run

    File: phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php
    Line: 155
    Function: doRun

    File: phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php
    Line: 106
    Function: run

    File: /usr/local/bin/phpunit
    Line: 514
    Function: main



Fatal error: Call to a member function order_by() on null in /var/www/html/lipa2016/application/models/Category_model.php on line 12

A PHP Error was encountered

Severity:    Error
Message:     Call to a member function order_by() on null
Filename:    /var/www/html/lipa2016/application/models/Category_model.php
Line Number: 12

BTW, the method get_category_list gives proper result if I'm calling it from a controller.
Reply


Messages In This Thread
ci-phpunit-test for CodeIgniter 3.0 - by kenjis - 05-09-2015, 11:33 PM
RE: ci-phpunit-test for CodeIgniter 3.0 - by kenjis - 01-04-2016, 10:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB