1111use Doctrine \DBAL \Platforms \SqlitePlatform ;
1212use Doctrine \DBAL \Schema \Schema ;
1313use PHPUnit \Framework \TestCase ;
14- use Prophecy \PhpUnit \ProphecyTrait ;
1514
1615/** @covers \Brainbits\FunctionalTestHelpers\Schema\SchemaTrait */
1716final class SchemaTraitTest extends TestCase
1817{
19- use ProphecyTrait;
2018 use SchemaTrait;
2119
2220 public function testApplySchema (): void
2321 {
2422 $ schemaBuilder = $ this ->createSchemaBuilder ();
2523 $ schemaBuilder ->foo ();
2624
27- $ connection = $ this ->prophesize (Connection::class);
28- $ connection ->getDatabasePlatform ()
25+ $ connection = $ this ->createMock (Connection::class);
26+ $ connection ->expects ($ this ->once ())
27+ ->method ('getDatabasePlatform ' )
2928 ->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) ' );
3232
33- $ this ->applySchema ($ schemaBuilder , $ connection-> reveal () );
33+ $ this ->applySchema ($ schemaBuilder , $ connection );
3434 }
3535
3636 public function testApplyDataWithQuoteTableName (): void
3737 {
3838 $ dataBuilder = $ this ->createDataBuilder ();
3939 $ dataBuilder ->foo ('baz ' );
4040
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 ' )
4545 ->willReturn ('#foo# ' );
46- $ connection ->insert ('#foo# ' , ['bar ' => 'baz ' ])
47- ->shouldBeCalled ();
46+ $ connection ->expects ($ this ->once ())
47+ ->method ('insert ' )
48+ ->with ('#foo# ' , ['bar ' => 'baz ' ]);
4849
49- $ this ->applyData ($ dataBuilder , $ connection-> reveal () );
50+ $ this ->applyData ($ dataBuilder , $ connection );
5051 }
5152
5253 public function testApplyDataWithoutQuoteTableName (): void
5354 {
5455 $ dataBuilder = $ this ->createDataBuilder ();
5556 $ dataBuilder ->foo ('baz ' );
5657
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 ' ] );
6465
65- $ this ->applyData ($ dataBuilder , $ connection-> reveal () , false );
66+ $ this ->applyData ($ dataBuilder , $ connection , false );
6667 }
6768
6869 public function testFixtureFromConnectionWithTableNameQuote (): void
6970 {
7071 $ schemaBuilder = $ this ->createSchemaBuilder ();
7172 $ dataBuilder = $ this ->createDataBuilder ($ schemaBuilder );
7273
73- $ connection = $ this ->prophesize (Connection::class);
74- $ connection ->getDatabasePlatform ()
74+ $ connection = $ this ->createMock (Connection::class);
75+ $ connection ->expects ($ this ->once ())
76+ ->method ('getDatabasePlatform ' )
7577 ->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 ' )
7984 ->willReturn ('#foo# ' );
80- $ connection ->insert ('#foo# ' , ['bar ' => 'baz ' ])
81- ->shouldBeCalled ();
85+ $ connection ->expects ($ this ->once ())
86+ ->method ('insert ' )
87+ ->with ('#foo# ' , ['bar ' => 'baz ' ]);
8288
8389 $ this ->fixtureFromConnection (
84- $ connection-> reveal () ,
90+ $ connection ,
8591 $ schemaBuilder ,
8692 $ dataBuilder ,
8793 static function ($ dataBuilder ): void {
@@ -95,18 +101,19 @@ public function testFixtureFromConnectionWithoutTableNameQuote(): void
95101 $ schemaBuilder = $ this ->createSchemaBuilder ();
96102 $ dataBuilder = $ this ->createDataBuilder ($ schemaBuilder );
97103
98- $ connection = $ this ->prophesize (Connection::class);
99- $ connection ->getDatabasePlatform ()
104+ $ connection = $ this ->createMock (Connection::class);
105+ $ connection ->expects ($ this ->once ())
106+ ->method ('getDatabasePlatform ' )
100107 ->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 ' ] );
107114
108115 $ this ->fixtureFromConnection (
109- $ connection-> reveal () ,
116+ $ connection ,
110117 $ schemaBuilder ,
111118 $ dataBuilder ,
112119 static function ($ dataBuilder ): void {
0 commit comments