Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TransferFactoryTest.php
Go to the documentation of this file.
1 <?php
7 
11 
15 class TransferFactoryTest extends \PHPUnit\Framework\TestCase
16 {
20  private $transferFactory;
21 
25  private $transferMock;
26 
30  private $transferBuilder;
31 
32  protected function setUp()
33  {
34  $this->transferBuilder = $this->createMock(TransferBuilder::class);
35  $this->transferMock = $this->createMock(TransferInterface::class);
36 
37  $this->transferFactory = new TransferFactory(
38  $this->transferBuilder
39  );
40  }
41 
42  public function testCreate()
43  {
44  $request = ['data1', 'data2'];
45 
46  $this->transferBuilder->expects($this->once())
47  ->method('setBody')
48  ->with($request)
49  ->willReturnSelf();
50 
51  $this->transferBuilder->expects($this->once())
52  ->method('build')
53  ->willReturn($this->transferMock);
54 
55  $this->assertEquals($this->transferMock, $this->transferFactory->create($request));
56  }
57 }