@@ -88,7 +88,7 @@ public function testPostgresConnectCallsCreateConnectionWithProperArguments()
88
88
public function testPostgresSearchPathIsSet ()
89
89
{
90
90
$ 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 ' ];
92
92
$ connector = $ this ->getMockBuilder (PostgresConnector::class)->onlyMethods (['createConnection ' , 'getOptions ' ])->getMock ();
93
93
$ connection = m::mock (stdClass::class);
94
94
$ connector ->expects ($ this ->once ())->method ('getOptions ' )->with ($ this ->equalTo ($ config ))->willReturn (['options ' ]);
@@ -104,7 +104,7 @@ public function testPostgresSearchPathIsSet()
104
104
public function testPostgresSearchPathArraySupported ()
105
105
{
106
106
$ 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 ' ];
108
108
$ connector = $ this ->getMockBuilder (PostgresConnector::class)->onlyMethods (['createConnection ' , 'getOptions ' ])->getMock ();
109
109
$ connection = m::mock (stdClass::class);
110
110
$ connector ->expects ($ this ->once ())->method ('getOptions ' )->with ($ this ->equalTo ($ config ))->willReturn (['options ' ]);
@@ -117,6 +117,38 @@ public function testPostgresSearchPathArraySupported()
117
117
$ this ->assertSame ($ result , $ connection );
118
118
}
119
119
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
+
120
152
public function testPostgresApplicationNameIsSet ()
121
153
{
122
154
$ dsn = 'pgsql:host=foo;dbname=bar ' ;
0 commit comments