Code Duplication    Length = 32-32 lines in 2 locations

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

@@ 1025-1056 (lines=32) @@
1022
     * @expectedException \Exception
1023
     * @expectedExceptionMessageRegExp /invalid element.*>:</
1024
     */
1025
    public function testRunWithMetadataSettingForInvalidFormat()
1026
    {
1027
        $importfile = $this->getDummyImportfile();
1028
1029
        $this->fileExtractorMock->expects(self::any())
1030
            ->method('extract')
1031
            ->willReturn('readable.extracted');
1032
1033
        self::$freadStack = [
1034
            '<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",
1035
            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
1036
            '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
1037
            'lorem ipsum [[Linkdata->someNodeName2]]</tw-passagedata>',
1038
            '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId2" position="104,30">lorem ipsum',
1039
            'lorem ipsum [[>:&lt;metavalue]]</tw-passagedata>',
1040
            '</tw-storydata>',
1041
        ];
1042
1043
        $textnode1 = new Textnode();
1044
        $textnode1->setText('lorem ipsum [[>:<metavalue]]');
1045
        $textnode1->setId('someId0');
1046
1047
        $this->textnodeRepository->expects($this->any())
1048
            ->method('find')
1049
            ->will($this->returnValue($textnode1));
1050
1051
        $this->textnodeRepository->expects($this->any())
1052
            ->method('findByTwineId')
1053
            ->will($this->returnValue($textnode1));
1054
1055
        $this->importTwine->run($importfile);
1056
    }
1057
1058
    /**
1059
     * @expectedException \Exception
@@ 1062-1093 (lines=32) @@
1059
     * @expectedException \Exception
1060
     * @expectedExceptionMessageRegExp /contains the metadata field/
1061
     */
1062
    public function testRunWithMetadataSettingForAnAlreadyExistingMetadataKey()
1063
    {
1064
        $importfile = $this->getDummyImportfile();
1065
1066
        $this->fileExtractorMock->expects(self::any())
1067
            ->method('extract')
1068
            ->willReturn('readable.extracted');
1069
1070
        self::$freadStack = [
1071
            '<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",
1072
            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
1073
            '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
1074
            'lorem ipsum [[Linkdata->someNodeName2]]</tw-passagedata>',
1075
            '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId2" position="104,30">lorem ipsum',
1076
            'lorem ipsum [[Autor>:&lt;metavalue]]</tw-passagedata>',
1077
            '</tw-storydata>',
1078
        ];
1079
1080
        $textnode1 = new Textnode();
1081
        $textnode1->setId('someId0');
1082
        $textnode1->setMetadata(['metakey' => 'someValue']);
1083
1084
        $this->textnodeRepository->expects($this->any())
1085
            ->method('find')
1086
            ->will($this->returnValue($textnode1));
1087
1088
        $this->textnodeRepository->expects($this->any())
1089
            ->method('findByTwineId')
1090
            ->will($this->returnValue($textnode1));
1091
1092
        $this->importTwine->run($importfile);
1093
    }
1094
1095
    /**
1096
     * @return void