Skip to content

Commit 7e8cc14

Browse files
committed
Merge pull request #23 from paul999/ticket/22
First start for issue #22, removed progress bar and everything related t...
2 parents 36199ef + 50a1545 commit 7e8cc14

14 files changed

Lines changed: 24 additions & 268 deletions

src/Events/php_exporter.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ public function get_event_name($event_line, $is_dispatch)
196196

197197
if (isset($match[2]))
198198
{
199-
$this->output->inMaxPogress(1);
200199
$this->output->addMessage(Output::ERROR, sprintf('Event names should be all lowercase in %s for event %s', $this->current_file, $match[2]));
201200
}
202201
else

src/Files/FileLoader.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ public function loadFile($fileName)
6363
// Otherwise add notice.
6464
if (strtolower($fileName) !== 'readme')
6565
{
66-
$this->output->addMessage(Output::NOTICE, sprintf("The file %s has no valid extension.", basename($fileName)), null, true);
67-
}
68-
else
69-
{
70-
$this->output->printErrorLevel();
66+
$this->output->addMessage(Output::NOTICE, sprintf("The file %s has no valid extension.", basename($fileName)));
7167
}
7268
$file = new PlainFile($this->debug, $fileName);
7369
}
@@ -94,7 +90,7 @@ public function loadFile($fileName)
9490
else if ($size >= 4) // Files with 3 ore more dots should not happen.
9591
{
9692
$error = true;
97-
$this->output->addMessage(Output::ERROR, sprintf("File (%s) seems to have too many dots. Using the last part as extension.", $fileName), null, true);
93+
$this->output->addMessage(Output::ERROR, sprintf("File (%s) seems to have too many dots. Using the last part as extension.", $fileName));
9894

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

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

199195
case 'swf':
200-
$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);
196+
$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)));
201197

202198
return new BinaryFile($this->debug, $fileName);
203199
case 'ds_store':
204-
$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);
200+
$this->output->addMessage(Output::ERROR, sprintf("Found an OS X specific file at %s, please make sure to remove it prior to submission.", $fileName));
205201

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

src/Output/Output.php

Lines changed: 12 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,9 @@ public function writelnIfDebug($message)
160160
* @param $type int message type
161161
* @param $message string message
162162
* @param \Phpbb\Epv\Files\FileInterface $file File the error happened in. When provided, this is displayed to the user
163-
* @param bool $skipError skip the printErrorLevel call (Default false)
164163
*/
165-
public function addMessage($type, $message, FileInterface $file = null, $skipError = false)
164+
public function addMessage($type, $message, FileInterface $file = null)
166165
{
167-
if (!$skipError)
168-
{
169-
$this->printErrorLevel($type);
170-
}
171166
switch ($type)
172167
{
173168
case Output::FATAL:
@@ -224,68 +219,16 @@ public function getFatalCount()
224219
*/
225220
public function getMessageCount($type)
226221
{
227-
switch ($type)
228-
{
229-
case Output::FATAL:
230-
return $this->fatal;
231-
case Output::ERROR:
232-
return $this->error;
233-
case Output::WARNING:
234-
return $this->warning;
235-
case Output::NOTICE:
236-
return $this->notice;
237-
}
238-
}
239-
/**
240-
* @param int $maxProgress
241-
*/
242-
public function setMaxProgress($maxProgress)
243-
{
244-
$this->maxProgress = $maxProgress;
245-
}
246-
247-
/**
248-
* Increase the max progress during the run.
249-
*
250-
* @param $inc
251-
*/
252-
public function inMaxPogress($inc)
253-
{
254-
$this->setMaxProgress($this->maxProgress + $inc);
255-
}
256-
257-
/**
258-
* @param $result the result of this specific test.
259-
*/
260-
public function printErrorLevel($result = null)
261-
{
262-
if ($result == Output::FATAL)
263-
{
264-
$this->output->write("<fatal>F</fatal>");
265-
}
266-
else if ($result == Output::ERROR)
267-
{
268-
$this->output->write("<error>E</error>");
269-
}
270-
else if ($result == Output::WARNING)
271-
{
272-
$this->output->write("<warning>W</warning>");
273-
}
274-
else if ($result == Output::NOTICE)
275-
{
276-
$this->output->write("<notice>N</notice>");
277-
}
278-
else
279-
{
280-
$this->output->write(".");
281-
}
282-
$this->progress++;
283-
284-
if ($this->progress % 85 == 0)
285-
{
286-
$this->output->write(' ' . sprintf('%' . strlen($this->maxProgress) . 's', $this->progress));
287-
$this->output->write(' / ' . $this->maxProgress);
288-
$this->output->writeln(' (' . sprintf('%3s', floor(100 * ($this->progress / $this->maxProgress))) . '%)');
289-
}
222+
switch ($type)
223+
{
224+
case Output::FATAL:
225+
return $this->fatal;
226+
case Output::ERROR:
227+
return $this->error;
228+
case Output::WARNING:
229+
return $this->warning;
230+
case Output::NOTICE:
231+
return $this->notice;
232+
}
290233
}
291234
}

src/Output/OutputInterface.php

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ public function writelnIfDebug($message);
3434
* @param $type int message type
3535
* @param $message string message
3636
* @param \Phpbb\Epv\Files\FileInterface $file File the error happened in. When provided, this is displayed to the user
37-
* @param bool $skipError
3837
* @return
3938
*/
40-
public function addMessage($type, $message, FileInterface $file = null, $skipError = false);
39+
public function addMessage($type, $message, FileInterface $file = null);
4140

4241
/**
4342
* Get all messages saved into the message queue.
@@ -57,26 +56,4 @@ public function getFatalCount();
5756
* @return mixed
5857
*/
5958
public function getMessageCount($type);
60-
61-
/**
62-
* Set the max progress (Number of tests) for this run.
63-
*
64-
*
65-
* @param $maxProgress int
66-
*/
67-
public function setMaxProgress($maxProgress);
68-
69-
/**
70-
* Increase the max progress during the run.
71-
*
72-
* @param $inc
73-
*/
74-
public function inMaxPogress($inc);
75-
76-
/**
77-
* Print the status of this specific test.
78-
*
79-
* @param $result The result for this specific test.
80-
*/
81-
public function printErrorLevel($result = null);
8259
}

