Project-Id-Version: Trac 0.12
Report-Msgid-Bugs-To: trac-dev@googlegroups.com
POT-Creation-Date: 2008-01-30 09:20+0100
PO-Revision-Date: 2010-07-19 23:05+0200
Last-Translator: Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
Language-Team: en_US <trac-dev@googlegroups.com>
Plural-Forms: nplurals=2; plural=(n != 1)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Generated-By: Babel 0.9.6

Warning: Can't synchronize with repository "(default)" (Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? ). Look in the Trac log for more information.
Last modified 5 years ago Last modified on 09/18/12 16:30:47

This page how to execute and write tests for phTagr. Writing tests is very important to reduce regression: You can avoid that fixed bug are getting buggy again.

Tests increase code quality and also simplifies the software development. You can concentrate on a specific feature/fix and assure that your changes do not break other dependent parts of code.

Installing PHPUnit

Since phtagr uses the MVC CakePHP framework phtagr uses their test framework, too. Cakes tests require PHPUnit and cake's Testing Documentation describes the Intallation of PHPUnit:

pear upgrade PEAR
pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit

Running Tests

Make sure you enabled debug level at least to 1 in Config/core.php file:

    Configure::write('debug', 1);

Open test.php at your phtagr installation. If your run your phtagr at http://localhost/phtagr open http://localhost/phtagr/test.php

http://demo.phtagr.org/media/thumb/404

Now you can run all tests or a specific test. If you write a tests it is better to run a specific test. Before you commit you should crosscheck that your changes do not break other tests.

http://demo.phtagr.org/media/thumb/405

Write Tests

All tests are located at Test/Case directory and have further subdirectories for their specific test case. Model tests are located in subdirectory Model and controller tests are located at Controller directory.

The easiest way is to copy an existing test and modify it for your needs. Please read Testing documentation of cake for further help. It is also helpful to observe your code with a debugger. The page DebugWithNetbeans describes how you run phtagr with IDE NetBeans and php debugger xdebug.