Commit a34eda07 authored by Hermann Mayer's avatar Hermann Mayer

Cleaned the style glitches, improved the tests.

parent 8e2f9e28
......@@ -68,7 +68,7 @@ class TagGenerator
*/
public function setFormater(FormaterInterface $formater)
{
$this->_formater[] = $formater;
$this->_formater = $formater;
return $this;
}
......@@ -85,7 +85,7 @@ class TagGenerator
*/
public function setSplitter(SplitterInterface $splitter)
{
$this->_splitter[] = $splitter;
$this->_splitter = $splitter;
return $this;
}
......@@ -256,8 +256,7 @@ class TagGenerator
new ScoreGroup(1, true, array(
'max' => 3
))
)
;
);
}
}
......@@ -93,8 +93,7 @@ This is a simple example how to use the TagGenerator.
->addFilter(new Camelcase(15))
/* Score capitalized words */
->addFilter(new Capitalized(5))
;
->addFilter(new Capitalized(5));
// Receive the collection of tags
$tags = $generator->getTags('Lorem ipsum etc');
......
......@@ -13,6 +13,7 @@ namespace Jity\TagGeneratorBundle\Tests;
use Jity\TagGeneratorBundle\Tests\JityTestCase,
Jity\TagGeneratorBundle\DependencyInjection\TagGenerator,
Jity\TagGeneratorBundle\Entity\TagCollection,
Jity\TagGeneratorBundle\Filter\Score,
Jity\TagGeneratorBundle\Filter\ScoreGroup,
Jity\TagGeneratorBundle\Filter\Length,
......@@ -21,7 +22,9 @@ use Jity\TagGeneratorBundle\Tests\JityTestCase,
Jity\TagGeneratorBundle\Filter\Capitalized,
Jity\TagGeneratorBundle\Filter\Uppercase,
Jity\TagGeneratorBundle\Filter\Camelcase,
Jity\TagGeneratorBundle\Filter\Regex;
Jity\TagGeneratorBundle\Filter\Regex,
Jity\TagGeneratorBundle\Formater\SimpleFormater,
Jity\TagGeneratorBundle\Splitter\SimpleSplitter;
/**
* TagGeneratorTest
......@@ -129,12 +132,36 @@ class TagGeneratorTest extends JityTestCase
new ScoreGroup(1, true, array(
'max' => 3
))
)
;
);
$this->generator = $generator;
}
/**
* testGenerator
*
* @access public
* @return void
*/
public function testGenerator()
{
$formater = new SimpleFormater();
$splitter = new SimpleSplitter();
$generator = new TagGenerator();
$generator
->setFormater($formater)
->setSplitter($splitter);
$collection = new TagCollection(array(
'tag' => 1
));
$tags = $generator->filter($collection);
$this->assertEquals($tags, $collection);
}
/**
* testIntegration
*
......@@ -157,6 +184,8 @@ class TagGeneratorTest extends JityTestCase
// Receive the collection of tags
$tags = $this->generator->getTags($text);
$this->assertEquals($text, $tags->getSource());
foreach ($tags as $tag) {
$output[] = $tag->getName();
$debug[] = $tag->getScore() . ' - ' . $tag->getName();
......@@ -167,8 +196,6 @@ class TagGeneratorTest extends JityTestCase
krsort($debug);
krsort($output);
// var_dump($debug);
if ('Bash als Power-Shell und Vim als IDE.md' === basename($file)) {
if (false === in_array('IDE', $output)) {
......@@ -198,6 +225,10 @@ class TagGeneratorTest extends JityTestCase
}
}
// Test the useless path of the filter
$scoreGroup = new ScoreGroup(1, false);
$this->assertEquals($tags, $scoreGroup->process($tags));
$time = (microtime(true) - $start);
echo "\n[Stat: Integration Test took " . number_format($time, 15) . 's for parsing ' . $count . " files]\n";
}
......
......@@ -50,6 +50,32 @@ class DictionaryTest extends JityTestCase
$this->fail('Error: [' . $tag . '] should not be found in dictionary. Seems to be a Bug.');
}
/**
* testConfigure
*
* @access public
* @return void
*/
public function testConfigure()
{
try {
$filter = new Dictionary(10, false, array(
'match' => true,
'casesensitive' => false,
'dictionaries' => array(
'doesNotExist' => array(
'nothing'
)
)
));
} catch (\Exception $e) {
$this->assertEquals('Dictionary "nothing" was not found.', $e->getMessage());
}
}
/**
* testSoftProcess
*
......@@ -84,6 +110,9 @@ class DictionaryTest extends JityTestCase
$this->assertEquals('1', $tag->getScore());
}
}
$result[0]->setName('New');
$this->assertEquals('New', $result[0]->getName());
}
/**
......
......@@ -68,7 +68,7 @@
<target name="phpmd-ci" description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
<exec executable="phpmd">
<arg line="
${basedir} xml codesize,unusedcode,naming,design --reportfile ${output}/logs/pmd.xml --exclude Tests/
${basedir} xml codesize,unusedcode,naming,design --reportfile ${output}/logs/pmd.xml --exclude ./Tests
" />
</exec>
</target>
......@@ -89,6 +89,8 @@
<exec executable="phpcpd">
<arg value="--log-pmd" />
<arg value="${output}/logs/pmd-cpd.xml" />
<arg value="--exclude" />
<arg value="Tests" />
<arg path="${basedir}" />
</exec>
</target>
......
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./Tests/TestInit.php"
>
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./Tests/TestInit.php" >
<testsuites>
<testsuite name="Jity Tag-Generator Test Suite">
<directory>./Tests/</directory>
......@@ -21,5 +21,20 @@
<group>performance</group>
</exclude>
</groups>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./</directory>
<exclude>
<directory suffix=".php">./Tests</directory>
<directory suffix=".php">./Resources</directory>
<directory suffix=".php">./build</directory>
<file>./JityTagGeneratorBundle.php</file>
<file>./DependencyInjection/Configuration.php</file>
<file>./DependencyInjection/JityTagGeneratorExtension.php</file>
</exclude>
</whitelist>
</filter>
</phpunit>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment