Commit a34eda07 authored by Hermann Mayer's avatar Hermann Mayer
Browse files

Cleaned the style glitches, improved the tests.

parent 8e2f9e28
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -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
                ))
            )
        ;
            );
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -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');
+36 −5
Original line number Diff line number Diff line
@@ -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";
    }
+29 −0
Original line number Diff line number Diff line
@@ -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());
    }

    /**
+3 −1
Original line number Diff line number Diff line
@@ -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>
Loading