You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB

<?php
namespace Glmdev\Meta\Tests;
use Glmdev\Meta\Meta;
use Ramsey\Uuid\Uuid;
class MetaTest extends \PHPUnit_Framework_TestCase
{
public function testReadWrite ()
{
$model = Meta::create();
$model->write('name', 'John');
$model->write('age', 15);
$model->write('email', 'Johnny@appleseed.com');
$this->assertEquals('John', $model->read('name'));
$this->assertEquals(15, $model->read('age'));
$this->assertEquals('Johnny@appleseed.com', $model->read('email'));
}
public function testUuid ()
{
$model = Meta::create();
$uuid = Uuid::uuid4();
$this->assertTrue($model->hasUuid());
$model->setRawUuid($uuid);
$this->assertEquals($uuid, $model->getUuid());
}
public function testUuidQuery ()
{
$model = Meta::create([
'meta' => serialize(['name' => 'Tony'])
]);
$queried = Meta::withUuid($model->getUuid())->first();
$this->assertEquals($model->read('name'), $queried->read('name'));
}
}