mirror of
https://github.com/filp/whoops.git
synced 2026-09-14 19:56:23 +00:00
Add FrameCollection tests
This commit is contained in:
@@ -199,12 +199,12 @@ class Frame implements Serializable
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
$frames = $this->frames;
|
||||
$frame = $this->frame;
|
||||
if(!empty($this->comments)) {
|
||||
$frames['_comments'] = $this->comments;
|
||||
$frame['_comments'] = $this->comments;
|
||||
}
|
||||
|
||||
return serialize($frames);
|
||||
return serialize($frame);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,13 +216,13 @@ class Frame implements Serializable
|
||||
*/
|
||||
public function unserialize($serializedFrame)
|
||||
{
|
||||
$frames = unserialize($serializedFrame);
|
||||
$frame = unserialize($serializedFrame);
|
||||
|
||||
if(!empty($frames['_comments'])) {
|
||||
$this->comments = $frames['_comments'];
|
||||
unset($frames['_comments']);
|
||||
if(!empty($frame['_comments'])) {
|
||||
$this->comments = $frame['_comments'];
|
||||
unset($frame['_comments']);
|
||||
}
|
||||
|
||||
$this->frames = $frames;
|
||||
$this->frame = $frame;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Whoops - php errors for cool kids
|
||||
* @author Filipe Dobreira <http://github.com/filp>
|
||||
*/
|
||||
|
||||
namespace Whoops\Exception;
|
||||
use Whoops\Exception\FrameCollection;
|
||||
use Whoops\TestCase;
|
||||
use Mockery as m;
|
||||
|
||||
class FrameCollectionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getFrameData()
|
||||
{
|
||||
return array(
|
||||
'file' => __DIR__ . '/../../fixtures/frame.lines-test.php',
|
||||
'line' => 0,
|
||||
'function' => 'test',
|
||||
'class' => 'MyClass',
|
||||
'args' => array(true, 'hello')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $frames
|
||||
* @return Whoops\Exception\FrameCollection
|
||||
*/
|
||||
private function getFrameCollectionInstance($frames = null)
|
||||
{
|
||||
if($frames === null) {
|
||||
$self = $this;
|
||||
|
||||
// Get 10 frames
|
||||
$frames = array_map(function() use($self) {
|
||||
return $self->getFrameData();
|
||||
}, range(1, 10));
|
||||
}
|
||||
|
||||
return new FrameCollection($frames);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Whoops\Exception\FrameCollection::getIterator
|
||||
*/
|
||||
public function testCollectionIsIterable()
|
||||
{
|
||||
$frames = $this->getFrameCollectionInstance();
|
||||
foreach($frames as $frame) {
|
||||
$this->assertInstanceOf('Whoops\\Exception\\Frame', $frame);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Whoops\Exception\FrameCollection::serialize
|
||||
* @covers Whoops\Exception\FrameCollection::unserialize
|
||||
*/
|
||||
public function testCollectionIsSerializable()
|
||||
{
|
||||
$frames = $this->getFrameCollectionInstance();
|
||||
$serializedFrames = serialize($frames);
|
||||
$newFrames = unserialize($serializedFrames);
|
||||
|
||||
foreach($newFrames as $frame) {
|
||||
$this->assertInstanceOf('Whoops\\Exception\\Frame', $frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ class FrameTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return Whoops\Exception\Frame
|
||||
*/
|
||||
private function getFrameInstance($data = null)
|
||||
|
||||
Reference in New Issue
Block a user