Code Duplication    Length = 76-76 lines in 2 locations

Test/Unit/Block/Info/BasicTest.php 1 location

@@ 36-111 (lines=76) @@
33
use Payone\Core\Model\Entities\TransactionStatus;
34
use Payone\Core\Model\TransactionStatusRepository;
35
36
class BasicTest extends \PHPUnit_Framework_TestCase
37
{
38
    /**
39
     * @var ClassToTest
40
     */
41
    private $classToTest;
42
43
    /**
44
     * @var ObjectManager
45
     */
46
    private $objectManager;
47
48
    /**
49
     * @var Info|\PHPUnit_Framework_MockObject_MockObject
50
     */
51
    private $info;
52
53
    protected function setUp()
54
    {
55
        $this->objectManager = new ObjectManager($this);
56
57
        $order = $this->getMockBuilder(Order::class)->disableOriginalConstructor()->getMock();
58
        $order->method('getPayoneTxid')->willReturn('12345');
59
60
        $this->info = $this->getMockBuilder(Info::class)
61
            ->disableOriginalConstructor()
62
            ->setMethods(['getLastTransId', 'getOrder'])
63
            ->getMock();
64
        $this->info->method('getOrder')->willReturn($order);
65
66
        $transactionStatus = $this->getMockBuilder(TransactionStatus::class)
67
            ->disableOriginalConstructor()
68
            ->setMethods([
69
                'getClearingBankcode',
70
                'getClearingBankaccountholder',
71
                'getClearingBankaccount',
72
                'getClearingBankiban',
73
                'getClearingBankbic',
74
                'getClearingBankname'
75
            ])
76
            ->getMock();
77
        $transactionStatus->method('getClearingBankcode')->willReturn('12345');
78
        $transactionStatus->method('getClearingBankaccountholder')->willReturn('12345');
79
        $transactionStatus->method('getClearingBankaccount')->willReturn('12345');
80
        $transactionStatus->method('getClearingBankiban')->willReturn('12345');
81
        $transactionStatus->method('getClearingBankbic')->willReturn('12345');
82
        $transactionStatus->method('getClearingBankname')->willReturn('12345');
83
84
        $transactionStatusRepository = $this->getMockBuilder(TransactionStatusRepository::class)->disableOriginalConstructor()->getMock();
85
        $transactionStatusRepository->method('getAppointedByTxid')->willReturn($transactionStatus);
86
87
        $this->classToTest = $this->objectManager->getObject(ClassToTest::class, [
88
            'transactionStatusRepository' => $transactionStatusRepository
89
        ]);
90
        $this->classToTest->setInfo($this->info);
91
    }
92
93
    public function testPrepareSpecificInformation()
94
    {
95
        $this->info->method('getLastTransId')->willReturn('12345');
96
97
        $result = $this->classToTest->getSpecificInformation();
98
        $this->assertArrayHasKey('IBAN:', $result);
99
100
        $result = $this->classToTest->getSpecificInformation();
101
        $this->assertNotEmpty($result);
102
    }
103
104
    public function testPrepareSpecificInformationNoLastTransId()
105
    {
106
        $this->info->method('getLastTransId')->willReturn('');
107
108
        $result = $this->classToTest->getSpecificInformation();
109
        $this->assertArrayHasKey('Payment has not been processed yet.', $result);
110
    }
111
}
112

Test/Unit/Block/Info/SafeInvoiceTest.php 1 location

@@ 36-111 (lines=76) @@
33
use Payone\Core\Model\Entities\TransactionStatus;
34
use Payone\Core\Model\TransactionStatusRepository;
35
36
class SafeInvoiceTest extends \PHPUnit_Framework_TestCase
37
{
38
    /**
39
     * @var ClassToTest
40
     */
41
    private $classToTest;
42
43
    /**
44
     * @var ObjectManager
45
     */
46
    private $objectManager;
47
48
    /**
49
     * @var Info|\PHPUnit_Framework_MockObject_MockObject
50
     */
51
    private $info;
52
53
    protected function setUp()
54
    {
55
        $this->objectManager = new ObjectManager($this);
56
57
        $order = $this->getMockBuilder(Order::class)->disableOriginalConstructor()->getMock();
58
        $order->method('getPayoneTxid')->willReturn('12345');
59
60
        $this->info = $this->getMockBuilder(Info::class)
61
            ->disableOriginalConstructor()
62
            ->setMethods(['getLastTransId', 'getOrder'])
63
            ->getMock();
64
        $this->info->method('getOrder')->willReturn($order);
65
66
        $transactionStatus = $this->getMockBuilder(TransactionStatus::class)
67
            ->disableOriginalConstructor()
68
            ->setMethods([
69
                'getClearingBankcode',
70
                'getClearingBankaccountholder',
71
                'getClearingBankaccount',
72
                'getClearingBankiban',
73
                'getClearingBankbic',
74
                'getClearingBankname'
75
            ])
76
            ->getMock();
77
        $transactionStatus->method('getClearingBankcode')->willReturn('12345');
78
        $transactionStatus->method('getClearingBankaccountholder')->willReturn('12345');
79
        $transactionStatus->method('getClearingBankaccount')->willReturn('12345');
80
        $transactionStatus->method('getClearingBankiban')->willReturn('12345');
81
        $transactionStatus->method('getClearingBankbic')->willReturn('12345');
82
        $transactionStatus->method('getClearingBankname')->willReturn('12345');
83
84
        $transactionStatusRepository = $this->getMockBuilder(TransactionStatusRepository::class)->disableOriginalConstructor()->getMock();
85
        $transactionStatusRepository->method('getAppointedByTxid')->willReturn($transactionStatus);
86
87
        $this->classToTest = $this->objectManager->getObject(ClassToTest::class, [
88
            'transactionStatusRepository' => $transactionStatusRepository
89
        ]);
90
        $this->classToTest->setInfo($this->info);
91
    }
92
93
    public function testPrepareSpecificInformation()
94
    {
95
        $this->info->method('getLastTransId')->willReturn('12345');
96
97
        $result = $this->classToTest->getSpecificInformation();
98
        $this->assertArrayHasKey('IBAN:', $result);
99
100
        $result = $this->classToTest->getSpecificInformation();
101
        $this->assertNotEmpty($result);
102
    }
103
104
    public function testPrepareSpecificInformationNoLastTransId()
105
    {
106
        $this->info->method('getLastTransId')->willReturn('');
107
108
        $result = $this->classToTest->getSpecificInformation();
109
        $this->assertArrayHasKey('Payment has not been processed yet.', $result);
110
    }
111
}
112