Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
add some tests for sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
albertcht committed Dec 13, 2018
1 parent b996e36 commit 781773d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/Server/Sandbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,6 @@ public function getSnapshot()
return Context::getApp();
}

/**
* Remove current request.
*/
public function removeRequest()
{
return Context::removeData('_request');
}

/**
* Get current request.
*/
Expand Down
25 changes: 25 additions & 0 deletions tests/Server/SandboxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,31 @@ public function testGetApplication()
$this->assertTrue($sandbox->getSnapshot() instanceof Container);
}

public function testGetCachedSnapshot()
{
$container = m::mock(Container::class);
$snapshot = m::mock(Container::class);
$snapshot->shouldReceive('offsetGet')
->with('foo')
->once()
->andReturn($result = 'bar');

$sandbox = new Sandbox;
$sandbox->setBaseApp($container);
$sandbox->setSnapshot($snapshot);

$this->assertTrue($sandbox->getApplication() instanceof Container);
$this->assertEquals($result, $sandbox->getApplication()->foo);
}

public function testRunWithoutSnapshot()
{
$this->expectException(SandboxException::class);

$sandbox = new Sandbox;
$sandbox->run($request = m::mock(Request::class));
}

public function testSetRequest()
{
$request = m::mock(Request::class);
Expand Down

0 comments on commit 781773d

Please sign in to comment.