src/Tests/BaseTest.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ abstract class BaseTest implements TestInterface
2525
/** @var \Phpbb\Epv\Files\FileInterface * */
2626
protected $file;
2727

28-
protected $totalLineTests = 0;
29-
protected $totalFileTests = 0;
30-
protected $totalDirectoryTests = 0;
31-
3228
/**
3329
* If this is set to true, tests are run on full directory listings.
3430
* @var bool
@@ -121,30 +117,6 @@ public function doValidateDirectory()
121117
return $this->directory;
122118
}
123119

124-
/**
125-
* @return mixed
126-
*/
127-
public function getTotalDirectoryTests()
128-
{
129-
return $this->totalDirectoryTests;
130-
}
131-
132-
/**
133-
* @return mixed
134-
*/
135-
public function getTotalFileTests()
136-
{
137-
return $this->totalFileTests;
138-
}
139-
140-
/**
141-
* @return mixed
142-
*/
143-
public function getTotalLineTests()
144-
{
145-
return $this->totalLineTests;
146-
}
147-
148120
/**
149121
* Convert a boolean to Yes or No.
150122
*

src/Tests/TestInterface.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,4 @@ public function doValidateFile($type);
6565
*/
6666
public function testName();
6767

68-
/**
69-
* @return int
70-
*/
71-
public function getTotalDirectoryTests();
72-
73-
/**
74-
* @return int
75-
*/
76-
public function getTotalFileTests();
77-
78-
/**
79-
* @return int
80-
*/
81-
public function getTotalLineTests();
8268
}

src/Tests/TestRunner.php

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Phpbb\Epv\Tests;
1111

1212

13+
use Phpbb\Epv\Files\FileInterface;
1314
use Phpbb\Epv\Files\FileLoader;
1415
use Phpbb\Epv\Files\Line;
1516
use Phpbb\Epv\Output\Output;
@@ -65,42 +66,9 @@ public function runTests()
6566
}
6667
$this->output->writeln("Running tests.");
6768

