25 private $objectManager;
30 private $stringBinary;
35 private $nullableMock;
45 private $resourceConnectionMock;
50 $this->nullableMock = $this->getMockBuilder(Nullable::class)
51 ->disableOriginalConstructor()
53 $this->commentMock = $this->getMockBuilder(Comment::class)
54 ->disableOriginalConstructor()
56 $this->resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class)
57 ->disableOriginalConstructor()
59 $this->stringBinary = $this->objectManager->getObject(
62 'nullable' => $this->nullableMock,
63 'comment' => $this->commentMock,
64 'resourceConnection' => $this->resourceConnectionMock
72 public function testToDefinition()
75 $column = $this->getMockBuilder(StringBinaryColumn::class)
76 ->disableOriginalConstructor()
78 $column->expects($this->any())
81 $column->expects($this->any())
83 ->willReturn(
'varchar');
84 $column->expects($this->any())
87 $column->expects($this->any())
88 ->method(
'getDefault')
90 $adapterMock = $this->getMockBuilder(\
Magento\Framework\DB\Adapter\AdapterInterface::class)
91 ->disableOriginalConstructor()
93 $this->resourceConnectionMock->expects($this->once())->method(
'getConnection')->willReturn($adapterMock);
94 $adapterMock->expects($this->once())
95 ->method(
'quoteIdentifier')
97 ->willReturn(
'`col`');
98 $this->nullableMock->expects($this->any())
99 ->method(
'toDefinition')
101 ->willReturn(
'NULL');
102 $this->commentMock->expects($this->any())
103 ->method(
'toDefinition')
105 ->willReturn(
'COMMENT "Comment"');
107 '`col` varchar(50) NULL DEFAULT "test" COMMENT "Comment"',
108 $this->stringBinary->toDefinition($column)
122 'definition' => $definition,
124 if ($expectedLength) {
125 $expectedData[
'length'] = $expectedLength;
127 $result = $this->stringBinary->fromDefinition([
'definition' => $definition]);
128 $this->assertEquals($expectedData,
$result);
140 [
'varchar (30)', 30],
144 [
'varbinary(44)', 44],
testFromDefinition($definition, $expectedLength=false)