11
11
use Neo4j \Neo4jBundle \Decorators \SymfonyTransaction ;
12
12
use Neo4j \Neo4jBundle \EventHandler ;
13
13
use Neo4j \Neo4jBundle \Factories \SymfonyDriverFactory ;
14
+ use PHPUnit \Framework \MockObject \MockObject ;
14
15
use PHPUnit \Framework \TestCase ;
15
16
16
17
class SymfonySessionTest extends TestCase
17
18
{
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 ;
21
22
private SymfonySession $ symfonySession ;
22
23
private string $ alias = 'default ' ;
23
24
private string $ schema = 'neo4j ' ;
@@ -29,6 +30,13 @@ protected function setUp(): void
29
30
$ this ->handlerMock = $ this ->createMock (EventHandler::class);
30
31
$ this ->factoryMock = $ this ->createMock (SymfonyDriverFactory::class);
31
32
33
+ $ this ->symfonySession = new SymfonySession (
34
+ $ this ->sessionMock ,
35
+ $ this ->createMock (EventHandler::class),
36
+ $ this ->createMock (SymfonyDriverFactory::class),
37
+ 'default ' ,
38
+ 'bolt '
39
+ );
32
40
33
41
$ this ->symfonySession = new SymfonySession (
34
42
$ this ->sessionMock ,
@@ -39,7 +47,7 @@ protected function setUp(): void
39
47
);
40
48
}
41
49
42
- public function testRunStatement ()
50
+ public function testRunStatement (): void
43
51
{
44
52
$ statementMock = $ this ->createMock (Statement::class);
45
53
$ resultMock = $ this ->createMock (SummarizedResult::class);
@@ -61,7 +69,7 @@ public function testRunStatement()
61
69
$ this ->assertInstanceOf (SummarizedResult::class, $ result );
62
70
}
63
71
64
- public function testRunStatements ()
72
+ public function testRunStatements (): void
65
73
{
66
74
$ statementMock1 = $ this ->createMock (Statement::class);
67
75
$ statementMock2 = $ this ->createMock (Statement::class);
@@ -79,7 +87,7 @@ public function testRunStatements()
79
87
}
80
88
81
89
82
- public function testBeginTransaction ()
90
+ public function testBeginTransaction (): void
83
91
{
84
92
$ transactionMock = $ this ->createMock (SymfonyTransaction::class);
85
93
@@ -100,7 +108,7 @@ public function testBeginTransaction()
100
108
$ this ->assertInstanceOf (SymfonyTransaction::class, $ transaction );
101
109
}
102
110
103
- public function testWriteTransaction ()
111
+ public function testWriteTransaction (): void
104
112
{
105
113
$ transactionMock = $ this ->createMock (SymfonyTransaction::class);
106
114
@@ -109,7 +117,7 @@ public function testWriteTransaction()
109
117
->method ('createTransaction ' )
110
118
->willReturn ($ transactionMock );
111
119
112
- $ handler = function ($ tsx ) {
120
+ $ handler = function ( SymfonyTransaction $ tsx ) : string {
113
121
return 'transaction success ' ;
114
122
};
115
123
@@ -118,7 +126,7 @@ public function testWriteTransaction()
118
126
$ this ->assertEquals ('transaction success ' , $ result );
119
127
}
120
128
121
- public function testGetLastBookmark ()
129
+ public function testGetLastBookmark (): void
122
130
{
123
131
$ bookmarkMock = $ this ->createMock (Bookmark::class);
124
132
@@ -130,4 +138,5 @@ public function testGetLastBookmark()
130
138
$ bookmark = $ this ->symfonySession ->getLastBookmark ();
131
139
$ this ->assertInstanceOf (Bookmark::class, $ bookmark );
132
140
}
141
+
133
142
}
0 commit comments