68-
// We start with calculating the total number of tests we are doing.
69-
$maxProgress = 0;
70-
71-
foreach ($this->tests as $test)
72-
{
73-
/** @var \Phpbb\Epv\Tests\TestInterface $test */
74-
if ($test->doValidateDirectory())
75-
{
76-
$maxProgress += ($test->getTotalDirectoryTests());
77-
}
78-
}
79-
80-
foreach ($this->files as $file)
81-
{
82-
/** @var \Phpbb\Epv\Files\FileInterface $file */
83-
// Get the number of lines;
84-
$lines = sizeof($file->getLines());
85-
86-
foreach ($this->tests as $test)
87-
{
88-
/** @var \Phpbb\Epv\Tests\TestInterface $test */
89-
if ($test->doValidateFile($file->getFileType()))
90-
{
91-
$maxProgress += ($test->getTotalFileTests());
92-
}
93-
if ($test->doValidateLine($file->getFileType()))
94-
{
95-
$maxProgress += ($test->getTotalLineTests() * $lines);
96-
}
97-
}
98-
}
99-
100-
$this->output->setMaxProgress($maxProgress);
101-
10269
// Now, we basicly do the same as above, but we do really run the tests.
10370
// All other tests are specific to files.
71+
/** @var \Phpbb\Epv\Tests\TestInterface $test */
10472
foreach ($this->tests as $test)
10573
{
10674
if ($test->doValidateDirectory())
@@ -113,10 +81,12 @@ public function runTests()
11381
// And over the tests that are available.
11482
// First do the full file check.
11583
// After that loop over each line and test per line.
84+
/** @var FileInterface $file */
11685
foreach ($this->files as $file)
11786
{
11887
$linetest = array();
11988

89+
/** @var \Phpbb\Epv\Tests\TestInterface $test */
12090
foreach ($this->tests as $test)
12191
{
12292
if ($test->doValidateFile($file->getFileType()))

src/Tests/TestStartup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class TestStartup
3636
* @param $type int Type what the location is
3737
* @param $location string Location where the extension is
3838
* @param $debug boolean if debug is enabled
39-
* @param string $branch When using GIT and GITHUB you can provide a brachname. When empty, defaults to master
39+
* @param string $branch When using GIT and GITHUB you can provide a branch name. When empty, defaults to master
4040
*/
4141
public function __construct(OutputInterface $output, $type, $location, $debug, $branch = '')
4242
{

src/Tests/Tests/epv_test_validate_composer.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public function __construct($debug, OutputInterface $output, $basedir, $namespac
2525
parent::__construct($debug, $output, $basedir, $namespace, $titania);
2626

2727
$this->fileTypeFull = Type::TYPE_COMPOSER;
28-
$this->totalFileTests = 2;
2928
}
3029

3130
/**
@@ -61,10 +60,6 @@ private function addMessageIfBooleanTrue($addMessage, $type, $message)
6160
{
6261
$this->output->addMessage($type, $message, $this->file);
6362
}
64-
else
65-
{
66-
$this->output->printErrorLevel();
67-
}
6863
}
6964

7065
public function testName()

src/Tests/Tests/epv_test_validate_directory_structure.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Phpbb\Epv\Tests\BaseTest;
1515

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

2019
public function __construct($debug, OutputInterface $output, $basedir, $namespace, $titania)
@@ -26,7 +25,7 @@ public function __construct($debug, OutputInterface $output, $basedir, $namespac
2625
if (!$titania)
2726
{
2827
$ns = ''; // Skip checking full directory structure on EPV.
29-
$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);
28+
$this->output->addMessage(Output::NOTICE, "Important: The full directory structure is not tested. See the extension validation guidelines for the full directory structure.");
3029
}
3130
else
3231
{
@@ -37,8 +36,6 @@ public function __construct($debug, OutputInterface $output, $basedir, $namespac
3736
'license.txt' => Output::ERROR,
3837
$ns . 'composer.json' => Output::FATAL,
3938
);
40-
41-
$this->totalDirectoryTests = sizeof($this->requiredFiles);
4239
}
4340

4441
public function validateDirectory(array $dirList)
@@ -77,10 +74,6 @@ public function validateDirectory(array $dirList)
7774
$this->output->addMessage($type, sprintf("The required file %s is missing from the extension package.", $file));
7875
}
7976
}
80-
else
81-
{
82-
$this->output->printErrorLevel();
83-
}
8477
}
8578
}
8679

0 commit comments

Comments
 (0)