Giter Club home page Giter Club logo

ci-app-for-ci-phpunit-test's Introduction

CodeIgniter Test Application for ci-phpunit-test

This CodeIgniter Application is for testing of ci-phpunit-test.

Requirements

  • PHP 7.3 or later

How to Run Tests

$ git clone -b 3.x https://github.com/kenjis/ci-app-for-ci-phpunit-test.git
$ cd ci-app-for-ci-phpunit-test
$ composer update
$ ./install.php
$ ./test.sh

Related Projects for CodeIgniter 3.0

ci-app-for-ci-phpunit-test's People

Contributors

esetnik avatar hoersten avatar jasonoro avatar kasimtan avatar kenjis avatar tianhe1986 avatar tpojka avatar ytetsuro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ci-app-for-ci-phpunit-test's Issues

Faild to open tream: No such file or directory in ~\ci-app-for-ci-phpunit-test\application\tests\Bootstrap.php on line 298

Hi!
Thank for your great work.

I have tried to make test code with your library.
But I have problems when I used command line below:

./vendor/bin/phpunit -c application/tests/ application/tests/controllers/Welcome_test.php

The occured error is following:

Faild to open tream: No such file or directory in ~\ci-app-for-ci-phpunit-test\application\tests\Bootstrap.php on line 298

I am looking forward to any response from you.

Issue with REST test

Hello,

I'm trying to run this file as a test (https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/api/Example_test.php) and here is the output that I am seeing.

PHPUnit 5.7.5 by Sebastian Bergmann and contributors.

Error:         No code coverage driver is available

...[{"id":1,"name":"John","email":"[email protected]","fact":"Loves coding"},{"id":2,"name":"Jim","email":"[email protected]","fact":"Developed on CodeIgniter"},{"id":3,"name":"Jane","email":"[email protected]","fact":"Lives in the USA","0":{"hobbies":["guitar","cycling"]}}]

It looks like the tests don't run. If I comment out line 11, things seem to work (until the next $this->request). Looks like there is an issue in $this->request that is causing issues, but it wasn't obvious the issue.

Any thoughts?

Testing controller method which has no output but returns

Assuming I have a controller like this:

<?php

class Welcome extends CI_Controller {
  public function index()
  {
    $solution = $this->getSolution();
    echo 'The solution is ' . $solution;
  }

  public function getSolution()
  {
    return 42;
  }
}

If I would like to test getSolution() in a classical unit testing behaviour, I would call the method directly:

<?php

class Welcome_test extends TestCase
{
  public function test_getSolution()
  {
    $testSolution = $this->request('GET', ['welcome', 'getSolution']);
    $this->assertEquals(42, $testSolution);
    // Failed asserting that null matches expected 200.
  }
}

Unfortunately (understandably), $testSolution is always null as it seems to contain only output. Proof: If I echo "something"; in getSolution(), $testSolution equals "something".

So is there a way to test controller methods directly that are no route methods but simple helper methods that return something?

Or do I have to change my design to define such methods in libraries/helpers?

my-codeigniter.sh -> composer update failed

error:
Your requirements could not be resolved to an installable set of packages.

Problem 1
- deployer/deployer v3.0.10 requires phpseclib/phpseclib ~2.0 -> satisfiable by phpseclib/phpseclib[2.0.x-dev].
- deployer/deployer v3.0.11 requires phpseclib/phpseclib ~2.0 -> satisfiable by phpseclib/phpseclib[2.0.x-dev].
- deployer/deployer v3.0.7 requires phpseclib/phpseclib ~2.0 -> satisfiable by phpseclib/phpseclib[2.0.x-dev].
- deployer/deployer v3.0.8 requires phpseclib/phpseclib ~2.0 -> satisfiable by phpseclib/phpseclib[2.0.x-dev].
- deployer/deployer v3.0.9 requires phpseclib/phpseclib ~2.0 -> satisfiable by phpseclib/phpseclib[2.0.x-dev].
- deployer/deployer v3.1.0 requires phpseclib/phpseclib ~2.0 -> satisfiable by phpseclib/phpseclib[2.0.x-dev].
- deployer/deployer v3.1.1 requires phpseclib/phpseclib ~2.0 -> satisfiable by phpseclib/phpseclib[2.0.x-dev].
- deployer/deployer v3.1.2 requires phpseclib/phpseclib ~2.0 -> satisfiable by phpseclib/phpseclib[2.0.x-dev].
- deployer/deployer v3.2.0 requires phpseclib/phpseclib ~2.0 -> satisfiable by phpseclib/phpseclib[2.0.x-dev].
- deployer/deployer v3.2.1 requires phpseclib/phpseclib ~2.0 -> satisfiable by phpseclib/phpseclib[2.0.x-dev].
- deployer/deployer v3.3.0 requires phpseclib/phpseclib ~2.0 -> satisfiable by phpseclib/phpseclib[2.0.x-dev].
- Conclusion: don't install phpseclib/phpseclib 2.0.x-dev
- Installation request for kenjis/codeigniter-deployer 1.0.x@dev -> satisfiable by kenjis/codeigniter-deployer[1.0.x-dev].
- Conclusion: don't install symfony/config v4.0.3|install deployer/deployer v3.0.10|install deployer/deployer v3.0.11|install deployer/deployer v3.0.7|install deployer/deployer v3.0.8|install deployer/deployer v3.0.9|install deployer/deployer v3.1.0|install deployer/deployer v3.1.1|install deployer/deployer v3.1.2|install deployer/deployer v3.2.0|install deployer/deployer v3.2.1|install deployer/deployer v3.3.0
- Conclusion: remove symfony/config v4.0.3|install deployer/deployer v3.0.10|install deployer/deployer v3.0.11|install deployer/deployer v3.0.7|install deployer/deployer v3.0.8|install deployer/deployer v3.0.9|install deployer/deployer v3.1.0|install deployer/deployer v3.1.1|install deployer/deployer v3.1.2|install deployer/deployer v3.2.0|install deployer/deployer v3.2.1|install deployer/deployer v3.3.0

How to i use the inside tests/models file ? i got an error.

Can you pls help me solve this error. i can't work with inside models file of tests folder.
Code

{
    protected $CI; 	
    public function setUp() { 	
        $this->CI = &get_instance();
        $this->obj = $this->newModel('Auth_model');
    }
}

Error

PHPUnit 6.5.12 by Sebastian Bergmann and contributors.

Error: No code coverage driver is available

E.. 3 / 3 (100%)G:\xampp\htdocs\hcm\admin\back-end\application

Time: 433 ms, Memory: 6.00MB

There was 1 error:

  1. Auth_test::testLoginTrue
    Error: Call to undefined method Auth_test::newModel()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.