Code Duplication    Length = 32-32 lines in 2 locations

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

@@ 907-938 (lines=32) @@
904
     * @expectedException \Exception
905
     * @expectedExceptionMessageRegExp /invalid element.*>:</
906
     */
907
    public function testRunWithMetadataSettingForInvalidFormat()
908
    {
909
        $importfile = $this->getDummyImportfile();
910
911
        $this->fileExtractorMock->expects(self::any())
912
            ->method('extract')
913
            ->willReturn('readable.extracted');
914
915
        self::$freadStack = [
916
            '<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",
917
            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
918
            '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
919
            'lorem ipsum [[Linkdata->someNodeName2]]</tw-passagedata>',
920
            '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId2" position="104,30">lorem ipsum',
921
            'lorem ipsum [[>:&lt;metavalue]]</tw-passagedata>',
922
            '</tw-storydata>',
923
        ];
924
925
        $textnode1 = new Textnode();
926
        $textnode1->setText('lorem ipsum [[>:<metavalue]]');
927
        $textnode1->setId('someId0');
928
929
        $this->textnodeRepository->expects($this->any())
930
            ->method('find')
931
            ->will($this->returnValue($textnode1));
932
933
        $this->textnodeRepository->expects($this->any())
934
            ->method('findByTwineId')
935
            ->will($this->returnValue($textnode1));
936
937
        $this->importTwine->run($importfile);
938
    }
939
940
    /**
941
     * @expectedException \Exception
@@ 944-975 (lines=32) @@
941
     * @expectedException \Exception
942
     * @expectedExceptionMessageRegExp /contains the metadata field/
943
     */
944
    public function testRunWithMetadataSettingForAnAlreadyExistingMetadataKey()
945
    {
946
        $importfile = $this->getDummyImportfile();
947
948
        $this->fileExtractorMock->expects(self::any())
949
            ->method('extract')
950
            ->willReturn('readable.extracted');
951
952
        self::$freadStack = [
953
            '<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",
954
            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
955
            '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
956
            'lorem ipsum [[Linkdata->someNodeName2]]</tw-passagedata>',
957
            '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId2" position="104,30">lorem ipsum',
958
            'lorem ipsum [[Autor>:&lt;metavalue]]</tw-passagedata>',
959
            '</tw-storydata>',
960
        ];
961
962
        $textnode1 = new Textnode();
963
        $textnode1->setId('someId0');
964
        $textnode1->setMetadata(['metakey' => 'someValue']);
965
966
        $this->textnodeRepository->expects($this->any())
967
            ->method('find')
968
            ->will($this->returnValue($textnode1));
969
970
        $this->textnodeRepository->expects($this->any())
971
            ->method('findByTwineId')
972
            ->will($this->returnValue($textnode1));
973
974
        $this->importTwine->run($importfile);
975
    }
976
977
    private function getDummyImportfile(array $data = [])
978
    {