1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2012 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
declare (strict_types=1 );
7
7
15
15
use Magento \Framework \DB \SelectFactory ;
16
16
use Magento \Framework \Model \ResourceModel \Type \Db \Pdo \Mysql ;
17
17
use Magento \Framework \Serialize \SerializerInterface ;
18
+ use Magento \Framework \Setup \Declaration \Schema \Dto \Factories \Table as DtoFactoriesTable ;
18
19
use Magento \Framework \Setup \SchemaListener ;
19
20
use Magento \Framework \Stdlib \DateTime ;
20
21
use Magento \Framework \Stdlib \StringUtils ;
@@ -55,6 +56,11 @@ class MysqlTest extends TestCase
55
56
*/
56
57
private $ connection ;
57
58
59
+ /**
60
+ * @var LoggerInterface|MockObject
61
+ */
62
+ private $ logger ;
63
+
58
64
/**
59
65
* Setup
60
66
*/
@@ -741,10 +747,11 @@ private function getMysqlPdoAdapterMock(array $methods): MockObject
741
747
742
748
$ string = $ this ->createMock (StringUtils::class);
743
749
$ dateTime = $ this ->createMock (DateTime::class);
744
- $ logger = $ this ->getMockForAbstractClass (LoggerInterface::class);
750
+ $ this -> logger = $ this ->createMock (LoggerInterface::class);
745
751
$ selectFactory = $ this ->getMockBuilder (SelectFactory::class)
746
752
->disableOriginalConstructor ()
747
753
->getMock ();
754
+ $ dtoFactoriesTable = $ this ->createMock (DtoFactoriesTable::class);
748
755
749
756
$ adapterMock = $ this ->getMockBuilder (PdoMysqlAdapter::class)
750
757
->onlyMethods (
@@ -753,14 +760,15 @@ private function getMysqlPdoAdapterMock(array $methods): MockObject
753
760
[
754
761
'string ' => $ string ,
755
762
'dateTime ' => $ dateTime ,
756
- 'logger ' => $ logger ,
763
+ 'logger ' => $ this -> logger ,
757
764
'selectFactory ' => $ selectFactory ,
758
765
'config ' => [
759
766
'dbname ' => 'not_exists ' ,
760
767
'username ' => 'not_valid ' ,
761
768
'password ' => 'not_valid ' ,
762
769
],
763
770
'serializer ' => $ this ->serializerMock ,
771
+ 'dtoFactoriesTable ' => $ dtoFactoriesTable ,
764
772
]
765
773
)
766
774
->getMock ();
@@ -1067,4 +1075,15 @@ public static function exceptionDataProvider(): array
1067
1075
[new \Exception ()],
1068
1076
];
1069
1077
}
1078
+
1079
+ public function testDestruct (): void
1080
+ {
1081
+ $ adapter = $ this ->getMysqlPdoAdapterMock (['_connect ' , '_rollBack ' ]);
1082
+ $ this ->addConnectionMock ($ adapter );
1083
+ $ adapter ->expects ($ this ->once ())->method ('_rollBack ' );
1084
+ $ this ->logger ->expects ($ this ->once ())->method ('log ' );
1085
+ $ adapter ->beginTransaction ();
1086
+ $ adapter ->__destruct ();
1087
+ $ this ->assertEquals (0 , $ adapter ->getTransactionLevel ());
1088
+ }
1070
1089
}
0 commit comments