Skip to content

Commit

Permalink
Merge pull request #32 from s-nakajima/master
Browse files Browse the repository at this point in the history
BlockTabsComponentからBlockTabsHelperに変更
  • Loading branch information
s-nakajima committed Mar 12, 2016
2 parents ea4ee8f + e9f8eb1 commit 96f4be5
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion Controller/Component/BlockTabsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BlockTabsComponent extends Component {
*/
public function startup(Controller $controller) {
//BlockTabsComponent->BlockTabsHelper一本化するため、Noticeを表示する
//trigger_error('Changed to BlockTabsHelper from BlockTabsComponent.', E_USER_WARNING);
trigger_error('Changed to BlockTabsHelper from BlockTabsComponent.', E_USER_WARNING);

if (! Hash::get($controller->helpers, 'Blocks.BlockTabs')) {
$controller->helpers['Blocks.BlockTabs'] = array(
Expand Down
120 changes: 60 additions & 60 deletions Test/Case/Controller/Component/BlockTabsComponent/StartupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,79 +62,79 @@ public function tearDown() {
*
* @return void
*/
public function testStartup() {
//テストコントローラ生成
$this->generateNc('TestBlocks.TestBlockTabsComponent');

//ログイン
TestAuthGeneral::login($this);

//Warningを無視する
$no = $str = $file = $line = $context = null;
set_error_handler(function ($no, $str, $file, $line, $context) {
}, E_USER_WARNING);

//テスト実行
$this->_testGetAction('/test_blocks/test_block_tabs_component/index',
array('method' => 'assertNotEmpty'), null, 'view');

set_error_handler(null);

//チェック
$pattern = '/' . preg_quote('Controller/Component/TestBlockTabsComponent/index', '/') . '/';
$this->assertRegExp($pattern, $this->view);

$this->assertEquals($this->controller->components['Blocks.BlockTabs'], $this->controller->helpers['Blocks.BlockTabs']);
}
//public function testStartup() {
// //テストコントローラ生成
// $this->generateNc('TestBlocks.TestBlockTabsComponent');
//
// //ログイン
// TestAuthGeneral::login($this);
//
// //Warningを無視する
// $no = $str = $file = $line = $context = null;
// set_error_handler(function ($no, $str, $file, $line, $context) {
// }, E_USER_WARNING);
//
// //テスト実行
// $this->_testGetAction('/test_blocks/test_block_tabs_component/index',
// array('method' => 'assertNotEmpty'), null, 'view');
//
// set_error_handler(null);
//
// //チェック
// $pattern = '/' . preg_quote('Controller/Component/TestBlockTabsComponent/index', '/') . '/';
// $this->assertRegExp($pattern, $this->view);
//
// $this->assertEquals($this->controller->components['Blocks.BlockTabs'], $this->controller->helpers['Blocks.BlockTabs']);
//}

/**
* startup()のテスト($controller->helpers[] = 'Blocks.BlockTabs'でセットされているものを削除)
*
* @return void
*/
public function testStartupInArray() {
//テストコントローラ生成
$this->generateNc('TestBlocks.TestBlockTabsComponentInArrayHelper');

//ログイン
TestAuthGeneral::login($this);

//Warningを無視する
$no = $str = $file = $line = $context = null;
set_error_handler(function ($no, $str, $file, $line, $context) {
}, E_USER_WARNING);

//テスト実行
$this->_testGetAction('/test_blocks/test_block_tabs_component_in_array_helper/index',
array('method' => 'assertNotEmpty'), null, 'view');

set_error_handler(null);

//チェック
$pattern = '/' . preg_quote('Controller/Component/TestBlockTabsComponent/index', '/') . '/';
$this->assertRegExp($pattern, $this->view);

$this->assertFalse(in_array('Blocks.BlockTabs', $this->controller->helpers, true));
$this->assertEquals($this->controller->components['Blocks.BlockTabs'], $this->controller->helpers['Blocks.BlockTabs']);
}

/**
* startup()のテスト(Warningの内容を確認する)
*
* @return void
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage Changed to BlockTabsHelper from BlockTabsComponent.
*/
//public function testStartupWarning() {
//public function testStartupInArray() {
// //テストコントローラ生成
// $this->generateNc('TestBlocks.TestBlockTabsComponent');
// $this->generateNc('TestBlocks.TestBlockTabsComponentInArrayHelper');
//
// //ログイン
// TestAuthGeneral::login($this);
//
// //Warningを無視する
// $no = $str = $file = $line = $context = null;
// set_error_handler(function ($no, $str, $file, $line, $context) {
// }, E_USER_WARNING);
//
// //テスト実行
// $this->_testGetAction('/test_blocks/test_block_tabs_component/index',
// $this->_testGetAction('/test_blocks/test_block_tabs_component_in_array_helper/index',
// array('method' => 'assertNotEmpty'), null, 'view');
//
// set_error_handler(null);
//
// //チェック
// $pattern = '/' . preg_quote('Controller/Component/TestBlockTabsComponent/index', '/') . '/';
// $this->assertRegExp($pattern, $this->view);
//
// $this->assertFalse(in_array('Blocks.BlockTabs', $this->controller->helpers, true));
// $this->assertEquals($this->controller->components['Blocks.BlockTabs'], $this->controller->helpers['Blocks.BlockTabs']);
//}

/**
* startup()のテスト(Warningの内容を確認する)
*
* @return void
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage Changed to BlockTabsHelper from BlockTabsComponent.
*/
public function testStartupWarning() {
//テストコントローラ生成
$this->generateNc('TestBlocks.TestBlockTabsComponent');

//ログイン
TestAuthGeneral::login($this);

//テスト実行
$this->_testGetAction('/test_blocks/test_block_tabs_component/index',
array('method' => 'assertNotEmpty'), null, 'view');
}

}

0 comments on commit 96f4be5

Please sign in to comment.