11
11
use Doctrine \DBAL \Platforms \SqlitePlatform ;
12
12
use Doctrine \DBAL \Schema \Schema ;
13
13
use PHPUnit \Framework \TestCase ;
14
- use Prophecy \PhpUnit \ProphecyTrait ;
15
14
16
15
/** @covers \Brainbits\FunctionalTestHelpers\Schema\SchemaTrait */
17
16
final class SchemaTraitTest extends TestCase
18
17
{
19
- use ProphecyTrait;
20
18
use SchemaTrait;
21
19
22
20
public function testApplySchema (): void
23
21
{
24
22
$ schemaBuilder = $ this ->createSchemaBuilder ();
25
23
$ schemaBuilder ->foo ();
26
24
27
- $ connection = $ this ->prophesize (Connection::class);
28
- $ connection ->getDatabasePlatform ()
25
+ $ connection = $ this ->createMock (Connection::class);
26
+ $ connection ->expects ($ this ->once ())
27
+ ->method ('getDatabasePlatform ' )
29
28
->willReturn (new SqlitePlatform ());
30
- $ connection ->executeStatement ('CREATE TABLE foo (bar VARCHAR(255) NOT NULL) ' )
31
- ->shouldBeCalled ();
29
+ $ connection ->expects ($ this ->once ())
30
+ ->method ('executeStatement ' )
31
+ ->with ('CREATE TABLE foo (bar VARCHAR(255) NOT NULL) ' );
32
32
33
- $ this ->applySchema ($ schemaBuilder , $ connection-> reveal () );
33
+ $ this ->applySchema ($ schemaBuilder , $ connection );
34
34
}
35
35
36
36
public function testApplyDataWithQuoteTableName (): void
37
37
{
38
38
$ dataBuilder = $ this ->createDataBuilder ();
39
39
$ dataBuilder ->foo ('baz ' );
40
40
41
- $ connection = $ this ->prophesize (Connection::class);
42
- $ connection ->getDatabasePlatform ( )
43
- ->willReturn ( new SqlitePlatform ());
44
- $ connection -> quoteIdentifier ('foo ' )
41
+ $ connection = $ this ->createMock (Connection::class);
42
+ $ connection ->expects ( $ this -> once () )
43
+ ->method ( ' quoteIdentifier ' )
44
+ -> with ('foo ' )
45
45
->willReturn ('#foo# ' );
46
- $ connection ->insert ('#foo# ' , ['bar ' => 'baz ' ])
47
- ->shouldBeCalled ();
46
+ $ connection ->expects ($ this ->once ())
47
+ ->method ('insert ' )
48
+ ->with ('#foo# ' , ['bar ' => 'baz ' ]);
48
49
49
- $ this ->applyData ($ dataBuilder , $ connection-> reveal () );
50
+ $ this ->applyData ($ dataBuilder , $ connection );
50
51
}
51
52
52
53
public function testApplyDataWithoutQuoteTableName (): void
53
54
{
54
55
$ dataBuilder = $ this ->createDataBuilder ();
55
56
$ dataBuilder ->foo ('baz ' );
56
57
57
- $ connection = $ this ->prophesize (Connection::class);
58
- $ connection ->getDatabasePlatform ( )
59
- ->willReturn ( new SqlitePlatform ());
60
- $ connection -> quoteIdentifier ('foo ' )
61
- -> shouldNotBeCalled ();
62
- $ connection -> insert ( ' foo ' , [ ' bar ' => ' baz ' ] )
63
- ->shouldBeCalled ( );
58
+ $ connection = $ this ->createMock (Connection::class);
59
+ $ connection ->expects ( $ this -> never () )
60
+ ->method ( ' quoteIdentifier ' )
61
+ -> with ('foo ' );
62
+ $ connection -> expects ( $ this -> once ())
63
+ -> method ( ' insert ' )
64
+ ->with ( ' foo ' , [ ' bar ' => ' baz ' ] );
64
65
65
- $ this ->applyData ($ dataBuilder , $ connection-> reveal () , false );
66
+ $ this ->applyData ($ dataBuilder , $ connection , false );
66
67
}
67
68
68
69
public function testFixtureFromConnectionWithTableNameQuote (): void
69
70
{
70
71
$ schemaBuilder = $ this ->createSchemaBuilder ();
71
72
$ dataBuilder = $ this ->createDataBuilder ($ schemaBuilder );
72
73
73
- $ connection = $ this ->prophesize (Connection::class);
74
- $ connection ->getDatabasePlatform ()
74
+ $ connection = $ this ->createMock (Connection::class);
75
+ $ connection ->expects ($ this ->once ())
76
+ ->method ('getDatabasePlatform ' )
75
77
->willReturn (new SqlitePlatform ());
76
- $ connection ->executeStatement ('CREATE TABLE foo (bar VARCHAR(255) NOT NULL) ' )
77
- ->shouldBeCalled ();
78
- $ connection ->quoteIdentifier ('foo ' )
78
+ $ connection ->expects ($ this ->once ())
79
+ ->method ('executeStatement ' )
80
+ ->with ('CREATE TABLE foo (bar VARCHAR(255) NOT NULL) ' );
81
+ $ connection ->expects ($ this ->once ())
82
+ ->method ('quoteIdentifier ' )
83
+ ->with ('foo ' )
79
84
->willReturn ('#foo# ' );
80
- $ connection ->insert ('#foo# ' , ['bar ' => 'baz ' ])
81
- ->shouldBeCalled ();
85
+ $ connection ->expects ($ this ->once ())
86
+ ->method ('insert ' )
87
+ ->with ('#foo# ' , ['bar ' => 'baz ' ]);
82
88
83
89
$ this ->fixtureFromConnection (
84
- $ connection-> reveal () ,
90
+ $ connection ,
85
91
$ schemaBuilder ,
86
92
$ dataBuilder ,
87
93
static function ($ dataBuilder ): void {
@@ -95,18 +101,19 @@ public function testFixtureFromConnectionWithoutTableNameQuote(): void
95
101
$ schemaBuilder = $ this ->createSchemaBuilder ();
96
102
$ dataBuilder = $ this ->createDataBuilder ($ schemaBuilder );
97
103
98
- $ connection = $ this ->prophesize (Connection::class);
99
- $ connection ->getDatabasePlatform ()
104
+ $ connection = $ this ->createMock (Connection::class);
105
+ $ connection ->expects ($ this ->once ())
106
+ ->method ('getDatabasePlatform ' )
100
107
->willReturn (new SqlitePlatform ());
101
- $ connection ->executeStatement ( ' CREATE TABLE foo (bar VARCHAR(255) NOT NULL) ' )
102
- ->shouldBeCalled ();
103
- $ connection -> quoteIdentifier ( ' foo ' )
104
- -> willReturn ( ' foo ' );
105
- $ connection -> insert ( ' foo ' , [ ' bar ' => ' baz ' ] )
106
- ->shouldBeCalled ( );
108
+ $ connection ->expects ( $ this -> once () )
109
+ ->method ( ' executeStatement ' )
110
+ -> with ( ' CREATE TABLE foo (bar VARCHAR(255) NOT NULL) ' );
111
+ $ connection -> expects ( $ this -> once ())
112
+ -> method ( ' insert ' )
113
+ ->with ( ' foo ' , [ ' bar ' => ' baz ' ] );
107
114
108
115
$ this ->fixtureFromConnection (
109
- $ connection-> reveal () ,
116
+ $ connection ,
110
117
$ schemaBuilder ,
111
118
$ dataBuilder ,
112
119
static function ($ dataBuilder ): void {
0 commit comments