mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-14 19:31:44 +00:00
Add tests for ApiQueryAllInfoboxes (#42)
This commit is contained in:
parent
de39a61206
commit
a7a41fa0f1
6
.github/workflows/mediawiki-tests.yml
vendored
6
.github/workflows/mediawiki-tests.yml
vendored
|
@ -267,12 +267,6 @@ jobs:
|
|||
docker load -i /home/runner/docker-images/"${QUIBBLE_DOCKER_IMAGE}" || \
|
||||
docker pull "${DOCKER_REGISTRY}/${DOCKER_ORG}/${QUIBBLE_DOCKER_IMAGE}:${QUIBBLE_DOCKER_LATEST_TAG}"
|
||||
|
||||
- name: Cache MediaWiki installation
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /home/runner/src
|
||||
key: ${{ runner.os }}-${{ env.MEDIAWIKI_VERSION }}-${{ hashFiles('.github/workflows/dependencies') }}
|
||||
|
||||
- name: Download MediaWiki and extensions
|
||||
run: |
|
||||
cd /home/runner
|
||||
|
|
|
@ -8,6 +8,14 @@ class ApiQueryAllInfoboxes extends ApiQueryBase {
|
|||
|
||||
public const MCACHE_KEY = 'allinfoboxes-list';
|
||||
|
||||
/**
|
||||
* @param ApiQuery $query
|
||||
* @param string $moduleName
|
||||
*/
|
||||
public function __construct( ApiQuery $query, $moduleName ) {
|
||||
parent::__construct( $query, $moduleName, 'api' );
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$db = $this->getDB();
|
||||
$res = $this->getResult();
|
||||
|
|
|
@ -14,21 +14,21 @@ class AllInfoboxesQueryPage extends PageQueryPage {
|
|||
$query = [
|
||||
'tables' => [ 'page', 'page_props' ],
|
||||
'fields' => [
|
||||
'namespace' => 'page.page_namespace',
|
||||
'title' => 'page.page_title',
|
||||
'value' => 'page.page_id',
|
||||
'infoboxes' => 'page_props.pp_value'
|
||||
'namespace' => 'page_namespace',
|
||||
'title' => 'page_title',
|
||||
'value' => 'page_id',
|
||||
'infoboxes' => 'pp_value'
|
||||
],
|
||||
'conds' => [
|
||||
'page.page_is_redirect' => 0,
|
||||
'page.page_namespace' => NS_TEMPLATE,
|
||||
'page_props.pp_value IS NOT NULL',
|
||||
'page_props.pp_value != \'\''
|
||||
'page_is_redirect' => 0,
|
||||
'page_namespace' => NS_TEMPLATE,
|
||||
'pp_value IS NOT NULL',
|
||||
'pp_value != \'\''
|
||||
],
|
||||
'join_conds' => [
|
||||
'page_props' => [
|
||||
'INNER JOIN',
|
||||
'page.page_id = page_props.pp_page AND page_props.pp_propname = "infoboxes"'
|
||||
'page_id = pp_page AND pp_propname = "infoboxes"'
|
||||
]
|
||||
]
|
||||
];
|
||||
|
@ -37,7 +37,7 @@ class AllInfoboxesQueryPage extends PageQueryPage {
|
|||
|
||||
$subpagesBlacklist = $this->getConfig()->get( 'AllInfoboxesSubpagesBlacklist' );
|
||||
foreach ( $subpagesBlacklist as $subpage ) {
|
||||
$query['conds'][] = 'page.page_title NOT ' . $dbr->buildLike( "/{$subpage}" );
|
||||
$query['conds'][] = 'page_title NOT ' . $dbr->buildLike( "/{$subpage}" );
|
||||
}
|
||||
|
||||
return $query;
|
||||
|
|
23
tests/phpunit/QueryAllInfoboxesTest.php
Normal file
23
tests/phpunit/QueryAllInfoboxesTest.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group medium
|
||||
* @coversDefaultClass ApiQueryAllInfoboxes
|
||||
*/
|
||||
class QueryAllInfoboxesTest extends ApiTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::execute
|
||||
* @covers ::createLabel
|
||||
* @covers AllInfoboxesQueryPage::doQuery
|
||||
*/
|
||||
public function testQueryAllInfoboxes() {
|
||||
$this->doApiRequest( [
|
||||
'action' => 'query',
|
||||
'list' => 'allinfoboxes',
|
||||
], null, null, self::getTestUser()->getUser() );
|
||||
$this->addToAssertionCount( 1 );
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue