Code Duplication    Length = 33-33 lines in 2 locations

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

@@ 4584-4616 (lines=33) @@
4581
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo
4582
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts
4583
     */
4584
    public function testDeleteVersionInTransactionWithRollback()
4585
    {
4586
        $repository = $this->getRepository();
4587
4588
        $contentId = $this->generateId('object', 12);
4589
        /* BEGIN: Use Case */
4590
        // $contentId is the ID of the "Administrator users" user group
4591
4592
        // Start a new transaction
4593
        $repository->beginTransaction();
4594
4595
        try {
4596
            // Create a new draft
4597
            $draft = $this->contentService->createContentDraft(
4598
                $this->contentService->loadContentInfo($contentId)
4599
            );
4600
4601
            $this->contentService->deleteVersion($draft->getVersionInfo());
4602
        } catch (Exception $e) {
4603
            // Cleanup hanging transaction on error
4604
            $repository->rollback();
4605
            throw $e;
4606
        }
4607
4608
        // Rollback all changes.
4609
        $repository->rollback();
4610
4611
        // This array will be empty
4612
        $drafts = $this->contentService->loadContentDrafts();
4613
        /* END: Use Case */
4614
4615
        $this->assertSame([], $drafts);
4616
    }
4617
4618
    /**
4619
     * Test for the deleteVersion() method.
@@ 4626-4658 (lines=33) @@
4623
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo
4624
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts
4625
     */
4626
    public function testDeleteVersionInTransactionWithCommit()
4627
    {
4628
        $repository = $this->getRepository();
4629
4630
        $contentId = $this->generateId('object', 12);
4631
        /* BEGIN: Use Case */
4632
        // $contentId is the ID of the "Administrator users" user group
4633
4634
        // Start a new transaction
4635
        $repository->beginTransaction();
4636
4637
        try {
4638
            // Create a new draft
4639
            $draft = $this->contentService->createContentDraft(
4640
                $this->contentService->loadContentInfo($contentId)
4641
            );
4642
4643
            $this->contentService->deleteVersion($draft->getVersionInfo());
4644
4645
            // Commit all changes.
4646
            $repository->commit();
4647
        } catch (Exception $e) {
4648
            // Cleanup hanging transaction on error
4649
            $repository->rollback();
4650
            throw $e;
4651
        }
4652
4653
        // This array will contain no element
4654
        $drafts = $this->contentService->loadContentDrafts();
4655
        /* END: Use Case */
4656
4657
        $this->assertSame([], $drafts);
4658
    }
4659
4660
    /**
4661
     * Test for the deleteContent() method.