Code Duplication    Length = 24-26 lines in 3 locations

www/src/AdminBundle/Tests/Model/ImportTwineTest.php 3 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
     * @return void
@@ 994-1019 (lines=26) @@
991
     * @expectedException \Exception
992
     * @expectedExceptionMessage Nested 'tw-passagedata' found in Twine archive file 'somefilename_readable
993
     */
994
    public function testRunWithNestedPassageData(): void
995
    {
996
        $importfile = $this->getDummyImportfile();
997
998
        $this->fileExtractorMock->expects(self::any())
999
            ->method('extract')
1000
            ->willReturn('readable.extracted');
1001
1002
        self::$freadStack = [
1003
            '<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",
1004
            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
1005
            '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">',
1006
            '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId2" position="104,40">Lorem Ipsum',
1007
            'lorem ipsum</tw-passagedata>',
1008
            '</tw-passagedata>',
1009
            '</tw-storydata>',
1010
        ];
1011
1012
        $this->textnodeRepository->expects($this->never())
1013
            ->method('find');
1014
1015
        $this->textnodeRepository->expects($this->once())
1016
            ->method('findByTwineId');
1017
1018
        $this->importTwine->run($importfile);
1019
    }
1020
1021
    /**
1022
     * @expectedException \Exception