Skip to content

Commit ad134f9

Browse files
committed
Support Jackalope <1.2 and code clean-up
1 parent 53aab0c commit ad134f9

File tree

3 files changed

+64
-72
lines changed

3 files changed

+64
-72
lines changed

bin/travis/doctrine_orm.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
32
DIR_NAME=`dirname $0`
43
CONSOLE_DIR=$DIR_NAME"/.."
54

bin/travis/phpcr_odm_doctrine_dbal.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/bin/bash
2-
32
DIR_NAME=`dirname $0`
43
CONSOLE_DIR=$DIR_NAME"/.."
54

6-
# composer install --dev
7-
$CONSOLE_DIR"/console" doctrine:phpcr:init:dbal --drop --force
5+
if ! $CONSOLE_DIR"/console" doctrine:phpcr:init:dbal --drop --force; then
6+
# To support Jackalope <1.2
7+
$CONSOLE_DIR"/console" doctrine:phpcr:init:dbal --drop
8+
fi
9+
810
$CONSOLE_DIR"/console" doctrine:phpcr:repository:init

src/Phpunit/DatabaseTestListener.php

Lines changed: 59 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -110,39 +110,44 @@ private function setUpPhpcrDatabase($suite)
110110
{
111111
echo PHP_EOL.PHP_EOL;
112112

113+
// initialize PHPCR DBAL (new way)
113114
$process = $this->processBuilder
114115
->setArguments(array_merge($this->prefix, array('doctrine:phpcr:init:dbal', '--drop', '--force')))
115116
->getProcess();
117+
116118
$process->run();
117119

118-
while (true) {
119-
if ($process->isTerminated()) {
120-
if (!$process->isSuccessful()) {
121-
$output = null !== $process->getErrorOutput() ? $process->getErrorOutput() : $process->getOutput();
122-
$suite->markTestSuiteSkipped('[PHPCR] Error when initializing dbal: '.$output);
123-
} else {
124-
$process = $this->processBuilder
125-
->setArguments(array_merge($this->prefix, array('doctrine:phpcr:repository:init')))
126-
->getProcess();
127-
$process->run();
128-
129-
while (true) {
130-
if ($process->isTerminated()) {
131-
if (!$process->isSuccessful()) {
132-
$output = null !== $process->getErrorOutput() ? $process->getErrorOutput() : $process->getOutput();
133-
$suite->markTestSuiteSkipped('[PHPCR] Error when initializing repositories: '.$output);
134-
} else {
135-
echo '[PHPCR]'.PHP_EOL;
136-
}
137-
}
138-
139-
break;
140-
}
141-
}
120+
if (!$process->isSuccessful()) {
121+
// try initializing the old way (Jackalope <1.2)
122+
$process = $this->processBuilder
123+
->setArguments(array_merge($this->prefix, array('doctrine:phpcr:init:dbal', '--drop')))
124+
->getProcess();
142125

143-
break;
126+
$process->run();
127+
128+
if (!$process->isSuccessful()) {
129+
$output = null !== $process->getErrorOutput() ? $process->getErrorOutput() : $process->getOutput();
130+
$suite->markTestSuiteSkipped('[PHPCR] Error when initializing dbal: '.$output);
131+
132+
return;
144133
}
134+
}
135+
136+
// initialize repositories
137+
$process = $this->processBuilder
138+
->setArguments(array_merge($this->prefix, array('doctrine:phpcr:repository:init')))
139+
->getProcess();
140+
141+
$process->run();
142+
143+
if (!$process->isSuccessful()) {
144+
$output = null !== $process->getErrorOutput() ? $process->getErrorOutput() : $process->getOutput();
145+
$suite->markTestSuiteSkipped('[PHPCR] Error when initializing repositories: '.$output);
146+
147+
return;
145148
}
149+
150+
echo '[PHPCR]'.PHP_EOL;
146151
}
147152

148153
private function setUpOrmDatabase($suite)
@@ -152,52 +157,42 @@ private function setUpOrmDatabase($suite)
152157
$process = $this->processBuilder
153158
->setArguments(array_merge($this->prefix, array('doctrine:schema:drop', '--env=orm', '--force')))
154159
->getProcess();
160+
155161
$process->run();
156162

157-
while (true) {
158-
if ($process->isTerminated()) {
159-
if (!$process->isSuccessful()) {
160-
$output = null !== $process->getErrorOutput() ? $process->getErrorOutput() : $process->getOutput();
161-
$suite->markTestSuiteSkipped('[ORM] Error when dropping database: '.$output);
162-
return;
163-
}
164-
break;
165-
}
163+
if (!$process->isSuccessful()) {
164+
$output = null !== $process->getErrorOutput() ? $process->getErrorOutput() : $process->getOutput();
165+
$suite->markTestSuiteSkipped('[ORM] Error when dropping database: '.$output);
166+
167+
return;
166168
}
167169

168170
$process = $this->processBuilder
169171
->setArguments(array_merge($this->prefix, array('doctrine:database:create', '--env=orm')))
170172
->getProcess();
173+
171174
$process->run();
172175

173-
while (true) {
174-
if ($process->isTerminated()) {
175-
if (!$process->isSuccessful()) {
176-
$output = null !== $process->getErrorOutput() ? $process->getErrorOutput() : $process->getOutput();
177-
$suite->markTestSuiteSkipped('[ORM] Error when creating database: '.$output);
178-
} else {
179-
$process = $this->processBuilder
180-
->setArguments(array_merge($this->prefix, array('doctrine:schema:create', '--env=orm')))
181-
->getProcess();
182-
$process->run();
183-
184-
while (true) {
185-
if ($process->isTerminated()) {
186-
if (!$process->isSuccessful()) {
187-
$output = null !== $process->getErrorOutput() ? $process->getErrorOutput() : $process->getOutput();
188-
$suite->markTestSuiteSkipped('[ORM] Error when creating schema: '.$output);
189-
} else {
190-
echo '[ORM]'.PHP_EOL;
191-
}
192-
}
193-
194-
break;
195-
}
196-
}
176+
if (!$process->isSuccessful()) {
177+
$output = null !== $process->getErrorOutput() ? $process->getErrorOutput() : $process->getOutput();
178+
$suite->markTestSuiteSkipped('[ORM] Error when creating database: '.$output);
197179

198-
break;
199-
}
180+
return;
200181
}
182+
183+
$process = $this->processBuilder
184+
->setArguments(array_merge($this->prefix, array('doctrine:schema:create', '--env=orm')))
185+
->getProcess();
186+
$process->run();
187+
188+
if (!$process->isSuccessful()) {
189+
$output = null !== $process->getErrorOutput() ? $process->getErrorOutput() : $process->getOutput();
190+
$suite->markTestSuiteSkipped('[ORM] Error when creating schema: '.$output);
191+
192+
return;
193+
}
194+
195+
echo '[ORM]'.PHP_EOL;
201196
}
202197

203198
public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
@@ -209,16 +204,12 @@ public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
209204
$process = $this->processBuilder
210205
->setArguments(array_merge($this->prefix, array('doctrine:database:drop', '--force')))
211206
->getProcess();
207+
212208
$process->run();
213209

214-
while (true) {
215-
if ($process->isTerminated()) {
216-
if (!$process->isSuccessful()) {
217-
$output = null !== $process->getErrorOutput() ? $process->getErrorOutput() : $process->getOutput();
218-
$suite->markTestSuiteSkipped('Error when dropping database: '.$output);
219-
}
220-
}
221-
break;
210+
if (!$process->isSuccessful()) {
211+
$output = null !== $process->getErrorOutput() ? $process->getErrorOutput() : $process->getOutput();
212+
$suite->markTestSuiteSkipped('Error when dropping database: '.$output);
222213
}
223214
}
224215
}

0 commit comments

Comments
 (0)