1111use Neo4j \Neo4jBundle \Decorators \SymfonyTransaction ;
1212use Neo4j \Neo4jBundle \EventHandler ;
1313use Neo4j \Neo4jBundle \Factories \SymfonyDriverFactory ;
14+ use PHPUnit \Framework \MockObject \MockObject ;
1415use PHPUnit \Framework \TestCase ;
1516
1617class SymfonySessionTest extends TestCase
1718{
18- private Session $ sessionMock ;
19- private EventHandler $ handlerMock ;
20- private SymfonyDriverFactory $ factoryMock ;
19+ private MockObject & Session $ sessionMock ;
20+ private MockObject & EventHandler $ handlerMock ;
21+ private MockObject & SymfonyDriverFactory $ factoryMock ;
2122 private SymfonySession $ symfonySession ;
2223 private string $ alias = 'default ' ;
2324 private string $ schema = 'neo4j ' ;
@@ -29,6 +30,13 @@ protected function setUp(): void
2930 $ this ->handlerMock = $ this ->createMock (EventHandler::class);
3031 $ this ->factoryMock = $ this ->createMock (SymfonyDriverFactory::class);
3132
33+ $ this ->symfonySession = new SymfonySession (
34+ $ this ->sessionMock ,
35+ $ this ->createMock (EventHandler::class),
36+ $ this ->createMock (SymfonyDriverFactory::class),
37+ 'default ' ,
38+ 'bolt '
39+ );
3240
3341 $ this ->symfonySession = new SymfonySession (
3442 $ this ->sessionMock ,
@@ -39,7 +47,7 @@ protected function setUp(): void
3947 );
4048 }
4149
42- public function testRunStatement ()
50+ public function testRunStatement (): void
4351 {
4452 $ statementMock = $ this ->createMock (Statement::class);
4553 $ resultMock = $ this ->createMock (SummarizedResult::class);
@@ -61,7 +69,7 @@ public function testRunStatement()
6169 $ this ->assertInstanceOf (SummarizedResult::class, $ result );
6270 }
6371
64- public function testRunStatements ()
72+ public function testRunStatements (): void
6573 {
6674 $ statementMock1 = $ this ->createMock (Statement::class);
6775 $ statementMock2 = $ this ->createMock (Statement::class);
@@ -79,7 +87,7 @@ public function testRunStatements()
7987 }
8088
8189
82- public function testBeginTransaction ()
90+ public function testBeginTransaction (): void
8391 {
8492 $ transactionMock = $ this ->createMock (SymfonyTransaction::class);
8593
@@ -100,7 +108,7 @@ public function testBeginTransaction()
100108 $ this ->assertInstanceOf (SymfonyTransaction::class, $ transaction );
101109 }
102110
103- public function testWriteTransaction ()
111+ public function testWriteTransaction (): void
104112 {
105113 $ transactionMock = $ this ->createMock (SymfonyTransaction::class);
106114
@@ -109,7 +117,7 @@ public function testWriteTransaction()
109117 ->method ('createTransaction ' )
110118 ->willReturn ($ transactionMock );
111119
112- $ handler = function ($ tsx ) {
120+ $ handler = function ( SymfonyTransaction $ tsx ) : string {
113121 return 'transaction success ' ;
114122 };
115123
@@ -118,7 +126,7 @@ public function testWriteTransaction()
118126 $ this ->assertEquals ('transaction success ' , $ result );
119127 }
120128
121- public function testGetLastBookmark ()
129+ public function testGetLastBookmark (): void
122130 {
123131 $ bookmarkMock = $ this ->createMock (Bookmark::class);
124132
@@ -130,4 +138,5 @@ public function testGetLastBookmark()
130138 $ bookmark = $ this ->symfonySession ->getLastBookmark ();
131139 $ this ->assertInstanceOf (Bookmark::class, $ bookmark );
132140 }
141+
133142}
0 commit comments