Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Events/php_exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ public function get_event_name($event_line, $is_dispatch)

if (isset($match[2]))
{
$this->output->inMaxPogress(1);
$this->output->addMessage(Output::ERROR, sprintf('Event names should be all lowercase in %s for event %s', $this->current_file, $match[2]));
}
else
Expand Down
12 changes: 4 additions & 8 deletions src/Files/FileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ public function loadFile($fileName)
// Otherwise add notice.
if (strtolower($fileName) !== 'readme')
{
$this->output->addMessage(Output::NOTICE, sprintf("The file %s has no valid extension.", basename($fileName)), null, true);
}
else
{
$this->output->printErrorLevel();
$this->output->addMessage(Output::NOTICE, sprintf("The file %s has no valid extension.", basename($fileName)));
}
$file = new PlainFile($this->debug, $fileName);
}
Expand All @@ -94,7 +90,7 @@ public function loadFile($fileName)
else if ($size >= 4) // Files with 3 ore more dots should not happen.
{
$error = true;
$this->output->addMessage(Output::ERROR, sprintf("File (%s) seems to have too many dots. Using the last part as extension.", $fileName), null, true);
$this->output->addMessage(Output::ERROR, sprintf("File (%s) seems to have too many dots. Using the last part as extension.", $fileName));

$file = self::tryLoadFile($fileName, $split[sizeof($split) - 1]);

Expand Down Expand Up @@ -197,11 +193,11 @@ private function tryLoadFile($fileName, $extension, $returnNull = false)
return new ImageFile($this->debug, $fileName);

case 'swf':
$this->output->addMessage(Output::NOTICE, sprintf("Found an SWF file (%s), please make sure to include the source files for it, as required by the GPL.", basename($fileName)), null, true);
$this->output->addMessage(Output::NOTICE, sprintf("Found an SWF file (%s), please make sure to include the source files for it, as required by the GPL.", basename($fileName)));

return new BinaryFile($this->debug, $fileName);
case 'ds_store':
$this->output->addMessage(Output::ERROR, sprintf("Found an OS X specific file at %s, please make sure to remove it prior to submission.", $fileName), null, true);
$this->output->addMessage(Output::ERROR, sprintf("Found an OS X specific file at %s, please make sure to remove it prior to submission.", $fileName));

return new BinaryFile($this->debug, $fileName);

Expand Down
81 changes: 12 additions & 69 deletions src/Output/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,9 @@ public function writelnIfDebug($message)
* @param $type int message type
* @param $message string message
* @param \Phpbb\Epv\Files\FileInterface $file File the error happened in. When provided, this is displayed to the user
* @param bool $skipError skip the printErrorLevel call (Default false)
*/
public function addMessage($type, $message, FileInterface $file = null, $skipError = false)
public function addMessage($type, $message, FileInterface $file = null)
{
if (!$skipError)
{
$this->printErrorLevel($type);
}
switch ($type)
{
case Output::FATAL:
Expand Down Expand Up @@ -224,68 +219,16 @@ public function getFatalCount()
*/
public function getMessageCount($type)
{
switch ($type)
{
case Output::FATAL:
return $this->fatal;
case Output::ERROR:
return $this->error;
case Output::WARNING:
return $this->warning;
case Output::NOTICE:
return $this->notice;
}
}
/**
* @param int $maxProgress
*/
public function setMaxProgress($maxProgress)
{
$this->maxProgress = $maxProgress;
}

/**
* Increase the max progress during the run.
*
* @param $inc
*/
public function inMaxPogress($inc)
{
$this->setMaxProgress($this->maxProgress + $inc);
}

/**
* @param $result the result of this specific test.
*/
public function printErrorLevel($result = null)
{
if ($result == Output::FATAL)
{
$this->output->write("<fatal>F</fatal>");
}
else if ($result == Output::ERROR)
{
$this->output->write("<error>E</error>");
}
else if ($result == Output::WARNING)
{
$this->output->write("<warning>W</warning>");
}
else if ($result == Output::NOTICE)
{
$this->output->write("<notice>N</notice>");
}
else
{
$this->output->write(".");
}
$this->progress++;

if ($this->progress % 85 == 0)
{
$this->output->write(' ' . sprintf('%' . strlen($this->maxProgress) . 's', $this->progress));
$this->output->write(' / ' . $this->maxProgress);
$this->output->writeln(' (' . sprintf('%3s', floor(100 * ($this->progress / $this->maxProgress))) . '%)');
}
switch ($type)
{
case Output::FATAL:
return $this->fatal;
case Output::ERROR:
return $this->error;
case Output::WARNING:
return $this->warning;
case Output::NOTICE:
return $this->notice;
}
}
}
25 changes: 1 addition & 24 deletions src/Output/OutputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ public function writelnIfDebug($message);
* @param $type int message type
* @param $message string message
* @param \Phpbb\Epv\Files\FileInterface $file File the error happened in. When provided, this is displayed to the user
* @param bool $skipError
* @return
*/
public function addMessage($type, $message, FileInterface $file = null, $skipError = false);
public function addMessage($type, $message, FileInterface $file = null);

/**
* Get all messages saved into the message queue.
Expand All @@ -57,26 +56,4 @@ public function getFatalCount();
* @return mixed
*/
public function getMessageCount($type);

/**
* Set the max progress (Number of tests) for this run.
*
*
* @param $maxProgress int
*/
public function setMaxProgress($maxProgress);

/**
* Increase the max progress during the run.
*
* @param $inc
*/
public function inMaxPogress($inc);

/**
* Print the status of this specific test.
*
* @param $result The result for this specific test.
*/
public function printErrorLevel($result = null);
}
28 changes: 0 additions & 28 deletions src/Tests/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ abstract class BaseTest implements TestInterface
/** @var \Phpbb\Epv\Files\FileInterface * */
protected $file;

protected $totalLineTests = 0;
protected $totalFileTests = 0;
protected $totalDirectoryTests = 0;

/**
* If this is set to true, tests are run on full directory listings.
* @var bool
Expand Down Expand Up @@ -121,30 +117,6 @@ public function doValidateDirectory()
return $this->directory;
}

/**
* @return mixed
*/
public function getTotalDirectoryTests()
{
return $this->totalDirectoryTests;
}

/**
* @return mixed
*/
public function getTotalFileTests()
{
return $this->totalFileTests;
}

/**
* @return mixed
*/
public function getTotalLineTests()
{
return $this->totalLineTests;
}

/**
* Convert a boolean to Yes or No.
*
Expand Down
14 changes: 0 additions & 14 deletions src/Tests/TestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,4 @@ public function doValidateFile($type);
*/
public function testName();

/**
* @return int
*/
public function getTotalDirectoryTests();

/**
* @return int
*/
public function getTotalFileTests();

/**
* @return int
*/
public function getTotalLineTests();
}
38 changes: 4 additions & 34 deletions src/Tests/TestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Phpbb\Epv\Tests;


