Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
HandlerCompositeTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class HandlerCompositeTest extends \PHPUnit\Framework\TestCase
11 {
12  public function testConstructorSuccess()
13  {
14  $handler = $this->getMockBuilder(
15  \Magento\Paypal\Model\Payflow\Service\Response\Handler\HandlerInterface::class
16  )->getMock();
17 
19  ['some_handler' => $handler]
20  );
21  $this->assertNotNull($result);
22  }
23 
24  public function testConstructorException()
25  {
26  $this->expectException('LogicException');
27  $this->expectExceptionMessage(
28  'Type mismatch. Expected type: HandlerInterface. Actual: string, Code: weird_handler'
29  );
30 
31  new HandlerComposite(
32  ['weird_handler' => 'some value']
33  );
34  }
35 
36  public function testHandle()
37  {
38  $paymentMock = $this->getMockBuilder(\Magento\Payment\Model\InfoInterface::class)
39  ->getMock();
40  $responseMock = $this->getMockBuilder(\Magento\Framework\DataObject::class)
41  ->disableOriginalConstructor()
42  ->getMock();
43 
44  $handler = $this->getMockBuilder(
45  \Magento\Paypal\Model\Payflow\Service\Response\Handler\HandlerInterface::class
46  )->getMock();
47  $handler->expects($this->once())
48  ->method('handle')
49  ->with($paymentMock, $responseMock);
50 
51  $composite = new HandlerComposite(
52  ['some_handler' => $handler]
53  );
54 
55  $composite->handle($paymentMock, $responseMock);
56  }
57 }
catch(\Exception $e) $handler
Definition: index.php:30