| 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\Context; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | class ArticleLoaderTest extends \PHPUnit_Framework_TestCase | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 24 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |     public function testLoadingCollection() | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |         $context = new Context(new ArrayCache()); | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |         $metaFactory = new MetaFactory($context); | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |         $articleLoader = new ArticleLoader(__DIR__.'/../../spec/Gimme/Meta', $metaFactory); | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |         $result = $articleLoader->load('articles', [], LoaderInterface::COLLECTION); | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |         self::assertInstanceOf(MetaCollection::class, $result); | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |         self::assertCount(2, $result); | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     protected function tearDown() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $reflection = new \ReflectionObject($this); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         foreach ($reflection->getProperties() as $prop) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |                 $prop->setAccessible(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |                 $prop->setValue($this, null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 46 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 47 |  |  |  |