Skip to content

Commit

Permalink
ユニットテストを調整
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Apr 14, 2024
1 parent f1f283f commit 960aeda
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
3 changes: 1 addition & 2 deletions plugins/baser-core/src/Controller/AnalyseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace BaserCore\Controller;

use Cake\Core\Plugin;
use Cake\Filesystem\File;
use Cake\Filesystem\Folder;
use Doctrine\Common\Annotations\AnnotationReader;
Expand Down Expand Up @@ -58,7 +57,7 @@ public function index($pluginName = null)
{
$basePath = ROOT . DS . 'plugins' . DS;

$plugin = new \BcCustomContent\Plugin();
$plugin = new \BcCustomContent\BcCustomContentPlugin();
$plugin->loadPlugin();

if ($pluginName) {
Expand Down
8 changes: 4 additions & 4 deletions plugins/baser-core/tests/TestCase/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace BaserCore\Test\TestCase;

use App\Application;
use BaserCore\Plugin;
use BaserCore\BaserCorePlugin;
use BaserCore\Service\SiteConfigsServiceInterface;
use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcUtil;
Expand All @@ -27,12 +27,12 @@

/**
* Class PluginTest
* @property Plugin $Plugin
* @property BaserCorePlugin $Plugin
*/
class PluginTest extends BcTestCase
{
/**
* @var Plugin
* @var BaserCorePlugin
*/
public $Plugin;

Expand All @@ -59,7 +59,7 @@ public function setUp(): void
{
parent::setUp();
$this->application = new Application(CONFIG);
$this->Plugin = new Plugin(['name' => 'BaserCore']);
$this->Plugin = new BaserCorePlugin(['name' => 'BaserCore']);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ public function test_add()
);

$rs = $this->ThemesService->add(["file" => $files]);
$this->assertEquals('BcPluginSample22', $rs);
$this->assertEquals('BcPluginSample3', $rs);

//テスト実行後不要ファイルを削除
$folder = new Folder();
$folder->delete(ROOT . DS . 'plugins' . DS . $theme);
$folder->delete(ROOT . DS . 'plugins' . DS . 'BcPluginSample22');
$folder->delete(ROOT . DS . 'plugins' . DS . 'BcPluginSample3');
$folder->delete($zipSrcPath);

// 失敗した場合の Exception メッセージ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testSetup()
$this->assertEquals('App\Application', get_class($this->Application));
$plugins = $this->Application->getPlugins();
$this->assertTrue($plugins->has('BaserCore'));
$this->assertEquals('BaserCore\Plugin', get_class($this->BaserCore));
$this->assertEquals('BaserCore\BaserCorePlugin', get_class($this->BaserCore));
}

/**
Expand Down
5 changes: 1 addition & 4 deletions plugins/baser-core/tests/TestCase/Utility/BcUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
namespace BaserCore\Test\TestCase\Utility;

use BaserCore\Event\BcEventListener;
use BaserCore\Model\Entity\SiteConfig;
use BaserCore\Test\Factory\SiteConfigFactory;
use BaserCore\Test\Factory\UserFactory;
use BaserCore\Test\Factory\UserGroupFactory;
use BaserCore\Test\Factory\UsersUserGroupFactory;
use BaserCore\View\BcAdminAppView;
use Cake\Core\App;
use Cake\Cache\Cache;
use Cake\Core\Plugin;
Expand All @@ -27,7 +25,6 @@
use Cake\Filesystem\Folder;
use BaserCore\Utility\BcUtil;
use BaserCore\TestSuite\BcTestCase;
use Cake\Http\ServerRequestFactory;
use Cake\Http\Session;
use Cake\ORM\TableRegistry;
use Cake\Routing\Router;
Expand Down Expand Up @@ -1311,7 +1308,7 @@ public function test_changePluginNameSpace()
// 対象ファイルをopen
$theme = 'BcFront';
$pluginPath = BcUtil::getPluginPath($theme);
$file = new File($pluginPath . 'src' . DS . 'Plugin.php');
$file = new File($pluginPath . 'src' . DS . 'BcFrontPlugin.php');
// テーマ名とネームスペースが違う状態を作る
$data = $file->read();
$file->write(preg_replace('/namespace .+?;/', 'namespace WrongNamespace;', $data));
Expand Down

0 comments on commit 960aeda

Please sign in to comment.