| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace ShlinkioTest\Shlink\Common\Doctrine\Mapping; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Doctrine\Persistence\Mapping\ClassMetadata; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Doctrine\Persistence\Mapping\Driver\FileLocator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use PHPUnit\Framework\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Prophecy\Argument; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Prophecy\Prophecy\ObjectProphecy; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Shlinkio\Shlink\Common\Doctrine\Mapping\EnhancedPHPDriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | class EnhancedPHPDriverTest extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     private ObjectProphecy $loader; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     private ObjectProphecy $meta; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     public function setUp(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         $this->loader = $this->prophesize(FileLocator::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         $this->loader->findMappingFile(Argument::any())->willReturn( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |             __DIR__ . '/../../../test-resources/mapping/fake.mapping.php', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         $this->meta = $this->prophesize(ClassMetadata::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * @dataProvider provideFuncStyle | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 31 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |     public function internalFunctionIsInvokedBasedOnFunctionalStyle(array $args, int $metaExpectedCalls): void | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |         $metaMethod = $this->meta->getFieldNames(); | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |         $driver = new EnhancedPHPDriver($this->loader->reveal(), [], ...$args); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |         $driver->loadMetadataForClass('', $this->meta->reveal()); | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |         $metaMethod->shouldHaveBeenCalledTimes($metaExpectedCalls); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     public function provideFuncStyle(): iterable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         yield 'func style' => [[true], 1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         yield 'no func style' => [[false], 0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         yield 'default func style' => [[], 0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 48 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 49 |  |  |  |