Update Kohana to 3.1.3.1
This commit is contained in:
@@ -1,13 +1,2 @@
|
||||
# Unittest
|
||||
# Unittest
|
||||
|
||||
Unittest is a module that provides unittesting for Kohana using [PHPUnit](http://www.phpunit.de/).
|
||||
|
||||
### Running from the command line
|
||||
|
||||
$ phpunit --bootstrap=index.php modules/unittest/tests.php
|
||||
|
||||
Of course, you'll need to make sure the path to the tests.php file is correct. If you want you can copy it to a more accessible location.
|
||||
|
||||
### Running from the web
|
||||
|
||||
Just navigate to `http://example.com/unittest`. You may need to use `http://example.com/index.php/unittest` if you have not enabled url rewriting in your `.htaccess`.
|
||||
|
@@ -1,41 +0,0 @@
|
||||
# Installing PHPUnit
|
||||
|
||||
Before the Unittest module will work, you need to install PHPUnit.
|
||||
|
||||
## Installing on Windows/XAMPP
|
||||
|
||||
**(written by bitshift, see [this forum post](http://forum.kohanaframework.org/discussion/7346))**
|
||||
|
||||
Assuming xampp is installed to `C:\xampp`, and that you have pear installed, do the following:
|
||||
|
||||
1. Open a command prompt and go to C:\xampp\php
|
||||
2. Type `pear update-channels` (updates channel definitions)
|
||||
3. Type `pear upgrade` (upgrades all existing packages and pear)
|
||||
4. Type `pear channel-discover components.ez.no` (This is needed for PHPUnit)
|
||||
5. Type `pear channel-discover pear.symfony-project.com` (Also needed by PHPUnit)
|
||||
6. Type `pear channel-discover pear.phpunit.de` (This is the phpunit channel)
|
||||
7. Type `pear install --alldeps phpunit/PHPUnit` (This actually installs PHPUnit and all dependencies)
|
||||
|
||||
[!!] You may have to edit `memory_limit` in your `php.ini` if you get some sort of memory error, just set it to something really large, then back when your done.
|
||||
|
||||
Please see [this forum post](http://forum.kohanaframework.org/discussion/7346) for more information.
|
||||
|
||||
## Installing on *nix
|
||||
|
||||
If any of these fail, try again with sudo, most of them require root priveledges.
|
||||
|
||||
1. Install the 'php-pear' package.
|
||||
- On Ubuntu/Debian type `sudo apt-get install php-pear`
|
||||
2. Make sure Pear is up-to-date
|
||||
- Type `pear update-channels`
|
||||
- Type `pear upgrade`
|
||||
3. Add the required channels
|
||||
- Type `pear channel-discover components.ez.no`
|
||||
- Type `pear channel-discover pear.symfony-project.com`
|
||||
- Type `pear channel-discover pear.phpunit.de`
|
||||
4. Install PHPUnit itself
|
||||
- Type `pear install --alldeps phpunit/PHPUnit`
|
||||
|
||||
## Class 'PHPUnit_Framework_TestSuite' not found
|
||||
|
||||
If you get this error than it means... I don't even know.
|
@@ -1,6 +1,5 @@
|
||||
## [UnitTest]()
|
||||
- [Installing PHPUnit](installing)
|
||||
- [Testing](testing)
|
||||
- [Mock Objects](mockobjects)
|
||||
- [Troubleshooting](troubleshooting)
|
||||
- [Testing workflows](workflows)
|
||||
- [Testing workflows](testing_workflows)
|
@@ -1,8 +1,18 @@
|
||||
### From the command line
|
||||
|
||||
$ phpunit --bootstrap=index.php modules/unittest/tests.php
|
||||
|
||||
Of course, you'll need to make sure the path to the tests.php file is correct. If you want you can copy it to a more accessible location
|
||||
|
||||
### From the web
|
||||
|
||||
Just navigate to http://example.com/unittest. You may need to use http://example.com/index.php/unittest if you have not enabled url rewriting in your .htaccess.
|
||||
|
||||
## Writing tests
|
||||
|
||||
If you're writing a test for your application, place it in `application/tests`. Similarly, if you're writing a test for a module place it in `modules/<modulefolder>/tests`.
|
||||
If you're writing a test for your application, place it in "application/tests". Similarly, if you're writing a test for a module place it in modules/[modulefolder]/tests
|
||||
|
||||
Rather than tell you how to write tests I'll point you in the direction of the [PHPUnit Manual](http://www.phpunit.de/manual/3.4/en/index.html). One thing you should bear in mind when writing tests is that testcases should extend [Kohana_Unittest_Testcase] rather than `PHPUnit_Framework_TestCase`.
|
||||
Rather than tell you how to write tests I'll point you in the direction of the [PHPUnit Manual](http://www.phpunit.de/manual/3.4/en/index.html). One thing you should bear in mind when writing tests is that testcases should extend Unittest_Testcase rather than PHPUnit_Framework_TestCase, doing so gives you access to useful kohana specific helpers such as `setEnvironment()`.
|
||||
|
||||
Here's a taster of some of the cool things you can do with phpunit:
|
||||
|
||||
@@ -14,7 +24,7 @@ Ordinarily you could use a foreach loop to iterate over an array of test data, h
|
||||
|
||||
<?php
|
||||
|
||||
Class ReallyCoolTest extends Kohana_Unittest_TestCase
|
||||
Class ReallyCoolTest extends Unittest_TestCase
|
||||
{
|
||||
function providerStrLen()
|
||||
{
|
||||
@@ -57,7 +67,7 @@ To allow users to selectively run tests you need to organise your tests into gro
|
||||
* @group somegroup
|
||||
* @group somegroup.morespecific
|
||||
*/
|
||||
Class AnotherReallyCoolTest extends Kohana_Unittest_TestCase
|
||||
Class AnotherReallyCoolTest extends Unittest_TestCase
|
||||
{
|
||||
/**
|
||||
* Tests can also be grouped too!
|
||||
|
@@ -4,7 +4,7 @@ Having unittests for your application is a nice idea, but unless you actually us
|
||||
|
||||
## Testing through the webui
|
||||
|
||||
The web ui is a fairly temporary solution, aimed at helping developers get into unittesting and code coverage. Eventually it's hoped that people migrate on to CI servers, but it's fine for calculating code coverage locally.
|
||||
The web ui is a fairly temporary solution, aimed at helping developers get into unittesting and code coverage. Eventually it's hoped that people migrate on to the termainl & CI servers.
|
||||
|
||||
To access it goto
|
||||
|
||||
@@ -34,15 +34,15 @@ You can also specify a custom test suite loader (enter the path to your tests.ph
|
||||
|
||||
## Looping shell
|
||||
|
||||
I personally prefer to do all of my development in an advanced text editor such as vim/gedit/np++.
|
||||
If you're developing in a text editor such as textmate, vim, gedit etc. chances are phpunit support isn't natively supported by your editor.
|
||||
|
||||
To test while I work I run tests in an infinte looping. It's very easy to setup and only takes a few commands to setup.
|
||||
On nix you can run the following commands in the terminal:
|
||||
In such situations you can run a simple bash script to loop over the tests every X seconds, here's an example script:
|
||||
|
||||
while(true) do clear; phpunit; sleep 8; done;
|
||||
|
||||
In my experience this gives you just enough time to see what's going wrong before the tests are rerun.
|
||||
It's also quite handy to store common phpunit settings (like path to the bootstrap) in a a phpunit xml file to reduce the amount that has to be written in order to start a loop.
|
||||
You will probably need to adjust the timeout (`sleep 8`) to suit your own workflow, but 8 seconds seems to be about enough time to see what's erroring before the tests are re-run.
|
||||
|
||||
In the above example we're using a phpunit.xml config file to specify all the unit testing settings & to reduce the complexity of the looping script.
|
||||
|
||||
## Continuous Integration (CI)
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# Troubleshooting
|
||||
|
||||
#### I get the error "Class Kohana_Tests could not be found" when testing from the CLI
|
||||
## I get the error "Class Kohana_Tests could not be found" when testing from the CLI
|
||||
|
||||
You need to running PHPUnit >= 3.4, there is a bug in 3.3 which causes this.
|
||||
|
||||
#### Some of my classes aren't getting whitelisted for code coverage even though their module is
|
||||
## Some of my classes aren't getting whitelisted for code coverage even though their module is
|
||||
|
||||
Only the "highest" files in the cascading filesystem are whitelisted for code coverage.
|
||||
|
||||
@@ -12,7 +12,7 @@ To test your module's file, remove the higher file from the cascading filesystem
|
||||
|
||||
A good way of testing is to create a "vanilla" testing environment for your module, devoid of anything that isn't required by the module.
|
||||
|
||||
#### I get a blank page when trying to generate a code coverage report
|
||||
## I get a blank page when trying to generate a code coverage report
|
||||
|
||||
Try the following:
|
||||
|
||||
|
Reference in New Issue
Block a user