Archived
1
0
Fork 0
This commit is contained in:
Alexander Yakovlev 2018-09-24 13:40:01 +07:00
parent f98926b03d
commit b15224381a
4 changed files with 360 additions and 6 deletions

29
tests/BaseTest.php Normal file
View file

@ -0,0 +1,29 @@
<?php
/*
* A set of utilities for tracking text-based game releases
* Copyright (C) 2018 Alexander Yakovlev <keloero@oreolek.ru>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'vendor/autoload.php';
require_once 'Game.php';
require_once 'Source.php';
require_once 'Source/Itch.php';
use PHPUnit\Framework\TestCase;
abstract class BaseTest extends TestCase
{
protected $parser;
}

View file

@ -17,15 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'vendor/autoload.php';
require_once 'Game.php';
require_once 'Source.php';
require_once 'BaseTest.php';
require_once 'Source/Itch.php';
use PHPUnit\Framework\TestCase;
class ItchTest extends TestCase
class ItchTest extends BaseTest
{
protected $parser;
protected function setUp() {
$this->parser = new Source\Itch();
}

44
tests/QspTest.php Normal file
View file

@ -0,0 +1,44 @@
<?php
/*
* A set of utilities for tracking text-based game releases
* Copyright (C) 2018 Alexander Yakovlev <keloero@oreolek.ru>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'BaseTest.php';
require_once 'Source/Qsp.php';
class QspTest extends BaseTest
{
protected function setUp() {
$this->parser = new Source\Qsp();
}
public function testPageCheck()
{
$this->assertTrue($this->parser->checkPage('http://qsp.su/index.php?option=com_sobi2&sobi2Task=sobi2Details&sobi2Id=364&Itemid=55'));
}
public function testPageParsing()
{
// we trick parser to think the page is online but we parse an offline copy
$url = 'http://qsp.su/index.php?option=com_sobi2&sobi2Task=sobi2Details&sobi2Id=364&Itemid=55';
$game_page = file_get_contents('./tests/fixtures/qsp_test_1.html');
$this->parser->loadStr($game_page, []);
$game = $this->parser->page($url);
$this->assertSame($game->url, $url);
$this->assertSame($game->title, 'Асатама II: Лунные земли');
$this->assertSame($game->author, 'Mkir');
$this->assertSame($game->platform, 'QSP');
}
}

285
tests/fixtures/qsp_test_1.html vendored Normal file
View file

@ -0,0 +1,285 @@
<!-- http://qsp.su/index.php?option=com_sobi2&sobi2Task=sobi2Details&sobi2Id=364&Itemid=55 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru-ru" lang="ru-ru" dir="ltr" >
<head>
<link href="/templates/coolness/css/template_css.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#container { width: 965px; }
#content { float:left; width: 99.9%!important; width: auto; }
#maincol { margin-right: 15px; margin-left: 15px; position:relative!important; position:inherit; float:none!important; float:left; width: auto; overflow:hidden }
#leftcol { width: 200px!important; width: 192px; float:left; margin: 0px 15px!important; margin:0px 15px 0 7px; }
#rightcol { width: 280px!important; width: 272px; float:right; margin: 0px 15px!important; margin:0px 7px; }
#multicol { width: 920px!important; width: 912px; margin: 0px 28px!important; margin:0px 15px 0px 7px; }
#menusearch { background: #4A9CD5 url(/templates/coolness/images/head_foot.png) no-repeat 0 -611px; }
ul.menu a { color:#2a7190; }
ul.menu a:hover, #menu ul.menu li a, ul.menu li.active a, ul#mainlevel li.active a, ul#mainlevel a:hover, td.sectiontableheader, .sectiontableheader, #inner .dynamic-tab-pane-control .tab-row .tab.hover.selected, #inner .dynamic-tab-pane-control .tab-row .tab.selected, .jpcool_dialog_menu ul.menu li a:hover, .jpcool_dialog_menu ul.menu li.active a, .cbSSmenu ul:hover, .cbSSmenu a:hover, .cbSSmenu a:focus, .cbMenu a:hover, .cbMenu a:focus { background:#4A9CD5; }
table.cb-tips-bg, legend { background-color:#4A9CD5; }
.createdate { border-bottom: solid 1px #4A9CD5; }
.modifydate { border-top: solid 1px #4A9CD5; }
#header { border-bottom: solid 3px #4A9CD5; }
.inputbox, .cb-tips-fg, TEXTAREA, .cbMenu, .cbSSmenu { border: solid 1px #4A9CD5; }
#logo h1, #logo h1 a, a:link, a:visited, a:hover, #botmenu a:hover, .cbMenu a, .cbSSmenu a, .cbMenu a:link, .cbMenu a:visited, .cbMenu a:hover, .cbSSmenu a:link, .cbSSmenu a:visited, .cbSSmenu a:hover, .cbMenu, .cbSSmenu, table.adminform textarea { color:#2a7190; }
#leftcol div.module h3, #leftcol div.module, #leftcol div.module_menu { width: 200px; }
#rightcol div.module h3, #rightcol div.module, #rightcol div.module_menu { width: 280px; }
#multicol div.module h3, #multicol div.module, #multicol div.module_menu { width: 920px; }
</style>
<!--[if IE 6]>
<style>
#menu ul li { padding: 3px 15px; margin: 0px; }
#menu ul li a { padding: 0px; height: auto; }
.jpcool_dialog .jpcool_content,.jpcool_dialog_menu .jpcool_content {zoom:1;overflow-y:hidden;}
.jpcool_dialog .jpcool_top,.jpcool_dialog_menu .jpcool_top {height:1600px; }
</style>
<![endif]-->
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="robots" content="NOODP, index, follow" />
<meta name="keywords" content=", " />
<meta name="description" content="Ты - простой солдат, которого судьба занесла в неприветливый, загадочный край. Где никогда не заходит луна и солнце меркнет в ее сиянии, где в сухих пустошах бродят гигантские рыбы и каменные львы. Выбирай, к чему стремиться: пытаться ли найти покой и счастье, дом, любовь, дружбу, либо участвовать в политических распрях правителей этих земель. " />
<meta name="generator" content="Joomla! 1.5 - Open Source Content Management. Sigsiu Online Business Index " />
<title>Асатама II: Лунные земли - QSP - Текстовые игры на любой вкус</title>
<link href="/index.php?option=com_jcomments&amp;task=rss&amp;object_id=364&amp;object_group=com_sobi2&amp;format=raw" rel="alternate" type="application/rss+xml" title="Асатама II: Лунные земли" />
<link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link rel="stylesheet" href="/components/com_jcomments/tpl/qsp/style.css?v=12" type="text/css" />
<link rel="stylesheet" href="http://qsp.su/plugins/content/attachments.css" type="text/css" />
<link rel="stylesheet" href="http://qsp.su/components/com_uddeim/templates/default/css/uddemodule.css" type="text/css" />
<script type="text/javascript" src="/media/system/js/mootools.js"></script>
<script type="text/javascript" src="/components/com_jcomments/js/jcomments-v2.1.js?v=7"></script>
<script type="text/javascript" src="/components/com_jcomments/libraries/joomlatune/ajax.js?v=3"></script>
<script type="text/javascript">
window.addEvent('domready', function(){ var JTooltips = new Tips($$('.hasTip'), { maxTitleChars: 50, fixed: false}); });
</script>
<link rel="stylesheet" href="http://qsp.su/components/com_sobi2/templates/standard_advanced/css/standard_advanced.css" type="text/css"/>
<link rel="stylesheet" href="http://qsp.su/components/com_sobi2/includes/com_sobi2.css" type="text/css" />
<link rel='StyleSheet' href='http://qsp.su/components/com_sobi2/plugins/download/download.css' type='text/css' />
<link href='http://qsp.su/components/com_sobi2/plugins/likes/likes.css' rel='stylesheet' type='text/css' />
<link rel="alternate" type="application/rss+xml" title="" href="http://qsp.su/index.php?option=com_sobi2&amp;sobi2Task=rss&amp;no_html=1&amp;catid=1&amp;Itemid=55" />
<script language="javascript" type="text/javascript">
<!-- /* <![CDATA[ */
var Limages = new Array();
Limages[0] = "/components/com_sobi2/plugins/likes/images/heart_off.png";
Limages[1] = "/components/com_sobi2/plugins/likes/images/heart_on.png";
var likesNames = "Последний из Гаяр, alienpost, NickoAilus, yobasss, RomaDova, De@th K!d";
/* ]]> */ // --> </script>
<script src="/components/com_sobi2/plugins/likes/js/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="/components/com_sobi2/plugins/likes/js/tooltip.js" type="text/javascript"></script>
<link rel="image_src" href="http://qsp.su/images/com_sobi2/clients/364_img.jpg">
</head>
<body id="page_bg">
<div align="center">
<div id="container">
<div id="header">
<div id="logo">
<h1><a href="/"><img src=./templates/coolness/images/headerlogo.png></a></h1>
</div>
<div id="sloganmenu">
<div id="slogan"><h2>Текстовые игры на любой вкус</h2></div>
<div id="menusearch">
<div id="menu"><ul class="menu"><li class="item1"><a href="http://qsp.su/"><span>Главная</span></a></li><li class="item55"><a href="/index.php?option=com_sobi2&amp;Itemid=55"><span>Игры</span></a></li><li class="item64"><a href="/index.php?option=com_content&amp;view=article&amp;id=61&amp;Itemid=64"><span>Конкурсы</span></a></li><li class="item56"><a href="/index.php?option=com_content&amp;view=article&amp;id=57&amp;Itemid=56"><span>Разработчикам</span></a></li><li class="item83"><a href="http://wiki.qsp.su"><span>Документация</span></a></li><li id="current" class="active item57"><a href="/index.php?option=com_agora&amp;Itemid=57"><span>Форум</span></a></li></ul><div class="toplogin"><a href="http://qsp.su/index.php?option=com_comprofiler&task=login">Войти</a> или <a href="http://qsp.su/index.php?option=com_comprofiler&task=registers">Зарегистрироваться</a></div></div>
<div id="search"></div>
<div class="clr"></div>
</div>
<div class="clr"></div>
</div>
<div class="clr"></div>
</div>
<div id="content">
<div id="pathflags">
<div id="path"></div>
<div id="flags"><!--
<div class="qsp_btn_download">
<div class="txt">
Скачайте набор игрока - <a href=index.php?some>Набор игрока 0.2</a>
</div>
</div>
-->
<div style="display: inline; float: left; padding-top: 3px;font-size:15px;"><a href="http://qsp.su/attachments/players_pack_2010_06_17.exe" mce_href="/attachments/players_pack_2010_06_17.exe"><b>Скачать Набор Игрока 1.2</b></div></a></div>
<div class="clr"></div>
</div>
<!--
<div id="maincol">
!!!! Nex's hack !!!!
-->
<div id="maincol">
<!--
-->
<div id="topcurve"><span>&nbsp;</span></div>
<div id="mainborders">
<div id="topusers1">
<div id="user3"></div> </div>
<div id="inner">
<!-- start of Sigsiu Online Business Index 2 component -->
<div class="componentheading"></div>
<div class='sobi2'>
<table class="sobi2Header">
<tr>
<td id="sobi2HeaderSearchLink"> <a class="sobi2Header" href="http://qsp.su/index.php?option=com_sobi2&amp;sobi2Task=search&amp;Itemid=55">Поиск</a> </td>
</tr>
</table>
<table class="sobi2Details" style='' >
<tr>
<td><h1>Асатама II: Лунные земли</h1></td>
</tr>
<tr>
<td valign="top">
<img src="http://qsp.su/images/com_sobi2/clients/364_img.jpg" alt="Асатама II: Лунные земли" class="sobi2DetailsImage"/> <br/>
<span id="sobi2Details_field_author" ><span id="sobi2Listing_field_author_label">Автор игры:</span> Mkir</span><br/>
<span id="sobi2Details_field_version" ><span id="sobi2Listing_field_version_label">Версия игры:</span> 1.6</span>
<span id="sobi2Details_field_description"><div>Ты - простой солдат, которого судьба занесла в неприветливый, загадочный край.&nbsp;</div><div>Где никогда не заходит луна и солнце меркнет в ее сиянии, где в сухих пустошах бродят гигантские рыбы и каменные львы.&nbsp;</div><div>Выбирай, к чему стремиться: пытаться ли найти покой и счастье, дом, любовь, дружбу, либо участвовать в политических распрях правителей этих земель. &nbsp;</div><div><br /></div></span> <br />
</td>
</tr>
<tr>
<td>
<div style="border-style:none; display:block;padding:10px;">
<div style="display:block;">Файл: <a href="http://qsp.su/index2.php?option=com_sobi2&amp;sobi2Task=dd_download&amp;fid=927&amp;format=html" title="moonland1_6_3.rar">moonland1_6_3.rar</a>, 22223 kB</div>
<div style="display:block;">Скачиваний: 914</div>
<div style="display:block;">Последнее изменение: 11.6.2018</div>
<div style="display:block;"><h2><a href="http://qsp.su/index2.php?option=com_sobi2&amp;sobi2Task=dd_download&amp;fid=927&amp;format=html" title="download">Скачать</a></h2></div>
</div>
</td>
</tr>
</table>
<table class="sobi2DetailsFooter" width="100%">
<tr>
<td>
Добавлено: 19.6.2017&nbsp;&nbsp;Просмотров: 2116 </td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>
<div id="srLikesRespCont"></div><div id="likesCont"><span id="likesPictureCont"><img src="/components/com_sobi2/plugins/likes/images/heart_on.png"></span><span id="likesTotalCont">6</span>
</div> </td>
</tr>
<tr>
<td>
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style "
addthis:title="Асатама II: Лунные земли"
addthis:url="http://qsp.su/index.php?option=com_sobi2&sobi2Task=sobi2Details&sobi2Id=364&Itemid=55"
>
<a class="addthis_button_twitter"></a>
<a class="addthis_button_facebook"></a>
<a class="addthis_button_vk"></a>
<a class="addthis_button_livejournal"></a>
<a class="addthis_button_compact"></a>
<a class="addthis_counter addthis_bubble_style"></a>
</div>
<script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4e27d2b702e0d433"></script>
<!-- AddThis Button END -->
</td>
</tr>
</table>
<br>
<script type="text/javascript">
<!--
var jcomments=new JComments(364, 'com_sobi2','/index.php?option=com_jcomments&amp;tmpl=component');
jcomments.setList('comments-list');
//-->
</script>
<div id="jc">
<div id="comments"></div>
<div id="comments-footer" align="center"><a href="http://www.joomlatune.ru" title="JComments" target="_blank">JComments</a></div>
<script type="text/javascript">
<!--
jcomments.setAntiCache(1,1,1);
//-->
</script>
</div>
<table class="sobi2Footer">
<tr><td id="sobi2Footer"></td> <td id="sobi2rss"><a href="http://qsp.su/index.php?option=com_sobi2&amp;sobi2Task=rss&amp;no_html=1&amp;catid=&amp;Itemid=55" title="RSS Feeds"><img src="http://qsp.su/components/com_sobi2/images/feed.gif" alt="RSS Feeds"/></a></td></tr> <tr><td colspan="2"></td></tr>
</table>
</div>
<!-- end of Sigsiu Online Business Index 2 component Memory 7,918,224 / Time 0.053683042526245 / Queries: 0 -->
</div>
<div class="clr"></div>
</div>
<div id="botcurve"><span>&nbsp;</span></div>
</div>
<!--
!!!! Nex's hack !!!!
-->
<!--
!!!! Nex's hack !!!!
-->
</div>
<div class="clr_bot"></div>
<div id="foot">
<div id="footl">
<div id="botmenu"><ul class="menu"><li class="item73"><a href="/index.php?option=com_content&amp;view=article&amp;id=47&amp;Itemid=73"><span>FAQ</span></a></li><li class="item70"><a href="http://ifwiki.ru" target="_blank"><span>IFWiki</span></a></li><li class="item71"><a href="http://ifiction.ru"><span>IFiction</span></a></li><li class="item81"><a href="http://ifprint.org/" target="_blank"><span>IFprint</span></a></li><li class="item82"><a href="http://rilarhiv.ru/" target="_blank"><span>Архив текстовых игр</span></a></li><li class="item72"><a href="http://tinyurl.com/qsp-irc2"><span>#qsp</span></a></li><li class="item80"><a href="/index.php?option=com_content&amp;view=article&amp;id=115&amp;Itemid=80"><span>AeroQSP</span></a></li><li class="item84"><a href="https://github.com/QSPFoundation/qsp" target="_blank"><span>Исходный код</span></a></li><li class="item85"><a href="/index.php?option=com_jawards&amp;Itemid=85"><span>Доска почёта</span></a></li></ul></div>
<div id="copyright"></div>
</div>
<div id="footr"> <div class="moduletable_online">
<h3>Сейчас на сайте:</h3>
<ul class='mod_login_online'>
<li><a href='http://qsp.su/index.php?option=com_comprofiler&amp;task=userprofile&amp;user=639' class='mod_login_online'>De@th K!d</a></li>
</ul>
</div>
<div class="moduletable">
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-7014404-1");
pageTracker._trackPageview();
} catch(err) {}
</script> </div>
</div>
<div class="clr"></div>
</div>
</div>
</div>
</body>
</html>