Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
NullableTest.php
Go to the documentation of this file.
1 <?php
7 
12 
13 class NullableTest extends \PHPUnit\Framework\TestCase
14 {
18  private $objectManager;
19 
23  private $nullable;
24 
25  protected function setUp()
26  {
27  $this->objectManager = new ObjectManager($this);
28  $this->nullable = $this->objectManager->getObject(
29  Nullable::class
30  );
31  }
32 
36  public function testToDefinition()
37  {
39  $column = $this->getMockBuilder(BooleanColumnDto::class)
40  ->disableOriginalConstructor()
41  ->setMethods(['isNullable'])
42  ->getMock();
43  $column->expects($this->any())
44  ->method('isNullable')
45  ->willReturn(true);
46  $this->assertEquals(
47  'NULL',
48  $this->nullable->toDefinition($column)
49  );
50  }
51 
55  public function testToDefinitionNotNull()
56  {
58  $column = $this->getMockBuilder(BooleanColumnDto::class)
59  ->disableOriginalConstructor()
60  ->setMethods(['isNullable'])
61  ->getMock();
62  $column->expects($this->any())
63  ->method('isNullable')
64  ->willReturn(false);
65  $this->assertEquals(
66  'NOT NULL',
67  $this->nullable->toDefinition($column)
68  );
69  }
70 
74  public function testToDefinitionNotNullableAware()
75  {
77  $column = $this->getMockBuilder(ElementInterface::class)
78  ->disableOriginalConstructor()
79  ->getMock();
80  $this->assertEquals(
81  '',
82  $this->nullable->toDefinition($column)
83  );
84  }
85 }