-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4fe00d5
commit 9062a55
Showing
4 changed files
with
239 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php | ||
/** | ||
* Language::getLanguages()のテスト | ||
* | ||
* @author Noriko Arai <arai@nii.ac.jp> | ||
* @author Shohei Nakajima <nakajimashouhei@gmail.com> | ||
* @link http://www.netcommons.org NetCommons Project | ||
* @license http://www.netcommons.org/license.txt NetCommons License | ||
* @copyright Copyright 2014, NetCommons Project | ||
*/ | ||
|
||
App::uses('M17nGetTest', 'M17n.TestSuite'); | ||
App::uses('Language', 'M17n.Model'); | ||
|
||
/** | ||
* Language::getLanguages()のテスト | ||
* | ||
* @author Shohei Nakajima <nakajimashouhei@gmail.com> | ||
* @package NetCommons\M17n\Test\Case\Model\Language | ||
*/ | ||
class LanguageGetLanguagesTest extends M17nGetTest { | ||
|
||
/** | ||
* Fixtures | ||
* | ||
* @var array | ||
*/ | ||
public $fixtures = array( | ||
'plugin.m17n.language', | ||
); | ||
|
||
/** | ||
* Plugin name | ||
* | ||
* @var string | ||
*/ | ||
public $plugin = 'm17n'; | ||
|
||
/** | ||
* Model name | ||
* | ||
* @var string | ||
*/ | ||
protected $_modelName = 'Language'; | ||
|
||
/** | ||
* Method name | ||
* | ||
* @var string | ||
*/ | ||
protected $_methodName = 'getLanguages'; | ||
|
||
/** | ||
* getLanguages()のテスト | ||
* | ||
* @return void | ||
*/ | ||
public function testGetLanguages() { | ||
$model = $this->_modelName; | ||
$methodName = $this->_methodName; | ||
|
||
//テスト実施 | ||
$result = $this->$model->$methodName(); | ||
|
||
//チェック | ||
$expected = array( | ||
0 => array( | ||
'Language' => array( | ||
'id' => '1', | ||
'code' => 'en', | ||
'weight' => '1', | ||
'is_active' => true, | ||
'created_user' => null, | ||
'created' => '2014-07-03 05:00:39', | ||
'modified_user' => null, | ||
'modified' => '2014-07-03 05:00:39', | ||
), | ||
), | ||
1 => array( | ||
'Language' => array( | ||
'id' => '2', | ||
'code' => 'ja', | ||
'weight' => '2', | ||
'is_active' => true, | ||
'created_user' => null, | ||
'created' => '2014-07-03 05:00:39', | ||
'modified_user' => null, | ||
'modified' => '2014-07-03 05:00:39', | ||
), | ||
), | ||
); | ||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
/** | ||
* getLanguages()の既に取得済みの場合のテスト | ||
* | ||
* @return void | ||
*/ | ||
public function testGetLanguagesWithData() { | ||
$model = $this->_modelName; | ||
$methodName = $this->_methodName; | ||
|
||
Language::$languages = array('test dummy'); | ||
|
||
//テスト実施 | ||
$result = $this->$model->$methodName(); | ||
|
||
//チェック | ||
$expected = array('test dummy'); | ||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
} |
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,77 @@ | ||
<?php | ||
/** | ||
* M17nGetTest TestCase | ||
* | ||
* @author Noriko Arai <arai@nii.ac.jp> | ||
* @author Shohei Nakajima <nakajimashouhei@gmail.com> | ||
* @link http://www.netcommons.org NetCommons Project | ||
* @license http://www.netcommons.org/license.txt NetCommons License | ||
* @copyright Copyright 2014, NetCommons Project | ||
*/ | ||
|
||
//@codeCoverageIgnoreStart; | ||
App::uses('NetCommonsGetTest', 'NetCommons.TestSuite'); | ||
//@codeCoverageIgnoreEnd; | ||
|
||
/** | ||
* M17nGetTest TestCase | ||
* | ||
* @author Shohei Nakajima <nakajimashouhei@gmail.com> | ||
* @package NetCommons\M17n\TestSuite | ||
* @codeCoverageIgnore | ||
*/ | ||
class M17nGetTest extends NetCommonsGetTest { | ||
|
||
/** | ||
* Fixtures | ||
* | ||
* @var array | ||
*/ | ||
private $__fixtures = array(); | ||
|
||
/** | ||
* Plugin name | ||
* | ||
* @var string | ||
*/ | ||
public $plugin = 'm17n'; | ||
|
||
/** | ||
* Fixtures load | ||
* | ||
* @param string $name The name parameter on PHPUnit_Framework_TestCase::__construct() | ||
* @param array $data The data parameter on PHPUnit_Framework_TestCase::__construct() | ||
* @param string $dataName The dataName parameter on PHPUnit_Framework_TestCase::__construct() | ||
* @return void | ||
*/ | ||
public function __construct($name = null, array $data = array(), $dataName = '') { | ||
if (! isset($this->fixtures)) { | ||
$this->fixtures = array(); | ||
} | ||
$this->fixtures = array_merge($this->__fixtures, $this->fixtures); | ||
parent::__construct($name, $data, $dataName); | ||
} | ||
|
||
/** | ||
* setUp method | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() { | ||
parent::setUp(); | ||
|
||
Language::$languages = array(); | ||
} | ||
|
||
/** | ||
* tearDown method | ||
* | ||
* @return void | ||
*/ | ||
public function tearDown() { | ||
Language::$languages = array(); | ||
|
||
parent::tearDown(); | ||
} | ||
|
||
} |