1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the Superdesk Web Publisher Templates System. |
4
|
|
|
* |
5
|
|
|
* Copyright 2015 Sourcefabric z.ú. and contributors. |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please see the |
8
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
9
|
|
|
* |
10
|
|
|
* @copyright 2015 Sourcefabric z.ú |
11
|
|
|
* @license http://www.superdesk.org/license |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace SWP\Component\TemplatesSystem\Tests\Gimme\Loader; |
15
|
|
|
|
16
|
|
|
use Doctrine\Common\Cache\ArrayCache; |
17
|
|
|
use SWP\Component\TemplatesSystem\Gimme\Context\Context; |
18
|
|
|
use SWP\Component\TemplatesSystem\Gimme\Factory\MetaFactory; |
19
|
|
|
use SWP\Component\TemplatesSystem\Gimme\Loader\ArticleLoader; |
20
|
|
|
use SWP\Component\TemplatesSystem\Gimme\Loader\LoaderInterface; |
21
|
|
|
use SWP\Component\TemplatesSystem\Gimme\Meta\MetaCollection; |
22
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcher; |
23
|
|
|
|
24
|
|
|
class ArticleLoaderTest extends \PHPUnit\Framework\TestCase |
25
|
|
|
{ |
26
|
|
|
public function testLoadingCollection() |
27
|
|
|
{ |
28
|
|
|
$context = new Context(new EventDispatcher(), new ArrayCache()); |
29
|
|
|
$metaFactory = new MetaFactory($context); |
30
|
|
|
$articleLoader = new ArticleLoader(__DIR__.'/../../Twig/Node', $metaFactory); |
31
|
|
|
|
32
|
|
|
$result = $articleLoader->load('articles', [], [], LoaderInterface::COLLECTION); |
33
|
|
|
self::assertInstanceOf(MetaCollection::class, $result); |
34
|
|
|
self::assertCount(2, $result); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
View Code Duplication |
protected function tearDown() |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
$reflection = new \ReflectionObject($this); |
40
|
|
|
foreach ($reflection->getProperties() as $prop) { |
41
|
|
|
if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) { |
42
|
|
|
$prop->setAccessible(true); |
43
|
|
|
$prop->setValue($this, null); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.