File tree Expand file tree Collapse file tree 2 files changed +90
-4
lines changed
Tests/Unit/DependencyInjection Expand file tree Collapse file tree 2 files changed +90
-4
lines changed Original file line number Diff line number Diff line change @@ -62,13 +62,16 @@ public function getConfigTreeBuilder()
62
62
->validate ()
63
63
->ifTrue (function ($ databases ) {
64
64
$ 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
+ }
67
70
}
68
71
69
72
return !$ valid ;
70
73
})
71
- ->thenInvalid ('Key "ignoreTables" is only valid on MySQL databases. ' )
74
+ ->thenInvalid ('Keys "ignoreTables", "ssl" and "singleTransaction" are only valid on MySQL databases. ' )
72
75
->end ()
73
76
->validate ()
74
77
->always (function ($ databases ) {
@@ -88,6 +91,8 @@ public function getConfigTreeBuilder()
88
91
->scalarNode ('user ' )->end ()
89
92
->scalarNode ('pass ' )->end ()
90
93
->scalarNode ('database ' )->end ()
94
+ ->booleanNode ('singleTransaction ' )->end ()
95
+ ->booleanNode ('ssl ' )->end ()
91
96
->arrayNode ('ignoreTables ' )
92
97
->scalarPrototype ()->end ()
93
98
->end ()
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public function testIgnoreTablesGeneratesErrorWhenNotUsingMySQL()
33
33
],
34
34
]
35
35
),
36
- 'Key "ignoreTables" is only valid on MySQL databases. '
36
+ 'Keys "ignoreTables", "ssl" and "singleTransaction" are only valid on MySQL databases. '
37
37
);
38
38
}
39
39
@@ -53,4 +53,85 @@ public function testIgnoreTablesDoesNothingWhenOmitted()
53
53
)
54
54
);
55
55
}
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
+ }
56
137
}
You can’t perform that action at this time.
0 commit comments