Code Duplication    Length = 24-24 lines in 2 locations

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

@@ 934-957 (lines=24) @@
931
     * @expectedException \Exception
932
     * @expectedExceptionMessage There is a 'tw-passagedata' in the Twine archive file 'somefilename_readable' which is missing its 'pid' attribute.
933
     */
934
    public function testRunWithMissingPid(): void
935
    {
936
        $importfile = $this->getDummyImportfile();
937
938
        $this->fileExtractorMock->expects(self::any())
939
            ->method('extract')
940
            ->willReturn('readable.extracted');
941
942
        self::$freadStack = [
943
            '<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",
944
            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
945
            '<tw-passagedata name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
946
            'lorem ipsum</tw-passagedata>',
947
            '</tw-storydata>',
948
        ];
949
950
        $this->textnodeRepository->expects($this->never())
951
            ->method('find');
952
953
        $this->textnodeRepository->expects($this->never())
954
            ->method('findByTwineId');
955
956
        $this->importTwine->run($importfile);
957
    }
958
959
    /**
960
     * @return void
@@ 964-987 (lines=24) @@
961
     * @expectedException \Exception
962
     * @expectedExceptionMessage There is a 'tw-passagedata' in the Twine archive file 'somefilename_readable' which hasn't a numeric value in its 'pid' attribute ('nonnumeric' was found instead).
963
     */
964
    public function testRunWithNonNumericPid(): void
965
    {
966
        $importfile = $this->getDummyImportfile();
967
968
        $this->fileExtractorMock->expects(self::any())
969
            ->method('extract')
970
            ->willReturn('readable.extracted');
971
972
        self::$freadStack = [
973
            '<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",
974
            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
975
            '<tw-passagedata pid="nonnumeric" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
976
            'lorem ipsum</tw-passagedata>',
977
            '</tw-storydata>',
978
        ];
979
980
        $this->textnodeRepository->expects($this->never())
981
            ->method('find');
982
983
        $this->textnodeRepository->expects($this->never())
984
            ->method('findByTwineId');
985
986
        $this->importTwine->run($importfile);
987
    }
988
989
    /**
990
     * @expectedException \Exception