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

(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
#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
#53

I opened the issue:
How to test setting cookie in controller testing https://github.com/kenjis/ci-phpunit-test/issues/86

If you have opinion about it, please comment.
Reply
#54

(01-04-2016, 10:24 PM)kenjis Wrote: I opened the issue:
How to test setting cookie in controller testing https://github.com/kenjis/ci-phpunit-test/issues/86

If you have opinion about it, please comment.

I sent a PR for it. See https://github.com/kenjis/ci-phpunit-test/pull/88
Reply
#55

At last ci-phpunit-test can test Welcome controller using wiredesignz/codeigniter-modular-extensions-hmvc without any modifications.
See https://github.com/kenjis/ci-hmvc-ci-phpunit-test

This dose not means ci-phpunit-test fully supports HMVC, but the compatibility with HMVC has been increased.
Reply
#56

v0.11.0 was released.
https://github.com/kenjis/ci-phpunit-test/releases

Please read Upgrade Note when you upgrade.
Reply
#57

About HMVC

Another test case was added to:
https://github.com/kenjis/ci-hmvc-ci-phpunit-test

And I added a note:
https://github.com/kenjis/ci-hmvc-ci-php...ote-to-use
Reply
#58

v0.11.1 was released!
See https://github.com/kenjis/ci-phpunit-test/releases

It is a bug fix release.
Reply
#59

v0.11.2 was released!
See https://github.com/kenjis/ci-phpunit-test/releases
Reply
#60

v0.11.3 was released!
Minor fix and update.

See https://github.com/kenjis/ci-phpunit-test/releases
Reply




Theme © iAndrew 2016 - Forum software by © MyBB