From c5d0db8b71a8c1bb6b5c08763b44e14b4f876d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 8 Dec 2015 08:57:19 +0100 Subject: [PATCH 1/2] changed table name for tagging rule --- src/Wallabag/CoreBundle/Entity/TaggingRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php index 4eab590fd..329d7ff85 100644 --- a/src/Wallabag/CoreBundle/Entity/TaggingRule.php +++ b/src/Wallabag/CoreBundle/Entity/TaggingRule.php @@ -10,7 +10,7 @@ use KPhoen\RulerZBundle\Validator\Constraints as RulerZAssert; * Tagging rule. * * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TaggingRuleRepository") - * @ORM\Table + * @ORM\Table(name="`tagging_rule`") * @ORM\Entity */ class TaggingRule From 347fa6beb0bd3fafd5f722c8ce2e2b3915e4e82e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 8 Dec 2015 09:20:03 +0100 Subject: [PATCH 2/2] php cs --- .../StringToListTransformer.php | 8 +++---- .../CoreBundle/Form/Type/TaggingRuleType.php | 1 - .../CoreBundle/Helper/ContentProxy.php | 2 +- .../CoreBundle/Helper/RuleBasedTagger.php | 9 ++++--- .../Tests/Controller/ExportControllerTest.php | 2 +- .../StringToListTransformerTest.php | 20 ++++++++-------- .../Tests/Helper/ContentProxyTest.php | 2 -- .../Tests/Helper/RuleBasedTaggerTest.php | 24 +++++++++---------- 8 files changed, 31 insertions(+), 37 deletions(-) diff --git a/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php b/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php index 23488d353..b712ad152 100644 --- a/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php +++ b/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php @@ -2,13 +2,11 @@ namespace Wallabag\CoreBundle\Form\DataTransformer; -use Doctrine\Common\Persistence\ObjectManager; use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\TransformationFailedException; /** * Transforms a comma-separated list to a proper PHP array. - * Example: the string "foo, bar" will become the array ["foo", "bar"] + * Example: the string "foo, bar" will become the array ["foo", "bar"]. */ class StringToListTransformer implements DataTransformerInterface { @@ -44,14 +42,14 @@ class StringToListTransformer implements DataTransformerInterface /** * Transforms a string to a list. * - * @param string $string + * @param string $string * * @return array|null */ public function reverseTransform($string) { if ($string === null) { - return null; + return; } return array_values(array_filter(array_map('trim', explode($this->separator, $string)))); diff --git a/src/Wallabag/CoreBundle/Form/Type/TaggingRuleType.php b/src/Wallabag/CoreBundle/Form/Type/TaggingRuleType.php index 7fbba38ac..428d94b38 100644 --- a/src/Wallabag/CoreBundle/Form/Type/TaggingRuleType.php +++ b/src/Wallabag/CoreBundle/Form/Type/TaggingRuleType.php @@ -5,7 +5,6 @@ namespace Wallabag\CoreBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; - use Wallabag\CoreBundle\Form\DataTransformer\StringToListTransformer; class TaggingRuleType extends AbstractType diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index 3d585e618..bd8b993a1 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php @@ -19,7 +19,7 @@ class ContentProxy public function __construct(Graby $graby, RuleBasedTagger $tagger, Logger $logger) { - $this->graby = $graby; + $this->graby = $graby; $this->tagger = $tagger; $this->logger = $logger; } diff --git a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php index 3f9953c09..fb2d1f87d 100644 --- a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php +++ b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php @@ -3,7 +3,6 @@ namespace Wallabag\CoreBundle\Helper; use RulerZ\RulerZ; - use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Repository\EntryRepository; @@ -18,8 +17,8 @@ class RuleBasedTagger public function __construct(RulerZ $rulerz, TagRepository $tagRepository, EntryRepository $entryRepository) { - $this->rulerz = $rulerz; - $this->tagRepository = $tagRepository; + $this->rulerz = $rulerz; + $this->tagRepository = $tagRepository; $this->entryRepository = $entryRepository; } @@ -54,11 +53,11 @@ class RuleBasedTagger */ public function tagAllForUser(User $user) { - $rules = $this->getRulesForUser($user); + $rules = $this->getRulesForUser($user); $entries = array(); foreach ($rules as $rule) { - $qb = $this->entryRepository->getBuilderForAllByUser($user->getId()); + $qb = $this->entryRepository->getBuilderForAllByUser($user->getId()); $entries = $this->rulerz->filter($qb, $rule->getRule()); foreach ($entries as $entry) { diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ExportControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ExportControllerTest.php index 739b2dec7..aaa264994 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/ExportControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/ExportControllerTest.php @@ -150,7 +150,7 @@ class ExportControllerTest extends WallabagCoreTestCase $this->assertGreaterThan(1, $csv); // +1 for title line - $this->assertEquals(count($contentInDB)+1, count($csv)); + $this->assertEquals(count($contentInDB) + 1, count($csv)); $this->assertEquals('Title;URL;Content;Tags;"MIME Type";Language', $csv[0]); } diff --git a/src/Wallabag/CoreBundle/Tests/Form/DataTransformer/StringToListTransformerTest.php b/src/Wallabag/CoreBundle/Tests/Form/DataTransformer/StringToListTransformerTest.php index d114e5f35..7105488dc 100644 --- a/src/Wallabag/CoreBundle/Tests/Form/DataTransformer/StringToListTransformerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Form/DataTransformer/StringToListTransformerTest.php @@ -19,10 +19,10 @@ class StringToListTransformerTest extends \PHPUnit_Framework_TestCase public function transformProvider() { return array( - array( null, '' ), - array( array(), '' ), - array( array('single value'), 'single value' ), - array( array('first value', 'second value'), 'first value,second value' ), + array(null, ''), + array(array(), ''), + array(array('single value'), 'single value'), + array(array('first value', 'second value'), 'first value,second value'), ); } @@ -39,12 +39,12 @@ class StringToListTransformerTest extends \PHPUnit_Framework_TestCase public function reverseTransformProvider() { return array( - array( null, null ), - array( '', array() ), - array( 'single value', array('single value') ), - array( 'first value,second value', array('first value', 'second value') ), - array( 'first value, second value', array('first value', 'second value') ), - array( 'first value, , second value', array('first value', 'second value') ), + array(null, null), + array('', array()), + array('single value', array('single value')), + array('first value,second value', array('first value', 'second value')), + array('first value, second value', array('first value', 'second value')), + array('first value, , second value', array('first value', 'second value')), ); } } diff --git a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php index ef7cbd5b2..ac518dbb1 100644 --- a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php +++ b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php @@ -2,9 +2,7 @@ namespace Wallabag\CoreBundle\Tests\Helper; -use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Psr\Log\NullLogger; - use Wallabag\CoreBundle\Entity\Entry; use Wallabag\UserBundle\Entity\User; use Wallabag\CoreBundle\Helper\ContentProxy; diff --git a/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php b/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php index 5180f7ddb..37e137bfc 100644 --- a/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php @@ -18,8 +18,8 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->rulerz = $this->getRulerZMock(); - $this->tagRepository = $this->getTagRepositoryMock(); + $this->rulerz = $this->getRulerZMock(); + $this->tagRepository = $this->getTagRepositoryMock(); $this->entryRepository = $this->getEntryRepositoryMock(); $this->tagger = new RuleBasedTagger($this->rulerz, $this->tagRepository, $this->entryRepository); @@ -37,8 +37,8 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase public function testTagWithNoMatchingRule() { $taggingRule = $this->getTaggingRule('rule as string', array('foo', 'bar')); - $user = $this->getUser([$taggingRule]); - $entry = new Entry($user); + $user = $this->getUser([$taggingRule]); + $entry = new Entry($user); $this->rulerz ->expects($this->once()) @@ -54,8 +54,8 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase public function testTagWithAMatchingRule() { $taggingRule = $this->getTaggingRule('rule as string', array('foo', 'bar')); - $user = $this->getUser([$taggingRule]); - $entry = new Entry($user); + $user = $this->getUser([$taggingRule]); + $entry = new Entry($user); $this->rulerz ->expects($this->once()) @@ -76,10 +76,10 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase public function testTagWithAMixOfMatchingRules() { - $taggingRule = $this->getTaggingRule('bla bla', array('hey')); + $taggingRule = $this->getTaggingRule('bla bla', array('hey')); $otherTaggingRule = $this->getTaggingRule('rule as string', array('foo')); - $user = $this->getUser([$taggingRule, $otherTaggingRule]); + $user = $this->getUser([$taggingRule, $otherTaggingRule]); $entry = new Entry($user); $this->rulerz @@ -98,9 +98,9 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase public function testWhenTheTagExists() { $taggingRule = $this->getTaggingRule('rule as string', array('foo')); - $user = $this->getUser([$taggingRule]); - $entry = new Entry($user); - $tag = new Tag($user); + $user = $this->getUser([$taggingRule]); + $entry = new Entry($user); + $tag = new Tag($user); $this->rulerz ->expects($this->once()) @@ -123,7 +123,7 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase private function getUser(array $taggingRules = []) { - $user = new User(); + $user = new User(); $config = new Config($user); $user->setConfig($config);