Code Duplication    Length = 9-11 lines in 6 locations

tests/DMSDocumentCartTest.php 5 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 testGetItemsAsArrayList()
80
    {
@@ 79-89 (lines=11) @@
76
        $this->assertCount(1, $this->cart->getItems());
77
    }
78
79
    public function testGetItemsAsArrayList()
80
    {
81
        $doc = $this->objFromFixture('DMSDocument', 'doc1');
82
        /** @var DMSRequestItem $item */
83
        $item = DMSRequestItem::create();
84
        $item->setDocument($doc)->setQuantity(2);
85
        $this->cart->addItem($item);
86
87
        $this->assertInstanceOf('ArrayList', $this->cart->getItemsAsArrayList());
88
        $this->assertCount(1, $this->cart->getItemsAsArrayList());
89
    }
90
91
    public function testGetReceiverInfo()
92
    {
@@ 98-107 (lines=10) @@
95
        $this->assertEquals($info, $this->cart->getReceiverInfo());
96
    }
97
98
    public function testIsCartEmpty()
99
    {
100
        $this->assertTrue($this->cart->isCartEmpty());
101
        $doc = $this->objFromFixture('DMSDocument', 'doc1');
102
        /** @var DMSRequestItem $item */
103
        $item = DMSRequestItem::create();
104
        $item->setDocument($doc)->setQuantity(2);
105
        $this->cart->addItem($item);
106
        $this->assertFalse($this->cart->isCartEmpty());
107
    }
108
109
    public function testRemoveItem()
110
    {

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