Skip to content

OSS PHP Frameworks Unit Testing: Kohana 3.3

Samuel Demirdjian edited this page Nov 29, 2013 · 2 revisions

Kohana is an elegant HMVC PHP5 framework that provides a rich set of components for building web applications.

The framework will stand out of the rest because of its Cascading File System running HHVM.

Why Kohana and HHVM match?

Excerpt from the Extension-API:

For the simplest implementations, you can just write pure PHP code which will be built into your HHVM binary (as a block called SystemLib) and loaded persistently for all requests... To add your own function or class to SystemLib, place the implementation under hphp/system/php, and reference it from hphp/system/php.txt. From here, the next time you compile HHVM, it will be included in the binary as part of the runtime.

It is possible to put the Kohana system, or any framework in SystemLib, and it will be just part of HHVM.

However, Kohana's advantage is that, when you list the system files in hphp/system/php.txt, you want to list only transparently implemented classes, the ones that go deeper in folder hierarchy with the Kohana_ prefix. Then, you can still develop your application(s), overriding whatever class you need, through the Cascading File System!

Source Download

Download the latest master branch from Github

Official Testing Documentation

The documentation to run the unit tests are found here: http://kohanaframework.org/3.3/guide/unittest/testing

We followed the instructions for running the tests at the command line (see the "Usage" in the link above). Below are some additional steps we took to get the tests running correctly.

Initial Setup

In order to run the Kohana unit tests successfully, make sure you have HHVM, Composer and other basic packages ready to go.

To set initial configuration for Kohana, its enough to set the cookie salt in bootstrap.php.

birkir/kohana-hhvm module (to be reviewed by HHVM team)

A Kohana module to fix specific parts of the framework to make Kohana more compatible with HHVM.

birkir/kohana-hhvm is a standard module that can be enabled in bootstrap.php. Please read how to enable a module in Kohana.

Link:

http://github.com/birkir/kohana-hhvm

Running the Tests

To run the Kohana unit tests, use the following command from the root Kohana directory (sudo may be necessary):

[sudo] hhvm vendor/bin/phpunit --bootstrap=modules/unittest/bootstrap.php modules/unittest/tests.php

Fatals

Kohana_CookieTest::test_set with data set #0 ('foo', 'bar', NULL, true)

Failed asserting that false matches expected true.

Kohana_CookieTest::test_set with data set #1 ('foo', 'bar', 10, true)

Failed asserting that false matches expected true.

Kohana_CookieTest::test_delete with data set #0 ('foo', true)

Failed asserting that false matches expected true.

Kohana_CoreTest::test_globals_removes_user_def_globals

Failed asserting that two arrays are equal.

Kohana_DateTest::test_formatted_time with data set #4 ('2011-04-01 01:23:45 Antarctica/South_Pole', '@1301574225', 'Y-m-d H:i:s e', 'Antarctica/South_Pole')

Failed asserting that two strings are identical.

Kohana_FeedTest::test_create with data set #0 ( ... )

Failed asserting that false is true.

Kohana_RouteTest::test_all_returns_all_defined_routes

Failed asserting that Array() is identical to an object of class "ReflectionProperty".
Clone this wiki locally