| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Graze\CiffRenderer\Test\Unit\Renderer\FieldRenderer\GraphicPrimitive; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Mockery as m; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Graze\CiffRenderer\Parser\FieldParser\FieldParserInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Intervention\Image\Image; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Intervention\Image\ImageManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Graze\CiffRenderer\Renderer\FieldRenderer\GraphicPrimitive\FieldRendererFilledBox; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | class FieldRendererFilledBoxTest extends \PHPUnit_Framework_TestCase | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 12 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  |     public function testRender() | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |         $width = 2; | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |         $height = 4; | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |         $lineWeight = 1; | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |         $parser = m::mock(FieldParserInterface::class) | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |             ->shouldReceive('getWidth') | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |             ->andReturn($width) | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |             ->twice() | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |             ->shouldReceive('getHeight') | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |             ->andReturn($height) | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |             ->twice() | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |             ->shouldReceive('getLineWeight') | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |             ->andReturn($lineWeight) | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |             ->times(3) | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |             ->getMock(); | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |         $rectangle = m::mock('rectangle') | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |             ->shouldReceive('border') | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |             ->with($lineWeight, '#000') | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |             ->once() | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |             ->shouldReceive('background') | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |             ->with('#000') | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |             ->getMock(); | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |         $closureExpection = function ($closureActual) use ($rectangle) { | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |             $closureActual($rectangle); | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |             return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |         }; | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |         $image = m::mock(Image::class) | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |             ->shouldReceive('rectangle') | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |             ->with(0, 0, $width - $lineWeight, $height - $lineWeight, m::on($closureExpection)) | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |             ->once() | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |             ->getMock(); | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |         $imageManager = m::mock(ImageManager::class) | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |             ->shouldReceive('canvas') | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |             ->with($width, $height) | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |             ->andReturn($image) | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |             ->getMock(); | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |         $renderer = new FieldRendererFilledBox(); | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |         $imageActual = $renderer->render( | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |             $imageManager, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |             $parser | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |         $this->assertSame($image, $imageActual); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 62 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 63 |  |  |  | 
            
                        
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.