FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
framework/tests/Database/DatabaseConnectionFactoryTest.php at master · JavaDevl/framework · GitHub
JavaDevl
/
framework
Public
forked from
laravel/framework
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
framework
/
tests
/
Database
/
DatabaseConnectionFactoryTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
73 lines (61 loc) · 2.3 KB
Breadcrumbs
framework
/
tests
/
Database
/
DatabaseConnectionFactoryTest.php
Copy path
File metadata and controls
executable file
·
73 lines (61 loc) · 2.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
use
Mockery
as
m
;
use
Illuminate
\
Database
\
Connection
;
use
Illuminate
\
Database
\
Capsule
\
Manager
as
DB
;
class
DatabaseConnectionFactoryTest
extends
PHPUnit_Framework_TestCase
{
protected
$
db
;
public
function
setUp
()
{
$
this
->
db
=
new
DB
;
$
this
->
db
->
addConnection
([
'
driver
'
=>
'
sqlite
'
,
'
database
'
=>
'
:memory:
'
,
]);
$
this
->
db
->
addConnection
([
'
driver
'
=>
'
sqlite
'
,
'
read
'
=> [
'
database
'
=>
'
:memory:
'
,
],
'
write
'
=> [
'
database
'
=>
'
:memory:
'
,
],
],
'
read_write
'
);
$
this
->
db
->
setAsGlobal
();
}
public
function
tearDown
()
{
m::
close
();
}
public
function
testConnectionCanBeCreated
()
{
$
this
->
assertInstanceOf
(
'
PDO
'
,
$
this
->
db
->
connection
()->
getPdo
());
$
this
->
assertInstanceOf
(
'
PDO
'
,
$
this
->
db
->
connection
()->
getReadPdo
());
$
this
->
assertInstanceOf
(
'
PDO
'
,
$
this
->
db
->
connection
(
'
read_write
'
)->
getPdo
());
$
this
->
assertInstanceOf
(
'
PDO
'
,
$
this
->
db
->
connection
(
'
read_write
'
)->
getReadPdo
());
}
/**
* @expectedException InvalidArgumentException
*/
public
function
testIfDriverIsntSetExceptionIsThrown
()
{
$
factory
=
new
Illuminate
\
Database
\
Connectors
\
ConnectionFactory
(
$
container
= m::
mock
(
'
Illuminate\Container\Container
'
));
$
factory
->
createConnector
([
'
foo
'
]);
}
/**
* @expectedException InvalidArgumentException
*/
public
function
testExceptionIsThrownOnUnsupportedDriver
()
{
$
factory
=
new
Illuminate
\
Database
\
Connectors
\
ConnectionFactory
(
$
container
= m::
mock
(
'
Illuminate\Container\Container
'
));
$
container
->
shouldReceive
(
'
bound
'
)->
once
()->
andReturn
(
false
);
$
factory
->
createConnector
([
'
driver
'
=>
'
foo
'
]);
}
public
function
testCustomConnectorsCanBeResolvedViaContainer
()
{
$
factory
=
new
Illuminate
\
Database
\
Connectors
\
ConnectionFactory
(
$
container
= m::
mock
(
'
Illuminate\Container\Container
'
));
$
container
->
shouldReceive
(
'
bound
'
)->
once
()->
with
(
'
db.connector.foo
'
)->
andReturn
(
true
);
$
container
->
shouldReceive
(
'
make
'
)->
once
()->
with
(
'
db.connector.foo
'
)->
andReturn
(
'
connector
'
);
$
this
->
assertEquals
(
'
connector
'
,
$
factory
->
createConnector
([
'
driver
'
=>
'
foo
'
]));
}
}
Back
|
FazBrowse Home
|
New Git URL