Skip to content

Commit 78caace

Browse files
authored
Adding support for "ssl" and "singleTransaction" (#29)
* Adding support for "ssl" and "singleTransaction" * Fixed tests
1 parent f235eff commit 78caace

File tree

2 files changed

+90
-4
lines changed

2 files changed

+90
-4
lines changed

DependencyInjection/Configuration.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,16 @@ public function getConfigTreeBuilder()
6262
->validate()
6363
->ifTrue(function ($databases) {
6464
$valid = true;
65-
foreach ($databases as $database) {
66-
$valid = $valid && (empty($database['ignoreTables']) || $database['type'] === 'mysql');
65+
foreach ($databases as $d) {
66+
if ($d['type'] !== 'mysql') {
67+
// If not "mysql" we have to make sure these parameter are set to default
68+
$valid = $valid && empty($d['ignoreTables']) && empty($d['ssl']) && empty($d['singleTransaction']);
69+
}
6770
}
6871

6972
return !$valid;
7073
})
71-
->thenInvalid('Key "ignoreTables" is only valid on MySQL databases.')
74+
->thenInvalid('Keys "ignoreTables", "ssl" and "singleTransaction" are only valid on MySQL databases.')
7275
->end()
7376
->validate()
7477
->always(function ($databases) {
@@ -88,6 +91,8 @@ public function getConfigTreeBuilder()
8891
->scalarNode('user')->end()
8992
->scalarNode('pass')->end()
9093
->scalarNode('database')->end()
94+
->booleanNode('singleTransaction')->end()
95+
->booleanNode('ssl')->end()
9196
->arrayNode('ignoreTables')
9297
->scalarPrototype()->end()
9398
->end()

Tests/Unit/DependencyInjection/ConfigurationTest.php

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testIgnoreTablesGeneratesErrorWhenNotUsingMySQL()
3333
],
3434
]
3535
),
36-
'Key "ignoreTables" is only valid on MySQL databases.'
36+
'Keys "ignoreTables", "ssl" and "singleTransaction" are only valid on MySQL databases.'
3737
);
3838
}
3939

@@ -53,4 +53,85 @@ public function testIgnoreTablesDoesNothingWhenOmitted()
5353
)
5454
);
5555
}
56+
57+
public function testSslGeneratesErrorWhenNotUsingMySQL()
58+
{
59+
$this->assertConfigurationIsInvalid(array(
60+
[
61+
'database'=>[
62+
'dev'=>[
63+
'type' => 'foo',
64+
'ssl' => true,
65+
],
66+
'prod'=>[
67+
'type' => 'mysql',
68+
],
69+
],
70+
]
71+
),
72+
'Keys "ignoreTables", "ssl" and "singleTransaction" are only valid on MySQL databases.'
73+
);
74+
}
75+
76+
public function testSslOnValid()
77+
{
78+
$this->assertConfigurationIsValid(array(
79+
[
80+
'database'=>[
81+
'dev'=>[
82+
'type' => 'foo',
83+
],
84+
'test'=>[
85+
'type' => 'bar',
86+
'ssl' => false,
87+
],
88+
'prod'=>[
89+
'type' => 'mysql',
90+
'ssl' => true,
91+
],
92+
],
93+
]
94+
)
95+
);
96+
}
97+
98+
public function testSingleTransactionGeneratesErrorWhenNotUsingMySQL()
99+
{
100+
$this->assertConfigurationIsInvalid(array(
101+
[
102+
'database'=>[
103+
'dev'=>[
104+
'type' => 'foo',
105+
'singleTransaction' => true,
106+
],
107+
'prod'=>[
108+
'type' => 'mysql',
109+
],
110+
],
111+
]
112+
),
113+
'Keys "ignoreTables", "ssl" and "singleTransaction" are only valid on MySQL databases.'
114+
);
115+
}
116+
117+
public function testSingleTransactionOnValid()
118+
{
119+
$this->assertConfigurationIsValid(array(
120+
[
121+
'database'=>[
122+
'dev'=>[
123+
'type' => 'foo',
124+
],
125+
'test'=>[
126+
'type' => 'bar',
127+
'singleTransaction' => false,
128+
],
129+
'prod'=>[
130+
'type' => 'mysql',
131+
],
132+
],
133+
]
134+
)
135+
);
136+
}
56137
}

0 commit comments

Comments
 (0)