Code Duplication    Length = 12-19 lines in 5 locations

eZ/Publish/API/Repository/Tests/BookmarkServiceTest.php 2 locations

@@ 79-90 (lines=12) @@
76
     * @depends testCreateBookmark
77
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
78
     */
79
    public function testCreateBookmarkThrowsInvalidArgumentException()
80
    {
81
        $repository = $this->getRepository();
82
83
        /* BEGIN: Use Case */
84
        $bookmarkService = $repository->getBookmarkService();
85
        $locationService = $repository->getLocationService();
86
87
        $location = $locationService->loadLocation($this->generateId('location', self::LOCATION_ID_BOOKMARKED));
88
        $bookmarkService->createBookmark($location);
89
        /* END: Use Case */
90
    }
91
92
    /**
93
     * @covers \eZ\Publish\Core\Repository\BookmarkService::deleteBookmark
@@ 119-130 (lines=12) @@
116
     * @depends testDeleteBookmark
117
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
118
     */
119
    public function testDeleteBookmarkThrowsInvalidArgumentException()
120
    {
121
        $repository = $this->getRepository();
122
123
        /* BEGIN: Use Case */
124
        $bookmarkService = $repository->getBookmarkService();
125
        $locationService = $repository->getLocationService();
126
127
        $location = $locationService->loadLocation($this->generateId('location', self::LOCATION_ID_NOT_BOOKMARKED));
128
        $bookmarkService->deleteBookmark($location);
129
        /* END: Use Case */
130
    }
131
132
    /**
133
     * @covers \eZ\Publish\Core\Repository\BookmarkService::loadBookmarks

eZ/Publish/API/Repository/Tests/LocationServiceAuthorizationTest.php 2 locations

@@ 130-147 (lines=18) @@
127
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
128
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation
129
     */
130
    public function testLoadLocationThrowsUnauthorizedException()
131
    {
132
        $repository = $this->getRepository();
133
134
        $editorsGroupId = $this->generateId('group', 13);
135
136
        /* BEGIN: Use Case */
137
        $locationService = $repository->getLocationService();
138
139
        $user = $this->createUserVersion1();
140
141
        // Set current user to newly created user
142
        $repository->setCurrentUser($user);
143
144
        // This call will fail with an "UnauthorizedException"
145
        $locationService->loadLocation($editorsGroupId);
146
        /* END: Use Case */
147
    }
148
149
    /**
150
     * Test for the loadLocationList() method.
@@ 177-195 (lines=19) @@
174
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
175
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocationByRemoteId
176
     */
177
    public function testLoadLocationByRemoteIdThrowsUnauthorizedException()
178
    {
179
        $repository = $this->getRepository();
180
181
        /* BEGIN: Use Case */
182
        // remoteId of the "Editors" location in an eZ Publish demo installation
183
        $editorsRemoteId = 'f7dda2854fc68f7c8455d9cb14bd04a9';
184
185
        $locationService = $repository->getLocationService();
186
187
        $user = $this->createUserVersion1();
188
189
        // Set current user to newly created user
190
        $repository->setCurrentUser($user);
191
192
        // This call will fail with an "UnauthorizedException"
193
        $locationService->loadLocationByRemoteId($editorsRemoteId);
194
        /* END: Use Case */
195
    }
196
197
    /**
198
     * Test for the loadLocations() method.

eZ/Publish/API/Repository/Tests/LocationServiceTest.php 1 location

@@ 642-658 (lines=17) @@
639
     * @see \eZ\Publish\API\Repository\LocationService::loadLocationByRemoteId()
640
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation
641
     */
642
    public function testLoadLocationByRemoteId()
643
    {
644
        $repository = $this->getRepository();
645
646
        /* BEGIN: Use Case */
647
        $locationService = $repository->getLocationService();
648
649
        $location = $locationService->loadLocationByRemoteId(
650
            '3f6d92f8044aed134f32153517850f5a'
651
        );
652
        /* END: Use Case */
653
654
        $this->assertEquals(
655
            $locationService->loadLocation($this->generateId('location', 5)),
656
            $location
657
        );
658
    }
659
660
    /**
661
     * Test for the loadLocationByRemoteId() method.