public function testEndTestSuiteDestruct() { $clearProperties = new Magento_Test_ClearProperties(); $phpUnitTestSuite = new PHPUnit_Framework_TestSuite(); $phpUnitTestSuite->addTestFile(__DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'DummyTestCase.php'); // Because addTestFile() adds classes from file to tests array, use first testsuite /** @var $testSuite PHPUnit_Framework_TestSuite */ $testSuite = $phpUnitTestSuite->testAt(0); $testSuite->run(); $testClass = $testSuite->testAt(0); foreach ($this->_properties as $property) { if ($property['is_static']) { $this->assertAttributeEquals($property['expectedValue'], $property['name'], get_class($testClass)); } else { $this->assertAttributeEquals($property['expectedValue'], $property['name'], $testClass); } } $clearProperties->endTestSuite($testSuite); $this->assertTrue(Magento_Test_ClearProperties_Stub::$isDestructCalled); foreach ($this->_properties as $property) { if ($property['is_static']) { $this->assertAttributeEmpty($property['name'], get_class($testClass)); } else { $this->assertAttributeEmpty($property['name'], $testClass); } } }
public function testEndTestSuiteDestruct() { $phpUnitTestSuite = new \PHPUnit_Framework_TestSuite(); $phpUnitTestSuite->addTestFile(__DIR__ . '/TestCasePropertiesTest/DummyTestCase.php'); // Because addTestFile() adds classes from file to tests array, use first testsuite /** @var $testSuite \PHPUnit_Framework_TestSuite */ $testSuite = $phpUnitTestSuite->testAt(0); $testSuite->run(); /** @var $testClass \Magento\Test\Workaround\Cleanup\TestCasePropertiesTest\DummyTestCase */ $testClass = $testSuite->testAt(0); $propertyObjectMock = $this->getMock('stdClass', ['__destruct']); $propertyObjectMock->expects($this->atLeastOnce())->method('__destruct'); $testClass->setPropertyObject($propertyObjectMock); foreach ($this->_fixtureProperties as $property) { if ($property['is_static']) { $this->assertAttributeNotEmpty($property['name'], get_class($testClass)); } else { $this->assertAttributeNotEmpty($property['name'], $testClass); } } $clearProperties = new \Magento\TestFramework\Workaround\Cleanup\TestCaseProperties(); $clearProperties->endTestSuite($testSuite); foreach ($this->_fixtureProperties as $property) { if ($property['is_static']) { $this->assertAttributeEmpty($property['name'], get_class($testClass)); } else { $this->assertAttributeEmpty($property['name'], $testClass); } } }
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) { // print("In startTestSuite - for suite = {$suite->getName()}\n"); KalturaLog::debug("In startTestSuite - for suite = {$suite->getName()}"); if ($suite instanceof PHPUnit_Framework_TestSuite_DataProvider) { //Get the test procedure name from the suite name which is (testCase::testProcedure) $testNames = explode("::", $suite->getName()); $testName = $testNames[0]; if (isset($testNames[1])) { $testName = $testNames[1]; } $testCase = $testNames[0]; if (is_null(KalturaTestListener::$testCaseFailures)) { KalturaLog::debug("KalturaTestCaseFailures is null creating empty test case failures for {$testCase}\n"); KalturaTestListener::$testCaseFailures = new KalturaTestCaseFailures($testName); } $testProcedure = KalturaTestListener::$testCaseFailures->getTestProcedureFailure($testName); //if the test procedure exists if (!$testProcedure) { KalturaTestListener::$testCaseFailures->addTestProcedureFailure(new KalturaTestProcedureFailure($testName)); } else { KalturaLog::alert("Test procedure [{$testName}] already added"); } } else { //Check if the test belongs to the same test case failures (by the first test of the suite) $test = $suite->testAt(0); if ($test instanceof PHPUnit_Framework_TestSuite_DataProvider) { $test = $test->testAt(0); } $class = get_class($test); //if the new test comes from a new file (testCase) if (KalturaTestListener::$currentTestCase != $class) { //Gets the class path for the failure file $classPath = KAutoloader::getClassFilePath($class); KalturaTestListener::$failureFilePath = dirname($classPath) . "/testsData/{$class}.failures"; KalturaTestListener::$dataFilePath = dirname($classPath) . "/testsData/{$class}.data"; $this->writeFailuresToFile(); //Opens the new failure file for the new test KalturaTestListener::$failuresFile = fopen(KalturaTestListener::$failureFilePath, "w+"); //Change the current test case KalturaTestListener::$currentTestCase = $class; //Create new test case failures for the new test case KalturaTestListener::$testCaseFailures = new KalturaTestCaseFailures(KalturaTestListener::$currentTestCase); //TODO: get the test procedure name from the suite KalturaTestListener::$testCaseFailures->setTestProceduresFailures(array(new KalturaTestProcedureFailure("Unknown"))); } else { } } }