Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Lib/Current/CurrentLibPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,17 @@ public function findTopPage() {
$cacheTopPageId = $this->__cache[$this->Page->alias]->read('current', 'top_page_id');
if ($cacheTopPageId) {
$result = $this->Page->find('first', [
'fields' => ['weight'],
'fields' => ['weight', 'theme'],
'recursive' => -1,
'conditions' => [
'Page.id' => $cacheTopPageId,
],
'callbacks' => false,
]);
if ($result[$this->Page->alias]['weight'] == '1') {

$cacheTop = $this->__cache[$this->Page->alias]->read('current', 'top_page');
if ($result[$this->Page->alias]['weight'] == '1' &&
$result[$this->Page->alias]['theme'] === $cacheTop['Page']['theme']) {
//キャッシュのトップページの内容と変わってなければ、キャッシュの内容を
$this->__topPage = $this->__cache[$this->Page->alias]->read('current', 'top_page');
return $this->__topPage;
Expand Down
9 changes: 8 additions & 1 deletion Test/Case/AllNetCommonsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ class AllNetCommonsTest extends NetCommonsTestSuite {
public static function suite() {
$plugin = preg_replace('/^All([\w]+)Test$/', '$1', __CLASS__);
$suite = new NetCommonsTestSuite(sprintf('All %s Plugin tests', $plugin));
$suite->addTestDirectoryRecursive(CakePlugin::path($plugin) . 'Test' . DS . 'Case');

$suite->addTestDirectoryRecursive(CakePlugin::path($plugin) . 'Test' . DS . 'Case' . DS . 'Lib');
$suite->addTestDirectoryRecursive(CakePlugin::path($plugin) . 'Test' . DS . 'Case' . DS . 'Config');
$suite->addTestDirectoryRecursive(CakePlugin::path($plugin) . 'Test' . DS . 'Case' . DS . 'Controller');
$suite->addTestDirectoryRecursive(CakePlugin::path($plugin) . 'Test' . DS . 'Case' . DS . 'Error');
$suite->addTestDirectoryRecursive(CakePlugin::path($plugin) . 'Test' . DS . 'Case' . DS . 'Model');
$suite->addTestDirectoryRecursive(CakePlugin::path($plugin) . 'Test' . DS . 'Case' . DS . 'Utility');
$suite->addTestDirectoryRecursive(CakePlugin::path($plugin) . 'Test' . DS . 'Case' . DS . 'View');
return $suite;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,10 @@ public function getExpectedRedirectAfterPost($key) {
'^' . $fullBaseUrl . '.*?/calendars/calendar_plans/view/[_0-9a-z]+$';
break;
case 'delete_calendar_plan_without_frame':
$year = gmdate('Y');
$month = gmdate('n');
$result =
'^' . $fullBaseUrl . '.*/calendars/calendars/index\?style=largemonthly&year=2019&month=3$';
'^' . $fullBaseUrl . '.*/calendars/calendars/index\?style=largemonthly&year=' . $year . '&month=' . $month . '$';
break;
}

Expand Down
18,970 changes: 13,161 additions & 5,809 deletions Test/Fixture/CurrentLib/test_schema_current_lib.sql

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions TestSuite/NetCommonsControllerBaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public function setUp() {

parent::setUp();

Configure::write('App.base', '');
Configure::write('NetCommons.installed', true);
Configure::write('Config.language', 'ja');
Current::$current['Language'] = [
Expand Down
2 changes: 1 addition & 1 deletion TestSuite/NetCommonsCurrentLibTestRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public function testPostRequestFrameDelete(
$url = '/frames/frames/delete';
$post = $this->__PostData->getPostDataByFrameDelete();

$_SERVER['HTTP_REFERER'] = '/setting/announcements_page';
$_SERVER['HTTP_REFERER'] = Configure::read('App.fullBaseUrl') . '/setting/announcements_page';

$test->generate($controller, [
'components' => ['Security'],
Expand Down
113 changes: 54 additions & 59 deletions TestSuite/NetCommonsCurrentLibTestUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ public static function loadTables() {

self::$__loadedTables = true;
}

Configure::write('App.base', '');
Router::reload();
}

/**
Expand All @@ -210,11 +213,7 @@ public static function loadedTables() {
* @return bool
*/
public static function canLoadTables() {
$travis = getenv('TRAVIS_BUILD_DIR');
$db = ConnectionManager::getDataSource('test');
$schemaFile = self::getSchemaFile();
$installed = Configure::read('NetCommons.installed');
return ($installed && !$travis && $db->config['prefix'] === '' && file_exists($schemaFile));
return (bool)getenv('NC3_LOCAL_TEST');
}

/**
Expand All @@ -233,11 +232,7 @@ public static function getFixturePath() {
* @return string
*/
public static function getSchemaFile() {
if (get_class(new Current()) === 'CurrentLib') {
$schemaFile = self::getFixturePath() . 'CurrentLib' . DS . 'test_schema_current_lib.sql';
} else {
$schemaFile = self::getFixturePath() . 'CurrentLib' . DS . 'test_schema_current_utility.sql';
}
$schemaFile = self::getFixturePath() . 'CurrentLib' . DS . 'test_schema_current_lib.sql';
return $schemaFile;
}

Expand Down Expand Up @@ -378,73 +373,73 @@ public static function logout() {
* @return void
*/
public static function settingMode($setting) {
if (get_class(new Current()) === 'CurrentLib') {
//if (get_class(new Current()) === 'CurrentLib') {
$reflectionClass = new ReflectionClass('SettingMode');
$property = $reflectionClass->getProperty('__isSettingMode');
$property->setAccessible(true);
$property->setValue($setting);
} else {
$reflectionClass = new ReflectionClass('Current');
$property = $reflectionClass->getProperty('_isSettingMode');
$property->setAccessible(true);
$property->setValue($setting);
}
//} else {
// $reflectionClass = new ReflectionClass('Current');
// $property = $reflectionClass->getProperty('_isSettingMode');
// $property->setAccessible(true);
// $property->setValue($setting);
//}
}

/**
* 旧Currentのリセット
*
* @return void
*/
private static function __resetOldCurrentUtility() {
Current::$current = [];
Current::$originalCurrent = [];
Current::$permission = [];

$class = new ReflectionClass('Current');
foreach (['_instance', '_instanceSystem', '_instanceFrame', '_instancePage'] as $prop) {
$Property = $class->getProperty($prop);
$Property->setAccessible(true);
$Property->setValue(null);
}

$class = new ReflectionClass('CurrentFrame');
$Property = $class->getProperty('__memoryCache');
$Property->setAccessible(true);
$Property->setValue([]);

$class = new ReflectionClass('CurrentFrame');
$Property = $class->getProperty('__roomIds');
$Property->setAccessible(true);
$Property->setValue([]);

$class = new ReflectionClass('CurrentPage');
$Property = $class->getProperty('__memoryCache');
$Property->setAccessible(true);
$Property->setValue([]);

$class = new ReflectionClass('CurrentSystem');
$Property = $class->getProperty('__memoryCache');
$Property->setAccessible(true);
$Property->setValue(null);

$class = new ReflectionClass('GetPageBehavior');
$Property = $class->getProperty('__memoryPageWithFrame');
$Property->setAccessible(true);
$Property->setValue([]);
}
//private static function __resetOldCurrentUtility() {
// Current::$current = [];
// Current::$originalCurrent = [];
// Current::$permission = [];
//
// $class = new ReflectionClass('Current');
// foreach (['_instance', '_instanceSystem', '_instanceFrame', '_instancePage'] as $prop) {
// $Property = $class->getProperty($prop);
// $Property->setAccessible(true);
// $Property->setValue(null);
// }
//
// $class = new ReflectionClass('CurrentFrame');
// $Property = $class->getProperty('__memoryCache');
// $Property->setAccessible(true);
// $Property->setValue([]);
//
// $class = new ReflectionClass('CurrentFrame');
// $Property = $class->getProperty('__roomIds');
// $Property->setAccessible(true);
// $Property->setValue([]);
//
// $class = new ReflectionClass('CurrentPage');
// $Property = $class->getProperty('__memoryCache');
// $Property->setAccessible(true);
// $Property->setValue([]);
//
// $class = new ReflectionClass('CurrentSystem');
// $Property = $class->getProperty('__memoryCache');
// $Property->setAccessible(true);
// $Property->setValue(null);
//
// $class = new ReflectionClass('GetPageBehavior');
// $Property = $class->getProperty('__memoryPageWithFrame');
// $Property->setAccessible(true);
// $Property->setValue([]);
//}

/**
* Currentライブラリのリセット
*
* @return void
*/
public static function resetCurrentLib() {
if (get_class(new Current()) === 'CurrentLib') {
Current::resetInstance();
} else {
self::__resetOldCurrentUtility();
}
//if (get_class(new Current()) === 'CurrentLib') {
CurrentLib::resetInstance();
//} else {
// self::__resetOldCurrentUtility();
//}

$class = new ReflectionClass('PageLayoutComponent');
$Property = $class->getProperty('_page');
Expand Down