<commit_before><?php
namespace pyd\testkit\base;

/**
 * Test case base class.
 *
 * @author pyd <<EMAIL>>
 */
class TestCase extends \PHPUnit_Framework_TestCase
{
    /**
     * @var \pyd\testkit\TestManager
     */
    private static $testManager;

    public static function setTestManager(\pyd\testkit\TestManager $testManager)
    {
        self::$testManager = $testManager;
    }

    /**
     * This method is executed at least once when PHPUnit will start processing
     * this test case. it is also executed before each test method that runs in
     * 'isolation'.
     *
     * Don't forget to call parent::setUpBeforeClass() when overriding.
     */
    public static function setUpBeforeClass()
    {
        self::$testManager->onSetUpBeforeClass(get_called_class());
    }

    /**
     * This method is executed before each test method.
     */
    public function setUp()
    {
        self::$testManager->onSetUp();
    }

    /**
     * This method is executed at least once when PHPUnit will end processing
     * this test case. it is also executed after each test method that runs in
     * 'isolation'.
     */
    public static function tearDownAfterClass()
    {
        self::$testManager->onTearDownAfterClass();
    }
}
<commit_msg>Refactor test case base class<commit_after><?php
namespace pyd\testkit\base;

use pyd\testkit\EventsDispatcher;

/**
 * Test case base class.
 *
 * @author pyd <<EMAIL>>
 */
class TestCase extends \PHPUnit_Framework_TestCase
{
    /**
     * @var boolean if set to false, a fresh Yii app will be created for each
     * test method of the test case.
     * If set to true, a single Yii app is created for all test methods of the
     * test case unless it is deleted by the tester. in this case a new Yii app
     * is automatically created.
     */
    public static $shareYiiApp = false;

    /**
     * @var boolean if set to false, each db table, @see dbTablesToLoad(), is
     * loaded before each test method of the test case.
     * If set to true, db is loaded once for all test methods of the test case
     * unless one or more tables are unloaded. In this case, unloaded tables
     * will be loaded again for the next test method. Note that unload must be
     * performed using the @see \pyd\testkit\fixtures\Db::unload() or
     * @see \pyd\testkit\fixtures\DbTable::unload() method. Deleting all rows
     * of a table using it's model 'delete' method won't cause de table to be
     * reloaded.
     */
    public static $shareDbFixture = false;

    /**
     * @var \pyd\testkit\fixtures\Manager
     */
    private static $fixturesManager;

    /**
     * @param \pyd\testkit\fixtures\Manager $fixturesManager
     */
    public static function setFixturesManager(\pyd\testkit\fixtures\Manager $fixturesManager)
    {
        self::$fixturesManager = $fixturesManager;
    }

    /**
     * Return config to create \pyd\testkit\fixtures\DbTable instances whose
     * tables must be populated with fixture data.
     */
    public static function dbTablesToLoad()
    {
        return [];
    }

    /**
     * @return \pyd\testkit\fixtures\Manager
     */
    public static function getFixturesManager()
    {
        return self::$fixturesManager;
    }

    public static function setUpBeforeClass()
    {
        self::$fixturesManager->getEventsDispatcher()->dispatch(EventsDispatcher::EVENT_SETUPBEFORECLASS, get_called_class());
    }

    public function setUp()
    {
        self::$fixturesManager->getEventsDispatcher()->dispatch(EventsDispatcher::EVENT_SETUP, $this);
    }

    public function tearDown()
    {
        self::$fixturesManager->getEventsDispatcher()->dispatch(EventsDispatcher::EVENT_TEARDOWN, $this);
    }

    public static function tearDownAfterClass()
    {
        $testCaseEnd = self::$fixturesManager->getInitialPID() === getmypid();
        self::$fixturesManager->getEventsDispatcher()->dispatch(EventsDispatcher::EVENT_TEARDOWNAFTERCLASS, get_called_class(), $testCaseEnd);
    }
}

{'fraction_non_alphanumeric': 0.10125, 'fraction_numerical': 0.0, 'mean_word_length': 2.8397312859884836, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5485771', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1133, 'n_words': 351}