fixing configuration test generator after PHP refactoring

This commit is contained in:
El RIDO 2019-07-08 19:56:05 +02:00
parent 07018e5876
commit 1e2014b9fa
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92

View file

@ -387,7 +387,7 @@ class ConfigurationTestGenerator
}
}
$code .= $this->_getFunction(
ucfirst($step), $key, $options, $preCode, $testCode
ucfirst($step), $key, $options, $preCode, $testCode, $fullOptions['main']['discussion']
);
}
}
@ -408,10 +408,11 @@ class ConfigurationTestGenerator
* DO NOT EDIT: This file is generated automatically using configGenerator.php
*/
use PrivateBin\PrivateBin;
use PrivateBin\Controller;
use PrivateBin\Data\Filesystem;
use PrivateBin\Persistence\ServerSalt;
use PrivateBin\Persistence\TrafficLimiter;
use PrivateBin\Request;
class ConfigurationCombinationsTest extends PHPUnit_Framework_TestCase
{
@ -467,7 +468,7 @@ EOT;
* @param array $testCode
* @return string
*/
private function _getFunction($step, $key, &$options, $preCode, $testCode)
private function _getFunction($step, $key, &$options, $preCode, $testCode, $discussionEnabled)
{
if (count($testCode) == 0) {
echo "skipping creation of test$step$key, no valid tests found for configuration: $options" . PHP_EOL;
@ -495,8 +496,21 @@ EOT;
// step specific initialization
switch ($step) {
case 'Create':
if ($discussionEnabled) {
$code .= PHP_EOL . <<<'EOT'
$_POST = Helper::getPaste();
$paste = Helper::getPasteJson();
EOT;
} else {
$code .= PHP_EOL . <<<'EOT'
$paste = json_decode(Helper::getPasteJson(), true);
$paste['adata'][2] = 0;
$paste = json_encode($paste);
EOT;
}
$code .= PHP_EOL . <<<'EOT'
$file = tempnam(sys_get_temp_dir(), 'FOO');
file_put_contents($file, $paste);
Request::setInputStream($file);
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
$_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1';
@ -525,7 +539,7 @@ EOT;
$code .= PHP_EOL . $preString;
$code .= <<<'EOT'
ob_start();
new PrivateBin;
new Controller;
$content = ob_get_contents();
ob_end_clean();
EOT;