Download the PHP package kenjis/ci-phpunit-test without Composer

On this page you can find all versions of the php package kenjis/ci-phpunit-test. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ci-phpunit-test

ci-phpunit-test for CodeIgniter 3.x

Latest Stable Version Total Downloads Latest Unstable Version License

Scrutinizer Code Quality Coverage Status Build Status


[!WARNING] Upgrading to CodeIgniter4 is strongly recommended.


An easier way to use PHPUnit with CodeIgniter 3.x.

Requirements

Optional

Change Log

See Change Log.

Folder Structure

codeigniter/
├── application/
│   └── tests/
│        ├── _ci_phpunit_test/ ... don't touch! files ci-phpunit-test uses
│        ├── Bootstrap.php     ... bootstrap file for PHPUnit
│        ├── DbTestCase.php    ... DbTestCase class
│        ├── TestCase.php      ... TestCase class
│        ├── controllers/      ... put your controller tests
│        ├── libraries/        ... put your library tests
│        ├── mocks/
│        │   └── libraries/    ... mock libraries
│        ├── models/           ... put your model tests
│        └── phpunit.xml       ... config file for PHPUnit
└── vendor/

Installation

Manual Installation

  1. Download latest ci-phpunit-test from https://github.com/kenjis/ci-phpunit-test/releases.
  2. Unzip and copy application/tests folder into your application folder in CodeIgniter project.

That's it.

Composer Installation

$ cd /path/to/codeigniter/
$ composer require kenjis/ci-phpunit-test:^3.0 --dev

And run install.php:

$ php vendor/kenjis/ci-phpunit-test/install.php --from-composer
$ php vendor/kenjis/ci-phpunit-test/install.php -a <application_dir> -p <public_dir> -t <unittest_dir>

So the default would be:

$ php vendor/kenjis/ci-phpunit-test/install.php -a application -p public -t application/tests

Upgrading

Manual Upgrading

  1. Download latest ci-phpunit-test from https://github.com/kenjis/ci-phpunit-test/releases.
  2. Unzip and replace application/tests/_ci_phpunit_test folder.
  3. Read Change Log.

Composer Upgrading

$ cd /path/to/codeigniter/
$ composer update kenjis/ci-phpunit-test

Read Change Log.

If you want to remove application/test/_ci_phpunit_test/

If you're upgrading from a previous version of ci-phpunit-test that created an application/test/_ci_phpunit_test directory and now want to directly use ci-phpunit-test from Composer, you have a couple of additional steps:

  1. Delete the old test library directory:

  2. Edit the application/tests/Bootstrap.php file. At the bottom of the "set the main path constants" section, add the following:

    And replace any references to __DIR__ . '/_ci_phpunit_test/ or TESTPATH . '_ci_phpunit_test with CI_PHPUNIT_TESTPATH . '. (So, for example, __DIR__ . '/_ci_phpunit_test/CIPHPUnitTest.php' would become CI_PHPUNIT_TESTPATH . '/CIPHPUnitTest.php'.)

How to Run Tests

You need to install PHPUnit before running tests.

If you use Composer:

Run All Tests

$ cd /path/to/codeigniter/
$ vendor/bin/phpunit -c application/tests/
PHPUnit 9.5.4 by Sebastian Bergmann and contributors.

...                                                                 3 / 3 (100%)

Time: 00:00.102, Memory: 12.00 MB

OK (3 tests, 3 assertions)

Generating code coverage report in Clover XML format ... done [00:00.002]

Generating code coverage report in HTML format ... done [00:00.012]

To generate coverage report, Xdebug is needed.

Run a Single Test

If you want to run a single test case file:

$ vendor/bin/phpunit -c application/tests/ application/tests/models/Category_model_test.php

How to Write Tests

As an example, a test case class for Inventory_model would be as follows:

As an example, a test case class for Welcome controller would be as follows:

See How to Write Tests for details.

Function/Class Reference

See Function and Class Reference.

Tips

See Tips.

Stand-alone Packages

Some features of ci-phpunit-test are available in the following standalone packages.

Related Projects for CodeIgniter 3.x


All versions of ci-phpunit-test with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
nikic/php-parser Version ^4.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kenjis/ci-phpunit-test contains the following files

Loading the files please wait ....