Skip to content

Instantly share code, notes, and snippets.

@morozov
Last active December 8, 2018 13:04
Show Gist options
  • Save morozov/6698323 to your computer and use it in GitHub Desktop.
Save morozov/6698323 to your computer and use it in GitHub Desktop.
Ninja Test Qualification

Ninja Test Qualification

Ninja test is a self-sufficient unit test that is fully responsible for setting up environment it depends on and doesn't rely on other tests. Unlike others, ninja-tests survive within any test suite, they are less subjected to accidental false-negative failures and don't require periodical fixing.

In order to see if your newly written test passes the ninja qualification, to run it with the following command:

php phpunit.php --bootstrap=/path/to/ninja.php -c tests/phpunit.xml /path/to/test.php

When writing test, it may be easier just to copy the contents of ninja.php and paste it into test setUp() or setUpBeforeClass() method.

<?php
require 'SugarTestHelper.php';
unset(
$moduleList, $GLOBALS['moduleList'],
$modListHeader, $GLOBALS['modListHeader'],
$beanList, $GLOBALS['beanList'],
$beanFiles, $GLOBALS['beanFiles'],
$current_user, $GLOBALS['current_user'],
$app_strings, $GLOBALS['app_strings'],
$app_list_strings, $GLOBALS['app_list_strings'],
$mod_strings, $GLOBALS['mod_strings']
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment