-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
101 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,11 @@ | |
"email": "[email protected]", | ||
"homepage": "http://baptiste.clavié.net", | ||
"role": "Lead Developper" | ||
}, | ||
|
||
{ | ||
"name": "Rémy Gazelot", | ||
"email": "[email protected]" | ||
} | ||
], | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* This file is part of the Totem package | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
* | ||
* @copyright Baptiste Clavié <[email protected]> | ||
* @license http://www.opensource.org/licenses/MIT-License MIT License | ||
*/ | ||
|
||
namespace Totem\Snapshot; | ||
|
||
use \ReflectionObject, | ||
\ReflectionProperty, | ||
|
||
\InvalidArgumentException; | ||
|
||
use Totem\AbstractSnapshot; | ||
|
||
/** | ||
* Represents a snapshot of an array at a given time | ||
* | ||
* @author Baptiste Clavié <[email protected]> | ||
*/ | ||
class ArraySnapshot extends AbstractSnapshot | ||
{ | ||
public function __construct(array $data) | ||
{ | ||
$this->data = $data; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
public function isComparable(AbstractSnapshot $snapshot) | ||
{ | ||
if (!$snapshot instanceof static) { | ||
return false; | ||
} | ||
|
||
return array_keys($snapshot->data) === array_keys($this->data); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,10 +23,10 @@ | |
* | ||
* @author Baptiste Clavié <[email protected]> | ||
*/ | ||
class Object extends AbstractSnapshot | ||
class ObjectSnapshot extends AbstractSnapshot | ||
{ | ||
/** @var string object's hash */ | ||
private $oid; | ||
protected $oid; | ||
|
||
/** | ||
* Build this snapshot | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* This file is part of the Totem package | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
* | ||
* @copyright Baptiste Clavié <[email protected]> | ||
* @license http://www.opensource.org/licenses/MIT-License MIT License | ||
*/ | ||
|
||
namespace test\Totem\Snapshot; | ||
|
||
use \stdClass; | ||
|
||
use \PHPUnit_Framework_TestCase; | ||
|
||
use Totem\Snapshot\ArraySnapshot; | ||
|
||
class ArraySnapshotTest extends PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @expectedException Totem\Exception\IncomparableDataException | ||
*/ | ||
public function testDiffWrongArray() | ||
{ | ||
$snapshot = new ArraySnapshot(['foo', 'bar']); | ||
$snapshot->diff(new ArraySnapshot(['foo' => 'bar'])); | ||
} | ||
|
||
public function testDiff() | ||
{ | ||
$snapshot = new ArraySnapshot(['foo' => 'bar']); | ||
$set = $snapshot->diff($snapshot); | ||
|
||
$this->assertInstanceOf('Totem\\Set', $set); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters