public function test_get_typeCallback() { $mock = Mockery::mock('Mismatch\\Model\\Attr\\AttrInterface'); Attrs::registerType('callback', function () use($mock) { return $mock; }); $this->subject->set('callback', 'callback'); $this->assertSame($mock, $this->subject->get('callback')); }
<?php /** * This file is part of Mismatch. * * @author ♥ <*****@*****.**> * @license MIT */ namespace Mismatch\ORM; use Mismatch\Model\Attrs; // Install native ORM types. foreach (['belongs-to' => 'Mismatch\\ORM\\Attr\\BelongsTo', 'has-many' => 'Mismatch\\ORM\\Attr\\HasMany', 'has-one' => 'Mismatch\\ORM\\Attr\\HasOne'] as $name => $type) { Attrs::registerType($name, $type); } // Install doctrine-specific types use Doctrine\DBAL\Types\Type; use Mismatch\ORM\Attr\Native; $types = Type::getTypesMap(); foreach ($types as $type => $class) { Attrs::registerType($type, function ($name, $opts) use($type) { $opts['type'] = Type::getType($type); return new Native($name, $opts); }); }