@@ -19,38 +19,38 @@ class DatabaseTestListenerTest extends \PHPUnit_Framework_TestCase
1919 private $ processBuilder ;
2020 private static $ i ;
2121
22- public function setUp ()
22+ protected function setUp ()
2323 {
2424 $ this ->listener = new DatabaseTestListener ($ this ->getProcessBuilder ());
2525 self ::$ i = 0 ;
2626 }
2727
2828 public function testPhpcrTestSuite ()
2929 {
30- $ suite = $ this ->getMock ('PHPUnit_Framework_TestSuite ' );
30+ $ suite = $ this ->createMock ('PHPUnit_Framework_TestSuite ' );
3131 $ suite ->expects ($ this ->any ())
3232 ->method ('getName ' )
33- ->will ( $ this -> returnValue ( 'phpcr ' ) );
33+ ->willReturn ( 'phpcr ' );
3434
35- $ this ->assertProcessExecuted (array ( 'doctrine:phpcr:init:dbal ' , '--drop ' , '--force ' ) );
36- $ this ->assertProcessExecuted (array ( 'doctrine:phpcr:repository:init ' ) );
35+ $ this ->assertProcessExecuted ([ 'doctrine:phpcr:init:dbal ' , '--drop ' , '--force ' ] );
36+ $ this ->assertProcessExecuted ([ 'doctrine:phpcr:repository:init ' ] );
3737
3838 ob_start ();
3939 $ this ->listener ->startTestSuite ($ suite );
4040
41- $ this ->assertEquals ( PHP_EOL . PHP_EOL . '[PHPCR] ' . PHP_EOL , ob_get_clean ());
41+ $ this ->assertContains ( '[PHPCR] ' , ob_get_clean ());
4242 }
4343
4444 public function testFallsBackToOldInitDbalCommand ()
4545 {
46- $ suite = $ this ->getMock ('PHPUnit_Framework_TestSuite ' );
46+ $ suite = $ this ->createMock ('PHPUnit_Framework_TestSuite ' );
4747 $ suite ->expects ($ this ->any ())
4848 ->method ('getName ' )
49- ->will ( $ this -> returnValue ( 'phpcr ' ) );
49+ ->willReturn ( 'phpcr ' );
5050
51- $ this ->assertProcessExecuted (array ( 'doctrine:phpcr:init:dbal ' , '--drop ' , '--force ' ) , false );
52- $ this ->assertProcessExecuted (array ( 'doctrine:phpcr:init:dbal ' , '--drop ' ) , true );
53- $ this ->assertProcessExecuted (array ( 'doctrine:phpcr:repository:init ' ) );
51+ $ this ->assertProcessExecuted ([ 'doctrine:phpcr:init:dbal ' , '--drop ' , '--force ' ] , false );
52+ $ this ->assertProcessExecuted ([ 'doctrine:phpcr:init:dbal ' , '--drop ' ] , true );
53+ $ this ->assertProcessExecuted ([ 'doctrine:phpcr:repository:init ' ] );
5454
5555 ob_start ();
5656 $ this ->listener ->startTestSuite ($ suite );
@@ -59,67 +59,64 @@ public function testFallsBackToOldInitDbalCommand()
5959
6060 public function testOrmTestSuite ()
6161 {
62- $ suite = $ this ->getMock ('PHPUnit_Framework_TestSuite ' );
62+ $ suite = $ this ->createMock ('PHPUnit_Framework_TestSuite ' );
6363 $ suite ->expects ($ this ->any ())
6464 ->method ('getName ' )
65- ->will ( $ this -> returnValue ( 'orm ' ) );
65+ ->willReturn ( 'orm ' );
6666
67- $ this ->assertProcessExecuted (array ( 'doctrine:schema:drop ' , '--env=orm ' , '--force ' ) );
68- $ this ->assertProcessExecuted (array ( 'doctrine:database:create ' , '--env=orm ' ) );
69- $ this ->assertProcessExecuted (array ( 'doctrine:schema:create ' , '--env=orm ' ) );
67+ $ this ->assertProcessExecuted ([ 'doctrine:schema:drop ' , '--env=orm ' , '--force ' ] );
68+ $ this ->assertProcessExecuted ([ 'doctrine:database:create ' , '--env=orm ' ] );
69+ $ this ->assertProcessExecuted ([ 'doctrine:schema:create ' , '--env=orm ' ] );
7070
7171 ob_start ();
7272 $ this ->listener ->startTestSuite ($ suite );
7373
74- $ this ->assertEquals ( PHP_EOL . PHP_EOL . '[ORM] ' . PHP_EOL , ob_get_clean ());
74+ $ this ->assertContains ( '[ORM] ' , ob_get_clean ());
7575 }
7676
7777 public function testUnknownTestSuite ()
7878 {
79- $ suite = $ this ->getMock ('PHPUnit_Framework_TestSuite ' );
79+ $ suite = $ this ->createMock ('PHPUnit_Framework_TestSuite ' );
8080 $ suite ->expects ($ this ->any ())
8181 ->method ('getName ' )
82- ->will ( $ this -> returnValue ( 'not orm or phpcr tests ' ) );
82+ ->willReturn ( 'not orm or phpcr tests ' );
8383
84- $ this ->getProcessBuilder ()
85- ->expects ($ this ->never ())
86- ->method ('setArguments ' );
84+ $ this ->getProcessBuilder ()->expects ($ this ->never ())->method ('setArguments ' );
8785
8886 ob_start ();
8987 $ this ->listener ->startTestSuite ($ suite );
9088
91- $ this ->assertEquals ( PHP_EOL . PHP_EOL . '[not orm or phpcr tests] ' . PHP_EOL , ob_get_clean ());
89+ $ this ->assertContains ( '[not orm or phpcr tests] ' , ob_get_clean ());
9290 }
9391
9492 protected function assertProcessExecuted (array $ arguments , $ successfull = true )
9593 {
96- $ process = $ this ->getMockBuilder ('Symfony\Component\Process\Process ' )
97- ->disableOriginalConstructor ()
98- ->getMock ();
94+ $ process = $ this ->createMock ('Symfony\Component\Process\Process ' );
9995
100- $ process ->expects ($ this ->once ())
101- ->method ('run ' );
96+ $ process ->expects ($ this ->once ())->method ('run ' );
10297
10398 $ process ->expects ($ this ->any ())
10499 ->method ('isSuccessful ' )
105- ->will ( $ this -> returnValue ( $ successfull) );
100+ ->willReturn ( $ successfull );
106101
107- $ processPlaceholder = $ this ->getMock ('ProcessPlaceholder ' , array ('getProcess ' ));
102+ $ processPlaceholder = $ this ->getMockBuilder ('ProcessPlaceholder ' )
103+ ->setMethods (['getProcess ' ])
104+ ->getMock ();
108105 $ processPlaceholder ->expects ($ this ->once ())
109106 ->method ('getProcess ' )
110- ->will ( $ this -> returnValue ( $ process) );
107+ ->willReturn ( $ process );
111108
112109 $ this ->getProcessBuilder ()
113110 ->expects ($ this ->at (self ::$ i ++))
114111 ->method ('setArguments ' )
115112 ->with ($ this ->equalTo ($ arguments ))
116- ->will ( $ this -> returnValue ( $ processPlaceholder) );
113+ ->willReturn ( $ processPlaceholder );
117114 }
118115
119116 protected function getProcessBuilder ()
120117 {
121118 if (null === $ this ->processBuilder ) {
122- $ this ->processBuilder = $ this ->getMock ('Symfony\Component\Process\ProcessBuilder ' );
119+ $ this ->processBuilder = $ this ->createMock ('Symfony\Component\Process\ProcessBuilder ' );
123120 }
124121
125122 return $ this ->processBuilder ;
0 commit comments