[TYPO3-dev] unit test extension

Elmar Hinz elmar.DOT.hinz at team.MINUS.red.DOT.net
Sat Mar 11 21:36:27 CET 2006


How to prepare a unit test in a way that it runs with t3unit and also
from the command line?

The pattern of the test filename is:

your_extension/tests/xxxxxxx_testcase.php

With this pattern it will be found by T3Unit.

Following lines in the testfile help me to evaluate the right pathes
from commandline:


if(!defined('PATH_site')) {

  $path = realpath($_SERVER['PWD'] .'/'. $_SERVER['SCRIPT_NAME']);

  if(!preg_match('|(.*)(typo3conf.*)(ecttest/test)|', $path, $matches)) {
    if(! preg_match('|(.*)(typo3/sysext.*)(ecttest/test)|', $path,
$matches))
      exit(chr(10) . 'Unknown installation path' . chr(10). chr(10));
  }

  define('PATH_site', $matches[1]);
  $GLOBALS['TYPO3_LOADED_EXT']['ect']['siteRelPath']= $matches[2] .
'ect/';
  $GLOBALS['TYPO3_LOADED_EXT']['ecttest']['siteRelPath']= $matches[2]
. 'ecttest/';

  define('PATH_t3lib', PATH_site . 't3lib/');
  require_once(PATH_t3lib . 'class.t3lib_div.php');
  require_once(PATH_t3lib . 'class.t3lib_extmgm.php');

}

require_once (t3lib_extMgm::extPath('ect') . 'class.ect_link.php');
require_once(t3lib_extMgm::extPath('ecttest') . _mockCObjectPath_);




More information about the TYPO3-dev mailing list