use Phpbb\Epv\Files\FileInterface;
use Phpbb\Epv\Files\FileLoader;
use Phpbb\Epv\Files\Line;
use Phpbb\Epv\Output\Output;
Expand Down Expand Up @@ -65,42 +66,9 @@ public function runTests()
}
$this->output->writeln("Running tests.");

// We start with calculating the total number of tests we are doing.
$maxProgress = 0;

foreach ($this->tests as $test)
{
/** @var \Phpbb\Epv\Tests\TestInterface $test */
if ($test->doValidateDirectory())
{
$maxProgress += ($test->getTotalDirectoryTests());
}
}

foreach ($this->files as $file)
{
/** @var \Phpbb\Epv\Files\FileInterface $file */
// Get the number of lines;
$lines = sizeof($file->getLines());

foreach ($this->tests as $test)
{
/** @var \Phpbb\Epv\Tests\TestInterface $test */
if ($test->doValidateFile($file->getFileType()))
{
$maxProgress += ($test->getTotalFileTests());
}
if ($test->doValidateLine($file->getFileType()))
{
$maxProgress += ($test->getTotalLineTests() * $lines);
}
}
}

$this->output->setMaxProgress($maxProgress);

// Now, we basicly do the same as above, but we do really run the tests.
// All other tests are specific to files.
/** @var \Phpbb\Epv\Tests\TestInterface $test */
foreach ($this->tests as $test)
{
if ($test->doValidateDirectory())
Expand All @@ -113,10 +81,12 @@ public function runTests()
// And over the tests that are available.
// First do the full file check.
// After that loop over each line and test per line.
/** @var FileInterface $file */
foreach ($this->files as $file)
{
$linetest = array();

/** @var \Phpbb\Epv\Tests\TestInterface $test */
foreach ($this->tests as $test)
{
if ($test->doValidateFile($file->getFileType()))
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/TestStartup.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TestStartup
* @param $type int Type what the location is
* @param $location string Location where the extension is
* @param $debug boolean if debug is enabled
* @param string $branch When using GIT and GITHUB you can provide a brachname. When empty, defaults to master
* @param string $branch When using GIT and GITHUB you can provide a branch name. When empty, defaults to master
*/
public function __construct(OutputInterface $output, $type, $location, $debug, $branch = '')
{
Expand Down
5 changes: 0 additions & 5 deletions src/Tests/Tests/epv_test_validate_composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public function __construct($debug, OutputInterface $output, $basedir, $namespac
parent::__construct($debug, $output, $basedir, $namespace, $titania);

$this->fileTypeFull = Type::TYPE_COMPOSER;
$this->totalFileTests = 2;
}

/**
Expand Down Expand Up @@ -61,10 +60,6 @@ private function addMessageIfBooleanTrue($addMessage, $type, $message)
{
$this->output->addMessage($type, $message, $this->file);
}
else
{
$this->output->printErrorLevel();
}
}

public function testName()
Expand Down
9 changes: 1 addition & 8 deletions src/Tests/Tests/epv_test_validate_directory_structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Phpbb\Epv\Tests\BaseTest;

class epv_test_validate_directory_structure extends BaseTest{
// $this->totalDirectoryTests is sizeof this.
private $requiredFiles;

public function __construct($debug, OutputInterface $output, $basedir, $namespace, $titania)
Expand All @@ -26,7 +25,7 @@ public function __construct($debug, OutputInterface $output, $basedir, $namespac
if (!$titania)
{
$ns = ''; // Skip checking full directory structure on EPV.
$this->output->addMessage(Output::NOTICE, "Important: The full directory structure is not tested. See the extension validation guidelines for the full directory structure.", null, true);
$this->output->addMessage(Output::NOTICE, "Important: The full directory structure is not tested. See the extension validation guidelines for the full directory structure.");
}
else
{
Expand All @@ -37,8 +36,6 @@ public function __construct($debug, OutputInterface $output, $basedir, $namespac
'license.txt' => Output::ERROR,
$ns . 'composer.json' => Output::FATAL,
);

$this->totalDirectoryTests = sizeof($this->requiredFiles);
}

public function validateDirectory(array $dirList)
Expand Down Expand Up @@ -77,10 +74,6 @@ public function validateDirectory(array $dirList)
$this->output->addMessage($type, sprintf("The required file %s is missing from the extension package.", $file));
}
}
else
{
$this->output->printErrorLevel();
}
}
}

Expand Down
Loading