mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-06-22 01:02:44 +02:00
31 lines
823 B
PHP
31 lines
823 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Structural\DataMapper\Tests;
|
|
|
|
use DesignPatterns\Structural\DataMapper\StorageAdapter;
|
|
use DesignPatterns\Structural\DataMapper\UserMapper;
|
|
|
|
class DataMapperTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
public function testCanMapUserFromStorage()
|
|
{
|
|
$storage = new StorageAdapter([1 => ['username' => 'domnikl', 'email' => 'liebler.dominik@gmail.com']]);
|
|
$mapper = new UserMapper($storage);
|
|
|
|
$user = $mapper->findById(1);
|
|
|
|
$this->assertInstanceOf('DesignPatterns\Structural\DataMapper\User', $user);
|
|
}
|
|
|
|
/**
|
|
* @expectedException \InvalidArgumentException
|
|
*/
|
|
public function testWillNotMapInvalidData()
|
|
{
|
|
$storage = new StorageAdapter([]);
|
|
$mapper = new UserMapper($storage);
|
|
|
|
$mapper->findById(1);
|
|
}
|
|
}
|