diff --git a/Tools/Tests/Regression/TestsGenerator/TestsGeneratorTest.php b/Tools/Tests/Regression/TestsGenerator/TestsGeneratorTest.php
index 0cc901e..a50b724 100644
--- a/Tools/Tests/Regression/TestsGenerator/TestsGeneratorTest.php
+++ b/Tools/Tests/Regression/TestsGenerator/TestsGeneratorTest.php
@@ -112,8 +112,9 @@ public function test()
unlink($this->setDirSep($tmp . '/' . $file));
}
}
- unlink($this->setDirSep($tmp . '/manyElements.xml'));
- unlink($this->setDirSep($tmp . '/manyNewElements.xml'));
+ unlink($this->setDirSep($tmp . '/modify-element/manyElements.xml'));
+ unlink($this->setDirSep($tmp . '/modify-element/manyNewElements.xml'));
+ rmdir($this->setDirSep($tmp . '/modify-element'));
rmdir($tmp);
}
diff --git a/Tools/Tests/Regression/TestsRunner/TestsRunnerTest.php b/Tools/Tests/Regression/TestsRunner/TestsRunnerTest.php
index 8c9503b..809d4e4 100644
--- a/Tools/Tests/Regression/TestsRunner/TestsRunnerTest.php
+++ b/Tools/Tests/Regression/TestsRunner/TestsRunnerTest.php
@@ -124,7 +124,9 @@ public function test()
$report = preg_replace('/Time="[^"]+"/', 'Time="..."', $report);
$report = preg_replace('/Memory="[^"]+"/', 'Memory="..."', $report);
- $report = preg_replace('/-[0-9]{10}-[0-9]{6}.xml"/', '-..........-.......xml"', $report);
+ $report = preg_replace('/-[0-9]{10}-[0-9]{6}.xml/', '-..........-.......xml', $report);
+ $report = str_replace(__DIR__, '__PATH__', $report);
+ $report = str_replace(str_replace('\\', '/', __DIR__), '__PATH__', $report);
$this->assertXmlStringEqualsXmlFile($reportsExpected, $report);
// remove generated report
diff --git a/Tools/Tests/Regression/TestsRunner/reportsExpectedLinux.xml b/Tools/Tests/Regression/TestsRunner/reportsExpectedLinux.xml
index 7f4b9b2..8436b48 100644
--- a/Tools/Tests/Regression/TestsRunner/reportsExpectedLinux.xml
+++ b/Tools/Tests/Regression/TestsRunner/reportsExpectedLinux.xml
@@ -6,72 +6,72 @@
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
diff --git a/Tools/Tests/Regression/TestsRunner/reportsExpectedWindows.xml b/Tools/Tests/Regression/TestsRunner/reportsExpectedWindows.xml
index c488d00..0a4be22 100644
--- a/Tools/Tests/Regression/TestsRunner/reportsExpectedWindows.xml
+++ b/Tools/Tests/Regression/TestsRunner/reportsExpectedWindows.xml
@@ -15,66 +15,66 @@
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
diff --git a/Tools/Tests/Unit/Reports/Convertor/HtmlConvertorDriver/FixtureReport/report.xml b/Tools/Tests/Unit/Reports/Convertor/HtmlConvertorDriver/FixtureReport/report.xml
index acd7d96..c14090e 100644
--- a/Tools/Tests/Unit/Reports/Convertor/HtmlConvertorDriver/FixtureReport/report.xml
+++ b/Tools/Tests/Unit/Reports/Convertor/HtmlConvertorDriver/FixtureReport/report.xml
@@ -2,9 +2,9 @@
-
-
-
+
+
+
diff --git a/Tools/Tests/Unit/TestsGenerator/Params/XmlParamsDriver/GetValuesTest.php b/Tools/Tests/Unit/TestsGenerator/Params/XmlParamsDriver/GetValuesTest.php
index cfbf3bc..03955d3 100644
--- a/Tools/Tests/Unit/TestsGenerator/Params/XmlParamsDriver/GetValuesTest.php
+++ b/Tools/Tests/Unit/TestsGenerator/Params/XmlParamsDriver/GetValuesTest.php
@@ -73,12 +73,12 @@ public function testGetTestFilesPaths()
$generator = \Mockery::mock('\XSLTBenchmarking\TestsGenerator\XmlGenerator()');
$generator->shouldReceive('setDriver')->twice()->with('easy');
$generator->shouldReceive('generate')->once()->with(
- $this->setDirSep(__DIR__ . '/manyElements.xml'),
+ $this->setDirSep(__DIR__ . '/modify-element/manyElements.xml'),
__DIR__,
array('testName' => 20, 'testName2' => 3)
);
$generator->shouldReceive('generate')->once()->with(
- $this->setDirSep(__DIR__ . '/manyNewElements.xml'),
+ $this->setDirSep(__DIR__ . '/modify-element/manyNewElements.xml'),
__DIR__,
array('testNewName' => 20, 'testName2' => 3)
);
@@ -90,7 +90,7 @@ public function testGetTestFilesPaths()
array(
$this->setDirSep(__DIR__ . '/oneElement.xml') => $this->setDirSep(__DIR__ . '/oneNewElement.xml'),
$this->setDirSep(__DIR__ . '/twoElements.xml') => $this->setDirSep(__DIR__ . '/twoNewElements.xml'),
- $this->setDirSep(__DIR__ . '/manyElements.xml') => $this->setDirSep(__DIR__ . '/manyNewElements.xml'),
+ $this->setDirSep(__DIR__ . '/modify-element/manyElements.xml') => $this->setDirSep(__DIR__ . '/modify-element/manyNewElements.xml'),
),
$this->driver->getTestFilesPaths('Rename')
);
@@ -99,10 +99,12 @@ public function testGetTestFilesPaths()
array(
$this->setDirSep(__DIR__ . '/oneElement.xml') => $this->setDirSep(__DIR__ . '/zeroElement.xml'),
$this->setDirSep(__DIR__ . '/twoElements.xml') => $this->setDirSep(__DIR__ . '/zeroElement.xml'),
- $this->setDirSep(__DIR__ . '/manyElements.xml') => $this->setDirSep(__DIR__ . '/zeroElement.xml'),
+ $this->setDirSep(__DIR__ . '/modify-element/manyElements.xml') => $this->setDirSep(__DIR__ . '/zeroElement.xml'),
),
$this->driver->getTestFilesPaths('Remove')
);
+
+ rmdir($this->setDirSep(__DIR__ . '/modify-element'));
}
diff --git a/Tools/Tests/Unit/TestsRunner/Controlor/IsSameTest.php b/Tools/Tests/Unit/TestsRunner/Controlor/IsSameTest.php
index 287aba2..735eede 100644
--- a/Tools/Tests/Unit/TestsRunner/Controlor/IsSameTest.php
+++ b/Tools/Tests/Unit/TestsRunner/Controlor/IsSameTest.php
@@ -87,7 +87,7 @@ public function testPlainTextIsNotSame()
public function testXmlIsSame()
{
$file1 = $this->setDirSep(__DIR__ . '/file1.xml');
- $file2 = $this->setDirSep(__DIR__ . '/file2.txt');
+ $file2 = $this->setDirSep(__DIR__ . '/file2.xml');
$xml1 = '' . PHP_EOL .
' ' . PHP_EOL .
diff --git a/Tools/Tests/Unit/TestsRunner/Processors/Processor/RunTest.php b/Tools/Tests/Unit/TestsRunner/Processors/Processor/RunTest.php
index af32cf9..0d0a8d3 100644
--- a/Tools/Tests/Unit/TestsRunner/Processors/Processor/RunTest.php
+++ b/Tools/Tests/Unit/TestsRunner/Processors/Processor/RunTest.php
@@ -200,7 +200,7 @@ public function testError()
$filesAfter = scandir(__DIR__);
$this->assertEquals($filesBefore, $filesAfter);
- $this->assertEquals('Test error', $return);
+ $this->assertEquals('Output file was not be generated (output); Test error', $return);
}
@@ -208,8 +208,12 @@ public function testXmlAndXsltSeparately()
{
$this->markTestSkippedCondition();
+ $outputPath = $this->setDirSep(__DIR__ . '/output.xml');
+ $outputPath_1 = $this->setDirSep(__DIR__ . '/output-1.xml');
+ $outputPath_2 = $this->setDirSep(__DIR__ . '/output-2.xml');
+
$processorOK = $this->getMock('\XSLTBenchmarking\TestsRunner\AProcessorDriver', array('getCommandTemplate', 'getFullName', 'getKernel', 'isTemplateSetInInput', 'getBeforeCommandTemplate', 'getAfterCommandTemplate', 'isAvailable'), array(), '', FALSE);
- $processorOK->expects($this->once())->method('getCommandTemplate')->will($this->returnValue('php -r "sleep(1);"'));
+ $processorOK->expects($this->once())->method('getCommandTemplate')->will($this->returnValue('php -r "file_put_contents(\'' . $outputPath . '\', \'generated data\'); sleep(1);"'));
$processorOK->expects($this->never())->method('getFullName')->will($this->returnValue(''));
$processorOK->expects($this->never())->method('getKernel')->will($this->returnValue(''));
$processorOK->expects($this->once())->method('isTemplateSetInInput')->will($this->returnValue(FALSE));
@@ -218,7 +222,7 @@ public function testXmlAndXsltSeparately()
$processorOK->expects($this->never())->method('isAvailable')->will($this->returnValue(TRUE));
$processorError = $this->getMock('\XSLTBenchmarking\TestsRunner\AProcessorDriver', array('getCommandTemplate', 'getFullName', 'getKernel', 'isTemplateSetInInput', 'getBeforeCommandTemplate', 'getAfterCommandTemplate', 'isAvailable'), array(), '', FALSE);
- $processorError->expects($this->never())->method('getCommandTemplate')->will($this->returnValue('php -r "echo \'Test error\';" > [ERROR]'));
+ $processorError->expects($this->never())->method('getCommandTemplate')->will($this->returnValue('php -r "file_put_contents(\'' . $outputPath . '\', \'generated data\'); echo \'Test error\';" > [ERROR]'));
$processorError->expects($this->never())->method('getFullName')->will($this->returnValue(''));
$processorError->expects($this->never())->method('getKernel')->will($this->returnValue(''));
$processorError->expects($this->never())->method('isTemplateSetInInput')->will($this->returnValue(FALSE));
@@ -234,12 +238,22 @@ public function testXmlAndXsltSeparately()
$this->setPropertyValue($this->processor, 'available', $available);
$memoryUsage = $this->getMock('\XSLTBenchmarking\TestsRunner\MemoryUsage', array('run', 'get'), array(), '', FALSE);
- $memoryUsage->expects($this->exactly(3))->method('run')->with('php -r "sleep(1);"')->will($this->returnValue('php -r "sleep(1);"'));
+ $memoryUsage->expects($this->exactly(3))->method('run')
+ ->with(
+ $this->logicalOr(
+ $this->equalTo('php -r "file_put_contents(\'' . $outputPath . '\', \'generated data\'); sleep(1);"'),
+ $this->equalTo('php -r "file_put_contents(\'' . $outputPath_1 . '\', \'generated data\'); sleep(1);"'),
+ $this->equalTo('php -r "file_put_contents(\'' . $outputPath_2 . '\', \'generated data\'); sleep(1);"')
+ )
+ )
+ ->will($this->returnCallback(function ($command) {return $command;}));
$memoryUsage->expects($this->exactly(3))->method('get')->will($this->returnValue('123456789'));
$this->setPropertyValue($this->processor, 'memoryUsage', $memoryUsage);
$filesBefore = scandir(__DIR__);
- $return = $this->processor->run('processorOK', __FILE__, $this->setDirSep(__DIR__ . '/FixtureRun/input.xml'), 'output', 3);
+ $return = $this->processor->run('processorOK', __FILE__, $this->setDirSep(__DIR__ . '/FixtureRun/input.xml'), $outputPath, 3);
+ // remove generated file
+ unlink($outputPath);
$filesAfter = scandir(__DIR__);
$this->assertEquals($filesBefore, $filesAfter);
@@ -270,8 +284,12 @@ public function testXsltInXml()
{
$this->markTestSkippedCondition();
+ $outputPath = $this->setDirSep(__DIR__ . '/output.xml');
+ $outputPath_1 = $this->setDirSep(__DIR__ . '/output-1.xml');
+ $outputPath_2 = $this->setDirSep(__DIR__ . '/output-2.xml');
+
$processorOK = $this->getMock('\XSLTBenchmarking\TestsRunner\AProcessorDriver', array('getCommandTemplate', 'getFullName', 'getKernel', 'isTemplateSetInInput', 'getBeforeCommandTemplate', 'getAfterCommandTemplate', 'isAvailable'), array(), '', FALSE);
- $processorOK->expects($this->once())->method('getCommandTemplate')->will($this->returnValue('php -r "sleep(1);"'));
+ $processorOK->expects($this->once())->method('getCommandTemplate')->will($this->returnValue('php -r "file_put_contents(\'' . $outputPath . '\', \'generated data\'); sleep(1);"'));
$processorOK->expects($this->never())->method('getFullName')->will($this->returnValue(''));
$processorOK->expects($this->never())->method('getKernel')->will($this->returnValue(''));
$processorOK->expects($this->once())->method('isTemplateSetInInput')->will($this->returnValue(TRUE));
@@ -280,7 +298,7 @@ public function testXsltInXml()
$processorOK->expects($this->never())->method('isAvailable')->will($this->returnValue(TRUE));
$processorError = $this->getMock('\XSLTBenchmarking\TestsRunner\AProcessorDriver', array('getCommandTemplate', 'getFullName', 'getKernel', 'isTemplateSetInInput', 'getBeforeCommandTemplate', 'getAfterCommandTemplate', 'isAvailable'), array(), '', FALSE);
- $processorError->expects($this->never())->method('getCommandTemplate')->will($this->returnValue('php -r "echo \'Test error\';" > [ERROR]'));
+ $processorError->expects($this->never())->method('getCommandTemplate')->will($this->returnValue('php -r "file_put_contents(\'' . $outputPath . '\', \'generated data\'); echo \'Test error\';" > [ERROR]'));
$processorError->expects($this->never())->method('getFullName')->will($this->returnValue(''));
$processorError->expects($this->never())->method('getKernel')->will($this->returnValue(''));
$processorError->expects($this->never())->method('isTemplateSetInInput')->will($this->returnValue(TRUE));
@@ -296,12 +314,22 @@ public function testXsltInXml()
$this->setPropertyValue($this->processor, 'available', $available);
$memoryUsage = $this->getMock('\XSLTBenchmarking\TestsRunner\MemoryUsage', array('run', 'get'), array(), '', FALSE);
- $memoryUsage->expects($this->exactly(3))->method('run')->with('php -r "sleep(1);"')->will($this->returnValue('php -r "sleep(1);"'));
+ $memoryUsage->expects($this->exactly(3))->method('run')
+ ->with(
+ $this->logicalOr(
+ $this->equalTo('php -r "file_put_contents(\'' . $outputPath . '\', \'generated data\'); sleep(1);"'),
+ $this->equalTo('php -r "file_put_contents(\'' . $outputPath_1 . '\', \'generated data\'); sleep(1);"'),
+ $this->equalTo('php -r "file_put_contents(\'' . $outputPath_2 . '\', \'generated data\'); sleep(1);"')
+ )
+ )
+ ->will($this->returnCallback(function ($command) {return $command;}));
$memoryUsage->expects($this->exactly(3))->method('get')->will($this->returnValue('123456789'));
$this->setPropertyValue($this->processor, 'memoryUsage', $memoryUsage);
$filesBefore = scandir(__DIR__);
- $return = $this->processor->run('processorOK', __FILE__, $this->setDirSep(__DIR__ . '/FixtureRun/input.xml'), 'output', 3);
+ $return = $this->processor->run('processorOK', __FILE__, $this->setDirSep(__DIR__ . '/FixtureRun/input.xml'), $outputPath, 3);
+ // detele generated file
+ unlink($outputPath);
$filesAfter = scandir(__DIR__);
$this->assertNotEquals($filesBefore, $filesAfter);
@@ -333,6 +361,7 @@ public function testXsltInXml()
$this->assertTrue(is_array($returnMemory));
$this->assertEquals(3, count($returnMemory));
+
// all times are greated then one second
$this->assertGreaterOneSecondInMicrotime($returnTimes[0]);
$this->assertGreaterOneSecondInMicrotime($returnTimes[1]);
@@ -352,9 +381,13 @@ public function testBeforeAndAfterCommand()
$controleOutputPath = $this->setDirSep(__DIR__ . '/controleOutput');
file_put_contents($controleOutputPath, '');
+ $outputPath = $this->setDirSep(__DIR__ . '/output.xml');
+ $outputPath_1 = $this->setDirSep(__DIR__ . '/output-1.xml');
+ $outputPath_2 = $this->setDirSep(__DIR__ . '/output-2.xml');
+
$processorOK = $this->getMock('\XSLTBenchmarking\TestsRunner\AProcessorDriver', array('getCommandTemplate', 'getFullName', 'getKernel', 'isTemplateSetInInput', 'getBeforeCommandTemplate', 'getAfterCommandTemplate', 'isAvailable'), array(), '', FALSE);
$processorOK->expects($this->once())->method('getCommandTemplate')->will($this->returnValue(
- 'php -r "file_put_contents(\'' . $controleOutputPath . '\', file_get_contents(\'' . $controleOutputPath . '\') . \'Test command;\');"'
+ 'php -r "file_put_contents(\'' . $controleOutputPath . '\', file_get_contents(\'' . $controleOutputPath . '\') . \'Test command;\'); file_put_contents(\'[OUTPUT]\', \'generated output\');"'
));
$processorOK->expects($this->never())->method('getFullName')->will($this->returnValue(''));
$processorOK->expects($this->never())->method('getKernel')->will($this->returnValue(''));
@@ -384,13 +417,26 @@ public function testBeforeAndAfterCommand()
$this->setPropertyValue($this->processor, 'available', $available);
$memoryUsage = $this->getMock('\XSLTBenchmarking\TestsRunner\MemoryUsage', array('run', 'get'), array(), '', FALSE);
+
$memoryUsage->expects($this->exactly(3))->method('run')
- ->with('php -r "file_put_contents(\'' . $controleOutputPath . '\', file_get_contents(\'' . $controleOutputPath . '\') . \'Test command;\');"')
- ->will($this->returnValue('php -r "file_put_contents(\'' . $controleOutputPath . '\', file_get_contents(\'' . $controleOutputPath . '\') . \'Test command;\');"'));
+ ->with(
+ $this->logicalOr(
+ $this->equalTo('php -r "file_put_contents(\'' . $controleOutputPath . '\', file_get_contents(\'' . $controleOutputPath . '\') . \'Test command;\'); file_put_contents(\'' . $outputPath . '\', \'generated output\');"'),
+ $this->equalTo('php -r "file_put_contents(\'' . $controleOutputPath . '\', file_get_contents(\'' . $controleOutputPath . '\') . \'Test command;\'); file_put_contents(\'' . $outputPath_1 . '\', \'generated output\');"'),
+ $this->equalTo('php -r "file_put_contents(\'' . $controleOutputPath . '\', file_get_contents(\'' . $controleOutputPath . '\') . \'Test command;\'); file_put_contents(\'' . $outputPath_2 . '\', \'generated output\');"')
+ )
+ )
+ ->will($this->returnCallback(function ($command) {return $command;}));
$memoryUsage->expects($this->exactly(3))->method('get')->will($this->returnValue('123456789'));
$this->setPropertyValue($this->processor, 'memoryUsage', $memoryUsage);
- $return = $this->processor->run('processorOK', __FILE__, $this->setDirSep(__DIR__ . '/FixtureRun/input.xml'), 'output', 3);
+ $return = $this->processor->run(
+ 'processorOK',
+ __FILE__,
+ $this->setDirSep(__DIR__ . '/FixtureRun/input.xml'),
+ $this->setDirSep(__DIR__ . '/output.xml'),
+ 3
+ );
$this->assertStringEqualsFile($controleOutputPath,
'Test of before command;Test command;Test of after command;' .
@@ -399,6 +445,7 @@ public function testBeforeAndAfterCommand()
);
unlink($controleOutputPath);
+ unlink($outputPath);
}
diff --git a/XSLTBenchmarking/TestsGenerator/Templating/SmartyTemplatingDriver.php b/XSLTBenchmarking/TestsGenerator/Templating/SmartyTemplatingDriver.php
index 2cad084..42d1f50 100644
--- a/XSLTBenchmarking/TestsGenerator/Templating/SmartyTemplatingDriver.php
+++ b/XSLTBenchmarking/TestsGenerator/Templating/SmartyTemplatingDriver.php
@@ -70,7 +70,7 @@ public function generate($templatePath, $outputPath, array $settings)
try {
$this->display($templatePath);
} catch (\Exception $e) {
- throw new \XSLTBenchmarking\GenerateTemplateException('Cannot generate template by Smarty Driver', 0, $e);
+ throw new \XSLTBenchmarking\GenerateTemplateException('Cannot generate template by Smarty Driver (' . $e->getMessage() . ')', 0, $e);
}
$content = ob_get_clean();