Code Duplication    Length = 51-53 lines in 3 locations

Tests/Imagine/Filter/FilterManagerTest.php 3 locations

@@ 574-625 (lines=52) @@
571
        ));
572
    }
573
574
    public function testReturnFilteredBinaryWithExpectedContentOnApply()
575
    {
576
        $originalContent = 'aOriginalContent';
577
        $expectedFilteredContent = 'theFilteredContent';
578
579
        $binary = new Binary($originalContent, 'image/png', 'png');
580
581
        $thumbConfig = array(
582
            'size' => array(180, 180),
583
            'mode' => 'outbound',
584
        );
585
586
        $image = $this->getMockImage();
587
        $image
588
            ->expects($this->once())
589
            ->method('get')
590
            ->will($this->returnValue($expectedFilteredContent))
591
        ;
592
593
        $imagineMock = $this->createImagineMock();
594
        $imagineMock
595
            ->expects($this->once())
596
            ->method('load')
597
            ->with($originalContent)
598
            ->will($this->returnValue($image))
599
        ;
600
601
        $loader = $this->getMockLoader();
602
        $loader
603
            ->expects($this->once())
604
            ->method('load')
605
            ->with($this->identicalTo($image), $thumbConfig)
606
            ->will($this->returnArgument(0))
607
        ;
608
609
        $filterManager = new FilterManager(
610
            $this->createFilterConfigurationMock(),
611
            $imagineMock,
612
            $this->getMockMimeTypeGuesser()
613
        );
614
        $filterManager->addLoader('thumbnail', $loader);
615
616
        $filteredBinary = $filterManager->apply($binary, array(
617
            'filters' => array(
618
                'thumbnail' => $thumbConfig,
619
            ),
620
            'post_processors' => array(),
621
        ));
622
623
        $this->assertInstanceOf('Liip\ImagineBundle\Model\Binary', $filteredBinary);
624
        $this->assertEquals($expectedFilteredContent, $filteredBinary->getContent());
625
    }
626
627
    public function testReturnFilteredBinaryWithFormatOfOriginalBinaryOnApply()
628
    {
@@ 627-677 (lines=51) @@
624
        $this->assertEquals($expectedFilteredContent, $filteredBinary->getContent());
625
    }
626
627
    public function testReturnFilteredBinaryWithFormatOfOriginalBinaryOnApply()
628
    {
629
        $originalContent = 'aOriginalContent';
630
        $expectedFormat = 'png';
631
632
        $binary = new Binary($originalContent, 'image/png', $expectedFormat);
633
634
        $thumbConfig = array(
635
            'size' => array(180, 180),
636
            'mode' => 'outbound',
637
        );
638
639
        $image = $this->getMockImage();
640
        $image
641
            ->expects($this->once())
642
            ->method('get')
643
            ->will($this->returnValue('aFilteredContent'))
644
        ;
645
646
        $imagineMock = $this->createImagineMock();
647
        $imagineMock
648
            ->expects($this->once())
649
            ->method('load')
650
            ->will($this->returnValue($image))
651
        ;
652
653
        $loader = $this->getMockLoader();
654
        $loader
655
            ->expects($this->once())
656
            ->method('load')
657
            ->with($this->identicalTo($image), $thumbConfig)
658
            ->will($this->returnArgument(0))
659
        ;
660
661
        $filterManager = new FilterManager(
662
            $this->createFilterConfigurationMock(),
663
            $imagineMock,
664
            $this->getMockMimeTypeGuesser()
665
        );
666
        $filterManager->addLoader('thumbnail', $loader);
667
668
        $filteredBinary = $filterManager->apply($binary, array(
669
            'filters' => array(
670
                'thumbnail' => $thumbConfig,
671
            ),
672
            'post_processors' => array(),
673
        ));
674
675
        $this->assertInstanceOf('Liip\ImagineBundle\Model\Binary', $filteredBinary);
676
        $this->assertEquals($expectedFormat, $filteredBinary->getFormat());
677
    }
678
679
    public function testReturnFilteredBinaryWithCustomFormatIfSetOnApply()
680
    {
@@ 679-731 (lines=53) @@
676
        $this->assertEquals($expectedFormat, $filteredBinary->getFormat());
677
    }
678
679
    public function testReturnFilteredBinaryWithCustomFormatIfSetOnApply()
680
    {
681
        $originalContent = 'aOriginalContent';
682
        $originalFormat = 'png';
683
        $expectedFormat = 'jpg';
684
685
        $binary = new Binary($originalContent, 'image/png', $originalFormat);
686
687
        $thumbConfig = array(
688
            'size' => array(180, 180),
689
            'mode' => 'outbound',
690
        );
691
692
        $image = $this->getMockImage();
693
        $image
694
            ->expects($this->once())
695
            ->method('get')
696
            ->will($this->returnValue('aFilteredContent'))
697
        ;
698
699
        $imagineMock = $this->createImagineMock();
700
        $imagineMock
701
            ->expects($this->once())
702
            ->method('load')
703
            ->will($this->returnValue($image))
704
        ;
705
706
        $loader = $this->getMockLoader();
707
        $loader
708
            ->expects($this->once())
709
            ->method('load')
710
            ->with($this->identicalTo($image), $thumbConfig)
711
            ->will($this->returnArgument(0))
712
        ;
713
714
        $filterManager = new FilterManager(
715
            $this->createFilterConfigurationMock(),
716
            $imagineMock,
717
            $this->getMockMimeTypeGuesser()
718
        );
719
        $filterManager->addLoader('thumbnail', $loader);
720
721
        $filteredBinary = $filterManager->apply($binary, array(
722
            'format' => $expectedFormat,
723
            'filters' => array(
724
                'thumbnail' => $thumbConfig,
725
            ),
726
            'post_processors' => array(),
727
        ));
728
729
        $this->assertInstanceOf('Liip\ImagineBundle\Model\Binary', $filteredBinary);
730
        $this->assertEquals($expectedFormat, $filteredBinary->getFormat());
731
    }
732
733
    public function testReturnFilteredBinaryWithMimeTypeOfOriginalBinaryOnApply()
734
    {