Code Duplication    Length = 9-10 lines in 5 locations

tests/DMSDocumentCartTest.php 4 locations

@@ 21-29 (lines=9) @@
18
        $this->cart = singleton('DMSDocumentCart');
19
    }
20
21
    public function testAddItem()
22
    {
23
        $doc = $this->objFromFixture('DMSDocument', 'doc1');
24
        /** @var DMSRequestItem $item */
25
        $item = DMSRequestItem::create();
26
        $item->setDocument($doc)->setQuantity(2);
27
        $this->cart->addItem($item);
28
        $this->assertFalse($this->cart->isCartEmpty());
29
    }
30
31
    public function testEmptyCart()
32
    {
@@ 57-66 (lines=10) @@
54
        $this->assertEquals($url, $this->cart->getBackUrl());
55
    }
56
57
    public function testGetItem()
58
    {
59
        $doc = $this->objFromFixture('DMSDocument', 'doc1');
60
        /** @var DMSRequestItem $item */
61
        $item = DMSRequestItem::create();
62
        $item->setDocument($doc)->setQuantity(2);
63
        $this->cart->addItem($item);
64
65
        $this->assertEquals($doc, $this->cart->getItem($doc->ID)->getDocument());
66
    }
67
68
    public function testGetItems()
69
    {
@@ 68-77 (lines=10) @@
65
        $this->assertEquals($doc, $this->cart->getItem($doc->ID)->getDocument());
66
    }
67
68
    public function testGetItems()
69
    {
70
        $doc = $this->objFromFixture('DMSDocument', 'doc1');
71
        /** @var DMSRequestItem $item */
72
        $item = DMSRequestItem::create();
73
        $item->setDocument($doc)->setQuantity(2);
74
        $this->cart->addItem($item);
75
76
        $this->assertCount(1, $this->cart->getItems());
77
    }
78
79
    public function testGetReceiverInfo()
80
    {
@@ 86-95 (lines=10) @@
83
        $this->assertEquals($info, $this->cart->getReceiverInfo());
84
    }
85
86
    public function testIsCartEmpty()
87
    {
88
        $this->assertTrue($this->cart->isCartEmpty());
89
        $doc = $this->objFromFixture('DMSDocument', 'doc1');
90
        /** @var DMSRequestItem $item */
91
        $item = DMSRequestItem::create();
92
        $item->setDocument($doc)->setQuantity(2);
93
        $this->cart->addItem($item);
94
        $this->assertFalse($this->cart->isCartEmpty());
95
    }
96
97
    public function testRemoveItem()
98
    {

tests/DMSDocumentCartCheckoutPageTest.php 1 location

@@ 50-59 (lines=10) @@
47
    /**
48
     * Tests if print requests are incremented
49
     */
50
    public function testTrackTimestampedPrintRequest()
51
    {
52
        $doc = $this->objFromFixture('DMSDocument', 'doc1');
53
        /** @var DMSRequestItem $item */
54
        $item = DMSRequestItem::create()->setDocument($doc)->setQuantity(2);
55
        $this->cart->addItem($item);
56
57
        $this->controller->trackTimestampedPrintRequest();
58
        $this->assertEquals(1, $item->getDocument()->PrintRequestCount);
59
    }
60
61
    /**
62
     * Tests if a Cart is received