mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 11:44:10 +09:00
Add unit tests for ModuleInfoParser
This commit is contained in:
parent
9d88e53439
commit
1abdb2d788
4 changed files with 96 additions and 0 deletions
19
tests/_data/module/info.xml
Normal file
19
tests/_data/module/info.xml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module version="0.2">
|
||||||
|
<title xml:lang="ko">테스트 모듈</title>
|
||||||
|
<title xml:lang="en">Test Module</title>
|
||||||
|
<description xml:lang="ko">유닛 테스트용 모듈입니다.</description>
|
||||||
|
<description xml:lang="en">This module is for unit testing.</description>
|
||||||
|
<version>2.0</version>
|
||||||
|
<date>2020-07-07</date>
|
||||||
|
<category>service</category>
|
||||||
|
<license link="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPLv2</license>
|
||||||
|
<author email_address="devops@rhymix.org" link="https://rhymix.org">
|
||||||
|
<name xml:lang="ko">Rhymix 개발자</name>
|
||||||
|
<name xml:lang="en">Rhymix Developer</name>
|
||||||
|
</author>
|
||||||
|
<author email_address="other.developer@rhymix.org">
|
||||||
|
<name xml:lang="ko">다른 개발자</name>
|
||||||
|
<name xml:lang="en">Other Developer</name>
|
||||||
|
</author>
|
||||||
|
</module>
|
||||||
30
tests/_data/module/module.xml
Normal file
30
tests/_data/module/module.xml
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<module>
|
||||||
|
<grants>
|
||||||
|
<grant name="view" default="guest">
|
||||||
|
<title xml:lang="ko">열람</title>
|
||||||
|
<title xml:lang="en">View</title>
|
||||||
|
</grant>
|
||||||
|
</grants>
|
||||||
|
<actions>
|
||||||
|
<action name="dispTestView" type="view" permission="view" standalone="false" index="true">
|
||||||
|
<route route="$document_srl:int" priority="100" />
|
||||||
|
<route route="$document_srl:int/comment/$comment_srl:int" priority="70" />
|
||||||
|
<route route="$document_srl:int/tag/$tag:word" priority="50" />
|
||||||
|
</action>
|
||||||
|
<action name="dispTestWrite" type="view" permission="view" standalone="false" meta-noindex="true" route="write" global_route="true" />
|
||||||
|
<action name="procTestSubmitData" type="controller" standalone="false" check-csrf="false" ruleset="submitData" />
|
||||||
|
<action name="dispTestAdminIndex" type="view" admin_index="true" menu_name="test" menu_index="true" />
|
||||||
|
<action name="procTestAdminSubmitData" type="controller" permission="manager" check_var="module_srl" check_type="thisisatest" method="GET|POST" />
|
||||||
|
<action name="dispTestErrorHandler" type="view" standalone="true" error-handlers="404" />
|
||||||
|
</actions>
|
||||||
|
<menus>
|
||||||
|
<menu name="test" type="all">
|
||||||
|
<title xml:lang="ko">테스트 메뉴</title>
|
||||||
|
<title xml:lang="en">Test Menu</title>
|
||||||
|
</menu>
|
||||||
|
</menus>
|
||||||
|
<permissions>
|
||||||
|
<permission action="procTestSubmitData" target="view" />
|
||||||
|
</permissions>
|
||||||
|
</module>
|
||||||
10
tests/unit/framework/parsers/ModuleActionParserTest.php
Normal file
10
tests/unit/framework/parsers/ModuleActionParserTest.php
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class ModuleActionParserTest extends \Codeception\TestCase\Test
|
||||||
|
{
|
||||||
|
public function testLoadXML()
|
||||||
|
{
|
||||||
|
$info = Rhymix\Framework\Parsers\ModuleActionParser::loadXML(\RX_BASEDIR . 'tests/_data/module/module.xml');
|
||||||
|
$this->assertTrue(is_object($info));
|
||||||
|
}
|
||||||
|
}
|
||||||
37
tests/unit/framework/parsers/ModuleInfoParserTest.php
Normal file
37
tests/unit/framework/parsers/ModuleInfoParserTest.php
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class ModuleInfoParserTest extends \Codeception\TestCase\Test
|
||||||
|
{
|
||||||
|
public function testLoadXML()
|
||||||
|
{
|
||||||
|
Context::init();
|
||||||
|
Context::setLangType('ko');
|
||||||
|
$info = Rhymix\Framework\Parsers\ModuleInfoParser::loadXML(\RX_BASEDIR . 'tests/_data/module/info.xml');
|
||||||
|
$this->assertTrue(is_object($info));
|
||||||
|
$this->assertEquals('테스트 모듈', $info->title);
|
||||||
|
$this->assertEquals('유닛 테스트용 모듈입니다.', $info->description);
|
||||||
|
$this->assertEquals('2.0', $info->version);
|
||||||
|
$this->assertEquals('20200707', $info->date);
|
||||||
|
$this->assertEquals('service', $info->category);
|
||||||
|
$this->assertEquals('GPLv2', $info->license);
|
||||||
|
$this->assertEquals('https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html', $info->license_link);
|
||||||
|
$this->assertTrue(is_array($info->author));
|
||||||
|
$this->assertEquals('Rhymix 개발자', $info->author[0]->name);
|
||||||
|
$this->assertEquals('devops@rhymix.org', $info->author[0]->email_address);
|
||||||
|
$this->assertEquals('https://rhymix.org', $info->author[0]->homepage);
|
||||||
|
$this->assertEquals('다른 개발자', $info->author[1]->name);
|
||||||
|
$this->assertEquals('other.developer@rhymix.org', $info->author[1]->email_address);
|
||||||
|
$this->assertEquals('', $info->author[1]->homepage);
|
||||||
|
|
||||||
|
Context::setLangType('en');
|
||||||
|
$info = Rhymix\Framework\Parsers\ModuleInfoParser::loadXML(\RX_BASEDIR . 'tests/_data/module/info.xml');
|
||||||
|
$this->assertEquals('Test Module', $info->title);
|
||||||
|
$this->assertEquals('This module is for unit testing.', $info->description);
|
||||||
|
$this->assertEquals('Rhymix Developer', $info->author[0]->name);
|
||||||
|
|
||||||
|
$this->assertEquals('dispTestView', $info->default_index_act);
|
||||||
|
$this->assertEquals('dispTestAdminIndex', $info->admin_index_act);
|
||||||
|
$this->assertTrue(is_array($info->error_handlers));
|
||||||
|
$this->assertEquals('dispTestErrorHandler', $info->error_handlers[404]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue