diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@smile.fr> | 2015-12-08 09:20:03 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@smile.fr> | 2015-12-08 09:20:03 +0100 |
commit | 347fa6beb0bd3fafd5f722c8ce2e2b3915e4e82e (patch) | |
tree | 23c7c5cee6aefbbf8ec058ac99f4729c7be4ac3e /src | |
parent | c5d0db8b71a8c1bb6b5c08763b44e14b4f876d06 (diff) | |
download | wallabag-347fa6beb0bd3fafd5f722c8ce2e2b3915e4e82e.tar.gz wallabag-347fa6beb0bd3fafd5f722c8ce2e2b3915e4e82e.tar.zst wallabag-347fa6beb0bd3fafd5f722c8ce2e2b3915e4e82e.zip |
php cs
Diffstat (limited to 'src')
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 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 | ||
3 | namespace Wallabag\CoreBundle\Form\DataTransformer; | 3 | namespace Wallabag\CoreBundle\Form\DataTransformer; |
4 | 4 | ||
5 | use Doctrine\Common\Persistence\ObjectManager; | ||
6 | use Symfony\Component\Form\DataTransformerInterface; | 5 | use Symfony\Component\Form\DataTransformerInterface; |
7 | use 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 | */ |
13 | class StringToListTransformer implements DataTransformerInterface | 11 | class 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; | |||
5 | use Symfony\Component\Form\AbstractType; | 5 | use Symfony\Component\Form\AbstractType; |
6 | use Symfony\Component\Form\FormBuilderInterface; | 6 | use Symfony\Component\Form\FormBuilderInterface; |
7 | use Symfony\Component\OptionsResolver\OptionsResolver; | 7 | use Symfony\Component\OptionsResolver\OptionsResolver; |
8 | |||
9 | use Wallabag\CoreBundle\Form\DataTransformer\StringToListTransformer; | 8 | use Wallabag\CoreBundle\Form\DataTransformer\StringToListTransformer; |
10 | 9 | ||
11 | class TaggingRuleType extends AbstractType | 10 | class 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 @@ | |||
3 | namespace Wallabag\CoreBundle\Helper; | 3 | namespace Wallabag\CoreBundle\Helper; |
4 | 4 | ||
5 | use RulerZ\RulerZ; | 5 | use RulerZ\RulerZ; |
6 | |||
7 | use Wallabag\CoreBundle\Entity\Entry; | 6 | use Wallabag\CoreBundle\Entity\Entry; |
8 | use Wallabag\CoreBundle\Entity\Tag; | 7 | use Wallabag\CoreBundle\Entity\Tag; |
9 | use Wallabag\CoreBundle\Repository\EntryRepository; | 8 | use 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 | ||
3 | namespace Wallabag\CoreBundle\Tests\Helper; | 3 | namespace Wallabag\CoreBundle\Tests\Helper; |
4 | 4 | ||
5 | use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | ||
6 | use Psr\Log\NullLogger; | 5 | use Psr\Log\NullLogger; |
7 | |||
8 | use Wallabag\CoreBundle\Entity\Entry; | 6 | use Wallabag\CoreBundle\Entity\Entry; |
9 | use Wallabag\UserBundle\Entity\User; | 7 | use Wallabag\UserBundle\Entity\User; |
10 | use Wallabag\CoreBundle\Helper\ContentProxy; | 8 | use 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); |