Code Duplication    Length = 32-32 lines in 2 locations

www/src/AdminBundle/Tests/Model/ImportTwineTest.php 2 locations

@@ 993-1024 (lines=32) @@
990
     * @expectedException \Exception
991
     * @expectedExceptionMessageRegExp /invalid element.*>:</
992
     */
993
    public function testRunWithMetadataSettingForInvalidFormat()
994
    {
995
        $importfile = $this->getDummyImportfile();
996
997
        $this->fileExtractorMock->expects(self::any())
998
            ->method('extract')
999
            ->willReturn('readable.extracted');
1000
1001
        self::$freadStack = [
1002
            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
1003
            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
1004
            '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
1005
            'lorem ipsum [[Linkdata->someNodeName2]]</tw-passagedata>',
1006
            '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId2" position="104,30">lorem ipsum',
1007
            'lorem ipsum [[>:&lt;metavalue]]</tw-passagedata>',
1008
            '</tw-storydata>',
1009
        ];
1010
1011
        $textnode1 = new Textnode();
1012
        $textnode1->setText('lorem ipsum [[>:<metavalue]]');
1013
        $textnode1->setId('someId0');
1014
1015
        $this->textnodeRepository->expects($this->any())
1016
            ->method('find')
1017
            ->will($this->returnValue($textnode1));
1018
1019
        $this->textnodeRepository->expects($this->any())
1020
            ->method('findByTwineId')
1021
            ->will($this->returnValue($textnode1));
1022
1023
        $this->importTwine->run($importfile);
1024
    }
1025
1026
    /**
1027
     * @expectedException \Exception
@@ 1030-1061 (lines=32) @@
1027
     * @expectedException \Exception
1028
     * @expectedExceptionMessageRegExp /contains the metadata field/
1029
     */
1030
    public function testRunWithMetadataSettingForAnAlreadyExistingMetadataKey()
1031
    {
1032
        $importfile = $this->getDummyImportfile();
1033
1034
        $this->fileExtractorMock->expects(self::any())
1035
            ->method('extract')
1036
            ->willReturn('readable.extracted');
1037
1038
        self::$freadStack = [
1039
            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
1040
            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
1041
            '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
1042
            'lorem ipsum [[Linkdata->someNodeName2]]</tw-passagedata>',
1043
            '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId2" position="104,30">lorem ipsum',
1044
            'lorem ipsum [[Autor>:&lt;metavalue]]</tw-passagedata>',
1045
            '</tw-storydata>',
1046
        ];
1047
1048
        $textnode1 = new Textnode();
1049
        $textnode1->setId('someId0');
1050
        $textnode1->setMetadata(['metakey' => 'someValue']);
1051
1052
        $this->textnodeRepository->expects($this->any())
1053
            ->method('find')
1054
            ->will($this->returnValue($textnode1));
1055
1056
        $this->textnodeRepository->expects($this->any())
1057
            ->method('findByTwineId')
1058
            ->will($this->returnValue($textnode1));
1059
1060
        $this->importTwine->run($importfile);
1061
    }
1062
1063
    private function getDummyImportfile(array $data = [])
1064
    {