Skip to content

Commit

Permalink
Merge pull request #4 from ezzatron/master
Browse files Browse the repository at this point in the history
Added get() method and 1.0.0 tag
  • Loading branch information
jmalloc committed Jul 10, 2012
2 parents 5ddc6a6 + f5ddd1e commit 2868ea6
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 9 deletions.
13 changes: 11 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified composer.phar
Binary file not shown.
17 changes: 17 additions & 0 deletions deploy/lib/IcecaveStudios/Isolator/Isolator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ public function __call($name, array $arguments) {
}
}

/**
* Fetch a usable isolator instance, or return an existing one.
*
* If no instance is provided, a new instance will be created and returned.
*
* @param Isolator|NULL $instance An existing isolator instance, if available.
*
* @return Isolator A new isolator instance, or the provided instance if available.
*/
public static function get(Isolator $instance = NULL) {
if ($instance) {
return $instance;
}

return static::getIsolator();
}

/**
* Fetch the default isolator instance, constructing it if necessary.
*
Expand Down
2 changes: 1 addition & 1 deletion test/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
require 'Phake.php';
Phake::setClient(Phake::CLIENT_PHPUNIT);

require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . '.composer' . DIRECTORY_SEPARATOR . 'autoload.php';
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
18 changes: 12 additions & 6 deletions test/suite/IcecaveStudios/Isolator/IsolatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
use Phake;

class IsolatorTest extends PHPUnit_Framework_TestCase {

public function tearDown() {
parent::tearDown();
Isolator::resetIsolator();
}

public function testCall() {
$isolator = new Isolator;
$this->assertSame(3, $isolator->strlen('foo'));
}

public function testEcho() {
$isolator = new Isolator;
$this->expectOutputString('Echo works!');
Expand All @@ -28,13 +28,19 @@ public function testEval() {
$isolator = new Isolator;
$this->assertSame(3, $isolator->eval('return strlen("foo");'));
}


public function testGet() {
$isolator = new Isolator;
$this->assertSame($isolator, Isolator::get($isolator));
$this->assertInstanceOf('IcecaveStudios\Isolator\Isolator', Isolator::get(NULL));
}

public function testGetIsolator() {
$isolator = Isolator::getIsolator();
$this->assertInstanceOf('IcecaveStudios\Isolator\Isolator', $isolator);
$this->assertSame($isolator, Isolator::getIsolator());
}

public function testGetIsolatorNoReferences() {
$isolator = Isolator::getIsolator(FALSE);
$this->assertSame('IcecaveStudios\Isolator\Isolator', get_class($isolator));
Expand All @@ -45,7 +51,7 @@ public function testGetIsolatorExistingInstance() {
$this->assertInstanceOf('IcecaveStudios\Isolator\Isolator', $isolator);
$this->assertSame($isolator, Isolator::getIsolator(FALSE));
}

public function testGetIsolatorNewInstance() {
$generator = Phake::mock('IcecaveStudios\Isolator\Generator');
Phake::when($generator)
Expand Down

0 comments on commit 2868ea6

Please sign in to comment.