15 class BlobTest extends \PHPUnit\Framework\TestCase
20 private $objectManager;
30 private $nullableMock;
40 private $resourceConnectionMock;
45 $this->nullableMock = $this->getMockBuilder(Nullable::class)
46 ->disableOriginalConstructor()
48 $this->commentMock = $this->getMockBuilder(Comment::class)
49 ->disableOriginalConstructor()
51 $this->resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class)
52 ->disableOriginalConstructor()
54 $this->blob = $this->objectManager->getObject(
57 'nullable' => $this->nullableMock,
58 'comment' => $this->commentMock,
59 'resourceConnection' => $this->resourceConnectionMock
67 public function testToDefinition()
70 $column = $this->getMockBuilder(ElementInterface::class)
71 ->disableOriginalConstructor()
73 $column->expects($this->any())
76 $column->expects($this->any())
79 $adapterMock = $this->getMockBuilder(\
Magento\Framework\DB\Adapter\AdapterInterface::class)
80 ->disableOriginalConstructor()
82 $this->resourceConnectionMock->expects($this->once())->method(
'getConnection')->willReturn($adapterMock);
83 $adapterMock->expects($this->once())
84 ->method(
'quoteIdentifier')
86 ->willReturn(
'`col`');
87 $this->nullableMock->expects($this->any())
88 ->method(
'toDefinition')
91 $this->commentMock->expects($this->any())
92 ->method(
'toDefinition')
94 ->willReturn(
'COMMENT "Comment"');
96 '`col` blob NULL COMMENT "Comment"',
97 $this->blob->toDefinition($column)
111 'definition' => $definition,
113 if ($expectedLength) {
114 $expectedData[
'length'] = $expectedLength;
116 $result = $this->blob->fromDefinition([
'definition' => $definition]);
117 $this->assertEquals($expectedData,
$result);
testFromDefinition($definition, $expectedLength=false)