aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Wallabag/CoreBundle/Entity/TaggingRule.php2
-rw-r--r--src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php8
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/TaggingRuleType.php1
-rw-r--r--src/Wallabag/CoreBundle/Helper/ContentProxy.php2
-rw-r--r--src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php9
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/ExportControllerTest.php2
-rw-r--r--src/Wallabag/CoreBundle/Tests/Form/DataTransformer/StringToListTransformerTest.php20
-rw-r--r--src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php2
-rw-r--r--src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php24
9 files changed, 32 insertions, 38 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php
index 4eab590f..329d7ff8 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;
10 * Tagging rule. 10 * Tagging rule.
11 * 11 *
12 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TaggingRuleRepository") 12 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TaggingRuleRepository")
13 * @ORM\Table 13 * @ORM\Table(name="`tagging_rule`")
14 * @ORM\Entity 14 * @ORM\Entity
15 */ 15 */
16class TaggingRule 16class TaggingRule
diff --git a/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php b/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php
index 23488d35..b712ad15 100644
--- a/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php
+++ b/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php
@@ -2,13 +2,11 @@
2 2
3namespace Wallabag\CoreBundle\Form\DataTransformer; 3namespace Wallabag\CoreBundle\Form\DataTransformer;
4 4
5use Doctrine\Common\Persistence\ObjectManager;
6use Symfony\Component\Form\DataTransformerInterface; 5use Symfony\Component\Form\DataTransformerInterface;
7use Symfony\Component\Form\Exception\TransformationFailedException;
8 6
9/** 7/**
10 * Transforms a comma-separated list to a proper PHP array. 8 * Transforms a comma-separated list to a proper PHP array.
11 * Example: the string "foo, bar" will become the array ["foo", "bar"] 9 * Example: the string "foo, bar" will become the array ["foo", "bar"].
12 */ 10 */
13class StringToListTransformer implements DataTransformerInterface 11class StringToListTransformer implements DataTransformerInterface
14{ 12{
@@ -44,14 +42,14 @@ class StringToListTransformer implements DataTransformerInterface
44 /** 42 /**
45 * Transforms a string to a list. 43 * Transforms a string to a list.
46 * 44 *
47 * @param string $string 45 * @param string $string
48 * 46 *
49 * @return array|null 47 * @return array|null
50 */ 48 */
51 public function reverseTransform($string) 49 public function reverseTransform($string)
52 { 50 {
53 if ($string === null) { 51 if ($string === null) {
54 return null; 52 return;
55 } 53 }
56 54
57 return array_values(array_filter(array_map('trim', explode($this->separator, $string)))); 55 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 7fbba38a..428d94b3 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;
5use Symfony\Component\Form\AbstractType; 5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface; 6use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\OptionsResolver\OptionsResolver; 7use Symfony\Component\OptionsResolver\OptionsResolver;
8
9use Wallabag\CoreBundle\Form\DataTransformer\StringToListTransformer; 8use Wallabag\CoreBundle\Form\DataTransformer\StringToListTransformer;
10 9
11class TaggingRuleType extends AbstractType 10class TaggingRuleType extends AbstractType
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
index 3d585e61..bd8b993a 100644
--- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
@@ -19,7 +19,7 @@ class ContentProxy
19 19
20 public function __construct(Graby $graby, RuleBasedTagger $tagger, Logger $logger) 20 public function __construct(Graby $graby, RuleBasedTagger $tagger, Logger $logger)
21 { 21 {
22 $this->graby = $graby; 22 $this->graby = $graby;
23 $this->tagger = $tagger; 23 $this->tagger = $tagger;
24 $this->logger = $logger; 24 $this->logger = $logger;
25 } 25 }
diff --git a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
index 3f9953c0..fb2d1f87 100644
--- a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
+++ b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
@@ -3,7 +3,6 @@
3namespace Wallabag\CoreBundle\Helper; 3namespace Wallabag\CoreBundle\Helper;
4 4
5use RulerZ\RulerZ; 5use RulerZ\RulerZ;
6
7use Wallabag\CoreBundle\Entity\Entry; 6use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\CoreBundle\Entity\Tag; 7use Wallabag\CoreBundle\Entity\Tag;
9use Wallabag\CoreBundle\Repository\EntryRepository; 8use Wallabag\CoreBundle\Repository\EntryRepository;
@@ -18,8 +17,8 @@ class RuleBasedTagger
18 17
19 public function __construct(RulerZ $rulerz, TagRepository $tagRepository, EntryRepository $entryRepository) 18 public function __construct(RulerZ $rulerz, TagRepository $tagRepository, EntryRepository $entryRepository)
20 { 19 {
21 $this->rulerz = $rulerz; 20 $this->rulerz = $rulerz;
22 $this->tagRepository = $tagRepository; 21 $this->tagRepository = $tagRepository;
23 $this->entryRepository = $entryRepository; 22 $this->entryRepository = $entryRepository;
24 } 23 }
25 24
@@ -54,11 +53,11 @@ class RuleBasedTagger
54 */ 53 */
55 public function tagAllForUser(User $user) 54 public function tagAllForUser(User $user)
56 { 55 {
57 $rules = $this->getRulesForUser($user); 56 $rules = $this->getRulesForUser($user);
58 $entries = array(); 57 $entries = array();
59 58
60 foreach ($rules as $rule) { 59 foreach ($rules as $rule) {
61 $qb = $this->entryRepository->getBuilderForAllByUser($user->getId()); 60 $qb = $this->entryRepository->getBuilderForAllByUser($user->getId());
62 $entries = $this->rulerz->filter($qb, $rule->getRule()); 61 $entries = $this->rulerz->filter($qb, $rule->getRule());
63 62
64 foreach ($entries as $entry) { 63 foreach ($entries as $entry) {
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ExportControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ExportControllerTest.php
index 739b2dec..aaa26499 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
150 150
151 $this->assertGreaterThan(1, $csv); 151 $this->assertGreaterThan(1, $csv);
152 // +1 for title line 152 // +1 for title line
153 $this->assertEquals(count($contentInDB)+1, count($csv)); 153 $this->assertEquals(count($contentInDB) + 1, count($csv));
154 $this->assertEquals('Title;URL;Content;Tags;"MIME Type";Language', $csv[0]); 154 $this->assertEquals('Title;URL;Content;Tags;"MIME Type";Language', $csv[0]);
155 } 155 }
156 156
diff --git a/src/Wallabag/CoreBundle/Tests/Form/DataTransformer/StringToListTransformerTest.php b/src/Wallabag/CoreBundle/Tests/Form/DataTransformer/StringToListTransformerTest.php
index d114e5f3..7105488d 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
19 public function transformProvider() 19 public function transformProvider()
20 { 20 {
21 return array( 21 return array(
22 array( null, '' ), 22 array(null, ''),
23 array( array(), '' ), 23 array(array(), ''),
24 array( array('single value'), 'single value' ), 24 array(array('single value'), 'single value'),
25 array( array('first value', 'second value'), 'first value,second value' ), 25 array(array('first value', 'second value'), 'first value,second value'),
26 ); 26 );
27 } 27 }
28 28
@@ -39,12 +39,12 @@ class StringToListTransformerTest extends \PHPUnit_Framework_TestCase
39 public function reverseTransformProvider() 39 public function reverseTransformProvider()
40 { 40 {
41 return array( 41 return array(
42 array( null, null ), 42 array(null, null),
43 array( '', array() ), 43 array('', array()),
44 array( 'single value', array('single value') ), 44 array('single value', array('single value')),
45 array( 'first value,second value', array('first value', 'second value') ), 45 array('first value,second value', array('first value', 'second value')),
46 array( 'first value, second value', array('first value', 'second value') ), 46 array('first value, second value', array('first value', 'second value')),
47 array( 'first value, , second value', array('first value', 'second value') ), 47 array('first value, , second value', array('first value', 'second value')),
48 ); 48 );
49 } 49 }
50} 50}
diff --git a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php
index ef7cbd5b..ac518dbb 100644
--- a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php
@@ -2,9 +2,7 @@
2 2
3namespace Wallabag\CoreBundle\Tests\Helper; 3namespace Wallabag\CoreBundle\Tests\Helper;
4 4
5use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
6use Psr\Log\NullLogger; 5use Psr\Log\NullLogger;
7
8use Wallabag\CoreBundle\Entity\Entry; 6use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\UserBundle\Entity\User; 7use Wallabag\UserBundle\Entity\User;
10use Wallabag\CoreBundle\Helper\ContentProxy; 8use Wallabag\CoreBundle\Helper\ContentProxy;
diff --git a/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php b/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php
index 5180f7dd..37e137bf 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
18 18
19 public function setUp() 19 public function setUp()
20 { 20 {
21 $this->rulerz = $this->getRulerZMock(); 21 $this->rulerz = $this->getRulerZMock();
22 $this->tagRepository = $this->getTagRepositoryMock(); 22 $this->tagRepository = $this->getTagRepositoryMock();
23 $this->entryRepository = $this->getEntryRepositoryMock(); 23 $this->entryRepository = $this->getEntryRepositoryMock();
24 24
25 $this->tagger = new RuleBasedTagger($this->rulerz, $this->tagRepository, $this->entryRepository); 25 $this->tagger = new RuleBasedTagger($this->rulerz, $this->tagRepository, $this->entryRepository);
@@ -37,8 +37,8 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
37 public function testTagWithNoMatchingRule() 37 public function testTagWithNoMatchingRule()
38 { 38 {
39 $taggingRule = $this->getTaggingRule('rule as string', array('foo', 'bar')); 39 $taggingRule = $this->getTaggingRule('rule as string', array('foo', 'bar'));
40 $user = $this->getUser([$taggingRule]); 40 $user = $this->getUser([$taggingRule]);
41 $entry = new Entry($user); 41 $entry = new Entry($user);
42 42
43 $this->rulerz 43 $this->rulerz
44 ->expects($this->once()) 44 ->expects($this->once())
@@ -54,8 +54,8 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
54 public function testTagWithAMatchingRule() 54 public function testTagWithAMatchingRule()
55 { 55 {
56 $taggingRule = $this->getTaggingRule('rule as string', array('foo', 'bar')); 56 $taggingRule = $this->getTaggingRule('rule as string', array('foo', 'bar'));
57 $user = $this->getUser([$taggingRule]); 57 $user = $this->getUser([$taggingRule]);
58 $entry = new Entry($user); 58 $entry = new Entry($user);
59 59
60 $this->rulerz 60 $this->rulerz
61 ->expects($this->once()) 61 ->expects($this->once())
@@ -76,10 +76,10 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
76 76
77 public function testTagWithAMixOfMatchingRules() 77 public function testTagWithAMixOfMatchingRules()
78 { 78 {
79 $taggingRule = $this->getTaggingRule('bla bla', array('hey')); 79 $taggingRule = $this->getTaggingRule('bla bla', array('hey'));
80 $otherTaggingRule = $this->getTaggingRule('rule as string', array('foo')); 80 $otherTaggingRule = $this->getTaggingRule('rule as string', array('foo'));
81 81
82 $user = $this->getUser([$taggingRule, $otherTaggingRule]); 82 $user = $this->getUser([$taggingRule, $otherTaggingRule]);
83 $entry = new Entry($user); 83 $entry = new Entry($user);
84 84
85 $this->rulerz 85 $this->rulerz
@@ -98,9 +98,9 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
98 public function testWhenTheTagExists() 98 public function testWhenTheTagExists()
99 { 99 {
100 $taggingRule = $this->getTaggingRule('rule as string', array('foo')); 100 $taggingRule = $this->getTaggingRule('rule as string', array('foo'));
101 $user = $this->getUser([$taggingRule]); 101 $user = $this->getUser([$taggingRule]);
102 $entry = new Entry($user); 102 $entry = new Entry($user);
103 $tag = new Tag($user); 103 $tag = new Tag($user);
104 104
105 $this->rulerz 105 $this->rulerz
106 ->expects($this->once()) 106 ->expects($this->once())
@@ -123,7 +123,7 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
123 123
124 private function getUser(array $taggingRules = []) 124 private function getUser(array $taggingRules = [])
125 { 125 {
126 $user = new User(); 126 $user = new User();
127 $config = new Config($user); 127 $config = new Config($user);
128 128
129 $user->setConfig($config); 129 $user->setConfig($config);