forked from luyadev/luya-module-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add instance of type check (luyadev#476)
* add instance of type check * add tests, add changelog * changelog, use createObject
- Loading branch information
1 parent
c1c51a5
commit 2242fea
Showing
6 changed files
with
141 additions
and
7 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
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,59 @@ | ||
<?php | ||
|
||
namespace admintests; | ||
|
||
use luya\testsuite\cases\BaseTestSuite; | ||
use luya\base\Boot; | ||
|
||
require 'vendor/autoload.php'; | ||
require 'data/env.php'; | ||
|
||
class AdminConsoleSqLiteTestCase extends BaseTestSuite | ||
{ | ||
public function getConfigArray() | ||
{ | ||
return [ | ||
'id' => 'testenv', | ||
'siteTitle' => 'Luya Tests', | ||
'remoteToken' => 'testtoken', | ||
'basePath' => dirname(__DIR__), | ||
'defaultRoute' => 'admin', | ||
'language' => 'en', | ||
'aliases' => [ | ||
'@runtime' => dirname(__DIR__) . '/runtime', | ||
'@data' => dirname(__DIR__), | ||
], | ||
'modules' => [ | ||
'admin' => [ | ||
'class' => 'luya\admin\Module', | ||
], | ||
'crudmodulefolderadmin' => [ | ||
'class' => 'admintests\data\modules\crudmodulefolder\admin\Module', | ||
] | ||
], | ||
'components' => [ | ||
'session' => ['class' => 'yii\web\CacheSession'], | ||
'cache' => ['class' => 'yii\caching\DummyCache'], | ||
'db' => [ | ||
'class' => 'yii\db\Connection', | ||
'dsn' => 'sqlite::memory:', | ||
], | ||
'storage' => [ | ||
'class' => 'luya\admin\filesystem\DummyFileSystem' | ||
] | ||
], | ||
]; | ||
} | ||
|
||
public function bootApplication(Boot $boot) | ||
{ | ||
$boot->applicationConsole(); | ||
} | ||
|
||
protected function removeNewline($text) | ||
{ | ||
$text = trim(preg_replace('/\s+/', ' ', $text)); | ||
|
||
return str_replace(['> ', ' <'], ['>', '<'], $text); | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
|
||
namespace admintests\admin\importers; | ||
|
||
use admintests\AdminConsoleSqLiteTestCase; | ||
use luya\admin\importers\FilterImporter; | ||
use luya\admin\models\StorageEffect; | ||
use luya\admin\models\StorageFile; | ||
use luya\admin\models\StorageFilter; | ||
use luya\admin\models\StorageFilterChain; | ||
use luya\admin\models\StorageImage; | ||
use luya\console\commands\ImportController; | ||
use luya\testsuite\fixtures\NgRestModelFixture; | ||
|
||
class FilterImporterTest extends AdminConsoleSqLiteTestCase | ||
{ | ||
public function testInvalidObject() | ||
{ | ||
new NgRestModelFixture(['modelClass' => StorageEffect::class]); | ||
new NgRestModelFixture(['modelClass' => StorageFilter::class]); | ||
new NgRestModelFixture(['modelClass' => StorageFilterChain::class]); | ||
new NgRestModelFixture(['modelClass' => StorageFile::class]); | ||
new NgRestModelFixture(['modelClass' => StorageImage::class]); | ||
|
||
$base = new ImportController('importer', $this->app); | ||
$importer = new FilterImporter($base, $this->app->getModule('admin')); | ||
$importer->run(); | ||
$this->assertNotEmpty($base->getLog()); | ||
} | ||
} |
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,37 @@ | ||
<?php | ||
|
||
namespace admintests\admin\importers; | ||
|
||
use admintests\AdminConsoleSqLiteTestCase; | ||
use luya\admin\importers\PropertyImporter; | ||
use luya\admin\models\Property; | ||
use luya\console\commands\ImportController; | ||
use luya\testsuite\fixtures\NgRestModelFixture; | ||
|
||
class PropertyImporterTest extends AdminConsoleSqLiteTestCase | ||
{ | ||
public function testInvalidObject() | ||
{ | ||
new NgRestModelFixture(['modelClass' => Property::class]); | ||
|
||
// data properties folder | ||
$path = dirname(__DIR__) . '/../data/properties'; | ||
$folder = 'properties'; | ||
$ns = '\luya\admin\tests\data\properties'; | ||
$module = 'admin'; | ||
|
||
|
||
|
||
$base = new ImportController('importer', $this->app); | ||
$this->invokeMethod($base, 'addToDirectory', [ | ||
$path, $folder, $ns, $module | ||
// $path, $folderName, $ns, $module | ||
]); | ||
|
||
$importer = new PropertyImporter($base, $this->app->getModule('admin')); | ||
$importer->run(); | ||
|
||
|
||
$this->assertNotEmpty($base->getLog()); | ||
} | ||
} |