@@ -88,7 +88,7 @@ public function testPostgresConnectCallsCreateConnectionWithProperArguments()
8888 public function testPostgresSearchPathIsSet ()
8989 {
9090 $ dsn = 'pgsql:host=foo;dbname=bar ' ;
91- $ config = ['host ' => 'foo ' , 'database ' => 'bar ' , 'schema ' => 'public ' , 'charset ' => 'utf8 ' ];
91+ $ config = ['host ' => 'foo ' , 'database ' => 'bar ' , 'search_path ' => 'public ' , 'charset ' => 'utf8 ' ];
9292 $ connector = $ this ->getMockBuilder (PostgresConnector::class)->onlyMethods (['createConnection ' , 'getOptions ' ])->getMock ();
9393 $ connection = m::mock (stdClass::class);
9494 $ connector ->expects ($ this ->once ())->method ('getOptions ' )->with ($ this ->equalTo ($ config ))->willReturn (['options ' ]);
@@ -104,7 +104,7 @@ public function testPostgresSearchPathIsSet()
104104 public function testPostgresSearchPathArraySupported ()
105105 {
106106 $ dsn = 'pgsql:host=foo;dbname=bar ' ;
107- $ config = ['host ' => 'foo ' , 'database ' => 'bar ' , 'schema ' => ['public ' , 'user ' ], 'charset ' => 'utf8 ' ];
107+ $ config = ['host ' => 'foo ' , 'database ' => 'bar ' , 'search_path ' => ['public ' , '" user" ' ], 'charset ' => 'utf8 ' ];
108108 $ connector = $ this ->getMockBuilder (PostgresConnector::class)->onlyMethods (['createConnection ' , 'getOptions ' ])->getMock ();
109109 $ connection = m::mock (stdClass::class);
110110 $ connector ->expects ($ this ->once ())->method ('getOptions ' )->with ($ this ->equalTo ($ config ))->willReturn (['options ' ]);
@@ -117,6 +117,38 @@ public function testPostgresSearchPathArraySupported()
117117 $ this ->assertSame ($ result , $ connection );
118118 }
119119
120+ public function testPostgresSearchPathCommaSeparatedValueSupported ()
121+ {
122+ $ dsn = 'pgsql:host=foo;dbname=bar ' ;
123+ $ config = ['host ' => 'foo ' , 'database ' => 'bar ' , 'search_path ' => 'public, "user" ' , 'charset ' => 'utf8 ' ];
124+ $ connector = $ this ->getMockBuilder ('Illuminate\Database\Connectors\PostgresConnector ' )->setMethods (['createConnection ' , 'getOptions ' ])->getMock ();
125+ $ connection = m::mock ('stdClass ' );
126+ $ connector ->expects ($ this ->once ())->method ('getOptions ' )->with ($ this ->equalTo ($ config ))->will ($ this ->returnValue (['options ' ]));
127+ $ connector ->expects ($ this ->once ())->method ('createConnection ' )->with ($ this ->equalTo ($ dsn ), $ this ->equalTo ($ config ), $ this ->equalTo (['options ' ]))->will ($ this ->returnValue ($ connection ));
128+ $ connection ->shouldReceive ('prepare ' )->once ()->with ('set names \'utf8 \'' )->andReturn ($ connection );
129+ $ connection ->shouldReceive ('prepare ' )->once ()->with ('set search_path to "public", "user" ' )->andReturn ($ connection );
130+ $ connection ->shouldReceive ('execute ' )->twice ();
131+ $ result = $ connector ->connect ($ config );
132+
133+ $ this ->assertSame ($ result , $ connection );
134+ }
135+
136+ public function testPostgresSearchPathVariablesSupported ()
137+ {
138+ $ dsn = 'pgsql:host=foo;dbname=bar ' ;
139+ $ config = ['host ' => 'foo ' , 'database ' => 'bar ' , 'search_path ' => '"$user", public, user ' , 'charset ' => 'utf8 ' ];
140+ $ connector = $ this ->getMockBuilder ('Illuminate\Database\Connectors\PostgresConnector ' )->setMethods (['createConnection ' , 'getOptions ' ])->getMock ();
141+ $ connection = m::mock ('stdClass ' );
142+ $ connector ->expects ($ this ->once ())->method ('getOptions ' )->with ($ this ->equalTo ($ config ))->will ($ this ->returnValue (['options ' ]));
143+ $ connector ->expects ($ this ->once ())->method ('createConnection ' )->with ($ this ->equalTo ($ dsn ), $ this ->equalTo ($ config ), $ this ->equalTo (['options ' ]))->will ($ this ->returnValue ($ connection ));
144+ $ connection ->shouldReceive ('prepare ' )->once ()->with ('set names \'utf8 \'' )->andReturn ($ connection );
145+ $ connection ->shouldReceive ('prepare ' )->once ()->with ('set search_path to "$user", "public", "user" ' )->andReturn ($ connection );
146+ $ connection ->shouldReceive ('execute ' )->twice ();
147+ $ result = $ connector ->connect ($ config );
148+
149+ $ this ->assertSame ($ result , $ connection );
150+ }
151+
120152 public function testPostgresApplicationNameIsSet ()
121153 {
122154 $ dsn = 'pgsql:host=foo;dbname=bar ' ;
0 commit comments