|
|
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
|
|
namespace Cake\Test\TestCase\Datasource;
|
|
|
|
|
|
use Cake\Datasource\FactoryLocator;
|
|
|
+use Cake\Datasource\LocatorInterface;
|
|
|
use Cake\Datasource\RepositoryInterface;
|
|
|
use Cake\TestSuite\TestCase;
|
|
|
use TestApp\Model\Table\PaginatorPostsTable;
|
|
|
@@ -127,6 +128,18 @@ class ModelAwareTraitTest extends TestCase
|
|
|
$this->assertInstanceOf(RepositoryInterface::class, $result);
|
|
|
$this->assertInstanceOf(RepositoryInterface::class, $stub->Magic);
|
|
|
$this->assertSame('Magic', $stub->Magic->name);
|
|
|
+
|
|
|
+ $locator = $this->getMockBuilder(LocatorInterface::class)->getMock();
|
|
|
+ $mock2 = $this->getMockBuilder(RepositoryInterface::class)->getMock();
|
|
|
+ $mock2->alias = 'Foo';
|
|
|
+ $locator->expects($this->any())
|
|
|
+ ->method('get')
|
|
|
+ ->willReturn($mock2);
|
|
|
+
|
|
|
+ $stub->modelFactory('MyType', $locator);
|
|
|
+ $result = $stub->loadModel('Foo', 'MyType');
|
|
|
+ $this->assertInstanceOf(RepositoryInterface::class, $result);
|
|
|
+ $this->assertSame('Foo', $stub->Foo->alias);
|
|
|
}
|
|
|
|
|
|
/**
|