Skip to content

Commit

Permalink
Added regression test for sebastianbergmann#1351.
Browse files Browse the repository at this point in the history
  • Loading branch information
sun committed Jul 26, 2014
1 parent 07d5a9e commit 60e949c
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/Regression/GitHub/1351.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--TEST--
GH-1351: Test result does not serialize test class in process isolation
--FILE--
<?php

$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--process-isolation';
$_SERVER['argv'][3] = 'Issue1351Test';
$_SERVER['argv'][4] = __DIR__ . '/1351/Issue1351Test.php';

require __DIR__ . '/../../bootstrap.php';
PHPUnit_TextUI_Command::main();
?>
--EXPECTF--
PHPUnit %s by Sebastian Bergmann.

F.E.

Time: %s, Memory: %sMb

There was 1 error:

1) Issue1351Test::testExceptionPre
RuntimeException: Expected rethrown exception.
%A
Caused by
LogicException: Expected exception.
%A

--

There was 1 failure:

1) Issue1351Test::testFailurePre
Expected failure.
%A
FAILURES!
Tests: 4, Assertions: 5, Failures: 1, Errors: 1.
4 changes: 4 additions & 0 deletions tests/Regression/GitHub/1351/ChildProcessClass1351.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
class ChildProcessClass1351
{
}
39 changes: 39 additions & 0 deletions tests/Regression/GitHub/1351/Issue1351Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
class Issue1351Test extends PHPUnit_Framework_TestCase
{
protected $instance;

/**
* @runInSeparateProcess
*/
public function testFailurePre()
{
$this->instance = new ChildProcessClass1351();
$this->assertFalse(TRUE, 'Expected failure.');
}

public function testFailurePost()
{
$this->assertNull($this->instance);
$this->assertFalse(class_exists('ChildProcessClass1351', false), 'ChildProcessClass1351 is not loaded.');
}

/**
* @runInSeparateProcess
*/
public function testExceptionPre()
{
$this->instance = new ChildProcessClass1351();
try {
throw new LogicException('Expected exception.');
} catch (LogicException $e) {
throw new RuntimeException('Expected rethrown exception.', 0, $e);
}
}

public function testExceptionPost()
{
$this->assertNull($this->instance);
$this->assertFalse(class_exists('ChildProcessClass1351', false), 'ChildProcessClass1351 is not loaded.');
}
}

0 comments on commit 60e949c

Please sign in to comment.