2015-10-02 08:58:54 +00:00
|
|
|
<?php
|
|
|
|
|
2015-10-07 15:18:54 +00:00
|
|
|
namespace PageImages\Tests;
|
2015-10-02 08:58:54 +00:00
|
|
|
|
2024-01-05 21:37:40 +00:00
|
|
|
use MediaWiki\Config\HashConfig;
|
2024-03-18 21:54:02 +00:00
|
|
|
use MediaWiki\Page\PageReferenceValue;
|
|
|
|
use MediaWikiIntegrationTestCase;
|
2020-04-19 22:41:19 +00:00
|
|
|
use PageImages\ApiQueryPageImages;
|
|
|
|
use PageImages\PageImages;
|
2022-04-03 23:28:52 +00:00
|
|
|
use Wikimedia\ParamValidator\ParamValidator;
|
2022-04-03 20:16:07 +00:00
|
|
|
use Wikimedia\ParamValidator\TypeDef\IntegerDef;
|
2018-01-04 22:41:54 +00:00
|
|
|
use Wikimedia\Rdbms\FakeResultWrapper;
|
2017-04-20 07:48:48 +00:00
|
|
|
use Wikimedia\TestingAccessWrapper;
|
2015-10-02 08:58:54 +00:00
|
|
|
|
2015-10-07 15:18:54 +00:00
|
|
|
/**
|
2020-10-22 20:04:23 +00:00
|
|
|
* @covers \PageImages\ApiQueryPageImages
|
2015-10-07 15:18:54 +00:00
|
|
|
*
|
|
|
|
* @group PageImages
|
|
|
|
*
|
2018-05-25 04:42:29 +00:00
|
|
|
* @license WTFPL
|
2015-11-16 14:59:34 +00:00
|
|
|
* @author Sam Smith
|
2017-11-24 07:33:49 +00:00
|
|
|
* @author Thiemo Kreuz
|
2015-10-07 15:18:54 +00:00
|
|
|
*/
|
2024-03-18 21:54:02 +00:00
|
|
|
class ApiQueryPageImagesTest extends MediaWikiIntegrationTestCase {
|
2015-10-02 08:58:54 +00:00
|
|
|
|
2015-10-26 10:41:13 +00:00
|
|
|
private function newInstance() {
|
2024-01-05 21:37:40 +00:00
|
|
|
$config = new HashConfig( [
|
2017-05-20 14:29:31 +00:00
|
|
|
'PageImagesAPIDefaultLicense' => 'free'
|
2017-05-30 19:49:44 +00:00
|
|
|
] );
|
2017-05-20 14:29:31 +00:00
|
|
|
|
2021-05-04 14:48:45 +00:00
|
|
|
$context = $this->createMock( \IContextSource::class );
|
2015-10-07 15:18:54 +00:00
|
|
|
|
2021-05-04 14:48:45 +00:00
|
|
|
$context->method( 'getConfig' )
|
2017-05-20 14:29:31 +00:00
|
|
|
->willReturn( $config );
|
|
|
|
|
2024-02-08 11:07:29 +00:00
|
|
|
$main = $this->createMock( \ApiMain::class );
|
2015-10-07 15:18:54 +00:00
|
|
|
$main->expects( $this->once() )
|
|
|
|
->method( 'getContext' )
|
2021-03-20 05:22:04 +00:00
|
|
|
->willReturn( $context );
|
2015-10-07 15:18:54 +00:00
|
|
|
|
2024-02-08 11:07:29 +00:00
|
|
|
$query = $this->createMock( \ApiQuery::class );
|
2015-10-07 15:18:54 +00:00
|
|
|
$query->expects( $this->once() )
|
|
|
|
->method( 'getMain' )
|
2021-03-20 05:22:04 +00:00
|
|
|
->willReturn( $main );
|
2015-10-07 15:18:54 +00:00
|
|
|
|
2024-03-18 21:54:02 +00:00
|
|
|
return new ApiQueryPageImages( $query, '', $this->getServiceContainer()->getRepoGroup() );
|
2015-10-07 15:18:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testConstructor() {
|
2015-10-26 10:41:13 +00:00
|
|
|
$instance = $this->newInstance();
|
2020-04-19 22:41:19 +00:00
|
|
|
$this->assertInstanceOf( ApiQueryPageImages::class, $instance );
|
2015-10-07 15:18:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetCacheMode() {
|
2015-10-26 10:41:13 +00:00
|
|
|
$instance = $this->newInstance();
|
2016-12-02 00:49:13 +00:00
|
|
|
$this->assertSame( 'public', $instance->getCacheMode( [] ) );
|
2015-10-07 15:18:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetAllowedParams() {
|
2015-10-26 10:41:13 +00:00
|
|
|
$instance = $this->newInstance();
|
|
|
|
$params = $instance->getAllowedParams();
|
2021-03-20 05:22:04 +00:00
|
|
|
|
2020-01-14 08:47:58 +00:00
|
|
|
$this->assertIsArray( $params );
|
2015-10-07 15:18:54 +00:00
|
|
|
$this->assertNotEmpty( $params );
|
|
|
|
$this->assertContainsOnly( 'array', $params );
|
2017-05-19 13:04:26 +00:00
|
|
|
$this->assertArrayHasKey( 'limit', $params );
|
2022-04-03 23:28:52 +00:00
|
|
|
$this->assertSame( 50, $params['limit'][ParamValidator::PARAM_DEFAULT] );
|
|
|
|
$this->assertSame( 'limit', $params['limit'][ParamValidator::PARAM_TYPE] );
|
2022-04-03 20:16:07 +00:00
|
|
|
$this->assertSame( 1, $params['limit'][IntegerDef::PARAM_MIN] );
|
|
|
|
$this->assertSame( 50, $params['limit'][IntegerDef::PARAM_MAX] );
|
|
|
|
$this->assertSame( 100, $params['limit'][IntegerDef::PARAM_MAX2] );
|
2016-11-10 00:02:00 +00:00
|
|
|
$this->assertArrayHasKey( 'license', $params );
|
2022-04-03 23:28:52 +00:00
|
|
|
$this->assertSame( [ 'free', 'any' ], $params['license'][ParamValidator::PARAM_TYPE] );
|
|
|
|
$this->assertSame( 'free', $params['license'][ParamValidator::PARAM_DEFAULT] );
|
|
|
|
$this->assertFalse( $params['license'][ParamValidator::PARAM_ISMULTI] );
|
2015-10-07 15:18:54 +00:00
|
|
|
}
|
|
|
|
|
2015-10-02 08:58:54 +00:00
|
|
|
/**
|
|
|
|
* @dataProvider provideGetTitles
|
|
|
|
*/
|
2024-03-18 21:54:02 +00:00
|
|
|
public function testGetTitles( $pageNames, $missingTitlesByNamespace, $expectedNames ) {
|
|
|
|
$titleParser = $this->getServiceContainer()->getTitleParser();
|
|
|
|
$titles = [];
|
|
|
|
foreach ( $pageNames as $pageName ) {
|
|
|
|
$titleValue = $titleParser->parseTitle( $pageName );
|
|
|
|
$titles[] = PageReferenceValue::localReference( $titleValue->getNamespace(), $titleValue->getDBkey() );
|
|
|
|
}
|
|
|
|
$expected = [];
|
|
|
|
foreach ( $expectedNames as $id => $expectedName ) {
|
|
|
|
$titleValue = $titleParser->parseTitle( $expectedName );
|
|
|
|
$expected[$id] = PageReferenceValue::localReference( $titleValue->getNamespace(), $titleValue->getDBkey() );
|
|
|
|
}
|
|
|
|
|
2024-02-08 11:07:29 +00:00
|
|
|
$pageSet = $this->createMock( \ApiPageSet::class );
|
2024-03-18 21:54:02 +00:00
|
|
|
$pageSet->method( 'getGoodPages' )
|
2021-03-20 05:22:04 +00:00
|
|
|
->willReturn( $titles );
|
2021-05-04 14:48:45 +00:00
|
|
|
$pageSet->method( 'getMissingTitlesByNamespace' )
|
2021-03-20 05:22:04 +00:00
|
|
|
->willReturn( $missingTitlesByNamespace );
|
2017-12-21 04:50:27 +00:00
|
|
|
$queryPageImages = new ApiQueryPageImagesProxyMock( $pageSet );
|
2015-10-02 08:58:54 +00:00
|
|
|
|
|
|
|
$this->assertEquals( $expected, $queryPageImages->getTitles() );
|
|
|
|
}
|
|
|
|
|
2023-05-20 15:29:11 +00:00
|
|
|
public static function provideGetTitles() {
|
2016-12-02 00:49:13 +00:00
|
|
|
return [
|
|
|
|
[
|
2024-03-18 21:54:02 +00:00
|
|
|
[ 'Foo' ],
|
2016-12-02 00:49:13 +00:00
|
|
|
[],
|
2024-03-18 21:54:02 +00:00
|
|
|
[ 'Foo' ],
|
2016-12-02 00:49:13 +00:00
|
|
|
],
|
|
|
|
[
|
2024-03-18 21:54:02 +00:00
|
|
|
[ 'Foo' ],
|
2016-12-02 00:49:13 +00:00
|
|
|
[
|
|
|
|
NS_TALK => [
|
2015-10-02 08:58:54 +00:00
|
|
|
'Bar' => -1,
|
2016-12-02 00:49:13 +00:00
|
|
|
],
|
|
|
|
],
|
2024-03-18 21:54:02 +00:00
|
|
|
[ 'Foo' ],
|
2016-12-02 00:49:13 +00:00
|
|
|
],
|
|
|
|
[
|
2024-03-18 21:54:02 +00:00
|
|
|
[ 'Foo' ],
|
2016-12-02 00:49:13 +00:00
|
|
|
[
|
|
|
|
NS_FILE => [
|
2015-10-02 08:58:54 +00:00
|
|
|
'Bar' => -1,
|
2016-12-02 00:49:13 +00:00
|
|
|
],
|
|
|
|
],
|
|
|
|
[
|
2024-03-18 21:54:02 +00:00
|
|
|
0 => 'Foo',
|
|
|
|
-1 => 'File:Bar',
|
2016-12-02 00:49:13 +00:00
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
2015-10-02 08:58:54 +00:00
|
|
|
}
|
2015-10-07 15:18:54 +00:00
|
|
|
|
2016-11-17 16:28:08 +00:00
|
|
|
/**
|
|
|
|
* @dataProvider provideExecute
|
|
|
|
* @param array $requestParams Request parameters to the API
|
2024-03-18 21:54:02 +00:00
|
|
|
* @param array $pageNames Page titles passed to the API
|
2016-11-17 16:28:08 +00:00
|
|
|
* @param array $queryPageIds Page IDs that will be used for querying the DB.
|
|
|
|
* @param array $queryResults Results of the DB select query
|
|
|
|
* @param int $setResultValueCount The number results the API returned
|
|
|
|
*/
|
2024-03-18 21:54:02 +00:00
|
|
|
public function testExecute( $requestParams, $pageNames, $queryPageIds,
|
2017-05-30 19:49:44 +00:00
|
|
|
$queryResults, $setResultValueCount
|
|
|
|
) {
|
2024-03-18 21:54:02 +00:00
|
|
|
$titles = [];
|
|
|
|
foreach ( $pageNames as $pageName ) {
|
|
|
|
$titles[] = PageReferenceValue::localReference( NS_MAIN, $pageName );
|
|
|
|
}
|
2016-11-10 00:02:00 +00:00
|
|
|
$mock = TestingAccessWrapper::newFromObject(
|
|
|
|
$this->getMockBuilder( ApiQueryPageImages::class )
|
|
|
|
->disableOriginalConstructor()
|
2021-05-12 09:23:38 +00:00
|
|
|
->onlyMethods( [ 'extractRequestParams', 'getTitles', 'dieWithError',
|
2016-12-02 00:49:13 +00:00
|
|
|
'addTables', 'addFields', 'addWhere', 'select', 'setResultValues' ] )
|
2016-11-10 00:02:00 +00:00
|
|
|
->getMock()
|
|
|
|
);
|
2021-05-04 14:48:45 +00:00
|
|
|
$mock->method( 'extractRequestParams' )
|
2016-11-17 16:28:08 +00:00
|
|
|
->willReturn( $requestParams );
|
2021-05-04 14:48:45 +00:00
|
|
|
$mock->method( 'getTitles' )
|
2016-11-17 16:28:08 +00:00
|
|
|
->willReturn( $titles );
|
2021-05-04 14:48:45 +00:00
|
|
|
$mock->method( 'select' )
|
2016-11-17 16:28:08 +00:00
|
|
|
->willReturn( new FakeResultWrapper( $queryResults ) );
|
|
|
|
|
|
|
|
// continue page ID is not found
|
2017-05-30 19:49:44 +00:00
|
|
|
if ( isset( $requestParams['continue'] )
|
|
|
|
&& $requestParams['continue'] > count( $titles )
|
|
|
|
) {
|
2021-05-04 14:48:45 +00:00
|
|
|
$mock->expects( $this->once() )
|
2021-05-12 09:23:38 +00:00
|
|
|
->method( 'dieWithError' );
|
2016-11-17 16:28:08 +00:00
|
|
|
}
|
|
|
|
|
2016-12-02 22:09:55 +00:00
|
|
|
$originalRequested = in_array( 'original', $requestParams['prop'] );
|
|
|
|
$this->assertTrue( $this->hasExpectedProperties( $queryResults, $originalRequested ) );
|
|
|
|
|
2021-05-04 14:51:18 +00:00
|
|
|
$license = $requestParams['license'] ?? 'free';
|
2020-04-20 13:34:12 +00:00
|
|
|
if ( $license == PageImages::LICENSE_ANY ) {
|
2016-12-02 00:49:13 +00:00
|
|
|
$propName = [ PageImages::getPropName( true ), PageImages::getPropName( false ) ];
|
2016-11-10 00:02:00 +00:00
|
|
|
} else {
|
|
|
|
$propName = PageImages::getPropName( true );
|
|
|
|
}
|
2016-12-02 00:49:13 +00:00
|
|
|
$mock->expects( $this->exactly( count( $queryPageIds ) > 0 ? 1 : 0 ) )
|
2016-11-17 16:28:08 +00:00
|
|
|
->method( 'addWhere' )
|
2016-12-02 00:49:13 +00:00
|
|
|
->with( [ 'pp_page' => $queryPageIds, 'pp_propname' => $propName ] );
|
2016-11-17 16:28:08 +00:00
|
|
|
|
|
|
|
$mock->expects( $this->exactly( $setResultValueCount ) )
|
|
|
|
->method( 'setResultValues' );
|
|
|
|
|
|
|
|
$mock->execute();
|
|
|
|
}
|
|
|
|
|
2023-05-20 15:29:11 +00:00
|
|
|
public static function provideExecute() {
|
2016-11-17 16:28:08 +00:00
|
|
|
return [
|
|
|
|
[
|
2020-08-12 10:32:53 +00:00
|
|
|
[ 'prop' => [ 'thumbnail' ], 'thumbsize' => 100, 'limit' => 10,
|
|
|
|
'license' => 'any', 'langcode' => null ],
|
2024-03-18 21:54:02 +00:00
|
|
|
[ 'Page 1', 'Page 2' ],
|
2016-12-02 00:49:13 +00:00
|
|
|
[ 0, 1 ],
|
2016-11-17 16:28:08 +00:00
|
|
|
[
|
2017-06-20 07:17:38 +00:00
|
|
|
(object)[ 'pp_page' => 0, 'pp_value' => 'A_Free.jpg',
|
2017-05-30 19:49:44 +00:00
|
|
|
'pp_propname' => PageImages::PROP_NAME_FREE ],
|
2017-06-20 07:17:38 +00:00
|
|
|
(object)[ 'pp_page' => 0, 'pp_value' => 'A.jpg',
|
2017-05-30 19:49:44 +00:00
|
|
|
'pp_propname' => PageImages::PROP_NAME ],
|
2017-06-20 07:17:38 +00:00
|
|
|
(object)[ 'pp_page' => 1, 'pp_value' => 'B.jpg',
|
2017-05-30 19:49:44 +00:00
|
|
|
'pp_propname' => PageImages::PROP_NAME ],
|
2016-11-17 16:28:08 +00:00
|
|
|
],
|
|
|
|
2
|
|
|
|
],
|
|
|
|
[
|
2020-08-12 10:32:53 +00:00
|
|
|
[ 'prop' => [ 'thumbnail' ], 'thumbsize' => 200, 'limit' => 10, 'langcode' => null ],
|
2016-11-17 16:28:08 +00:00
|
|
|
[],
|
|
|
|
[],
|
|
|
|
[],
|
|
|
|
0
|
|
|
|
],
|
|
|
|
[
|
2017-05-30 19:49:44 +00:00
|
|
|
[ 'prop' => [ 'thumbnail' ], 'continue' => 1, 'thumbsize' => 400,
|
2020-08-12 10:32:53 +00:00
|
|
|
'limit' => 10, 'license' => 'any', 'langcode' => null ],
|
2024-03-18 21:54:02 +00:00
|
|
|
[ 'Page 1', 'Page 2' ],
|
2016-12-02 00:49:13 +00:00
|
|
|
[ 1 ],
|
2016-11-10 00:02:00 +00:00
|
|
|
[
|
2017-06-20 07:17:38 +00:00
|
|
|
(object)[ 'pp_page' => 1, 'pp_value' => 'B_Free.jpg',
|
2017-05-30 19:49:44 +00:00
|
|
|
'pp_propname' => PageImages::PROP_NAME_FREE ],
|
2017-06-20 07:17:38 +00:00
|
|
|
(object)[ 'pp_page' => 1, 'pp_value' => 'B.jpg',
|
2017-05-30 19:49:44 +00:00
|
|
|
'pp_propname' => PageImages::PROP_NAME ],
|
2016-11-10 00:02:00 +00:00
|
|
|
],
|
|
|
|
1
|
|
|
|
],
|
|
|
|
[
|
2020-08-12 10:32:53 +00:00
|
|
|
[ 'prop' => [ 'thumbnail' ], 'thumbsize' => 500, 'limit' => 10,
|
|
|
|
'license' => 'any', 'langcode' => 'en' ],
|
2024-03-18 21:54:02 +00:00
|
|
|
[ 'Page 1', 'Page 2' ],
|
2016-12-02 00:49:13 +00:00
|
|
|
[ 0, 1 ],
|
2016-11-10 00:02:00 +00:00
|
|
|
[
|
2017-06-20 07:17:38 +00:00
|
|
|
(object)[ 'pp_page' => 1, 'pp_value' => 'B_Free.jpg',
|
2017-05-30 19:49:44 +00:00
|
|
|
'pp_propname' => PageImages::PROP_NAME ],
|
2016-11-10 00:02:00 +00:00
|
|
|
],
|
|
|
|
1
|
|
|
|
],
|
|
|
|
[
|
2017-05-30 19:49:44 +00:00
|
|
|
[ 'prop' => [ 'thumbnail' ], 'continue' => 1, 'thumbsize' => 500,
|
2020-08-12 10:32:53 +00:00
|
|
|
'limit' => 10, 'license' => 'any', 'langcode' => 'de' ],
|
2024-03-18 21:54:02 +00:00
|
|
|
[ 'Page 1', 'Page 2' ],
|
2016-12-02 00:49:13 +00:00
|
|
|
[ 1 ],
|
2016-11-17 16:28:08 +00:00
|
|
|
[
|
2017-06-20 07:17:38 +00:00
|
|
|
(object)[ 'pp_page' => 1, 'pp_value' => 'B_Free.jpg',
|
2017-05-30 19:49:44 +00:00
|
|
|
'pp_propname' => PageImages::PROP_NAME_FREE ],
|
2016-11-17 16:28:08 +00:00
|
|
|
],
|
|
|
|
1
|
|
|
|
],
|
2016-11-10 00:02:00 +00:00
|
|
|
[
|
2020-08-12 10:32:53 +00:00
|
|
|
[ 'prop' => [ 'thumbnail' ], 'thumbsize' => 510, 'limit' => 10,
|
|
|
|
'license' => 'free', 'langcode' => 'de' ],
|
2024-03-18 21:54:02 +00:00
|
|
|
[ 'Page 1', 'Page 2' ],
|
2016-12-02 00:49:13 +00:00
|
|
|
[ 0, 1 ],
|
2016-11-10 00:02:00 +00:00
|
|
|
[],
|
|
|
|
0
|
|
|
|
],
|
|
|
|
[
|
2020-08-12 10:32:53 +00:00
|
|
|
[ 'prop' => [ 'thumbnail' ], 'thumbsize' => 510, 'limit' => 10,
|
|
|
|
'license' => 'free', 'langcode' => 'en' ],
|
2024-03-18 21:54:02 +00:00
|
|
|
[ 'Page 1', 'Page 2' ],
|
2016-12-02 00:49:13 +00:00
|
|
|
[ 0, 1 ],
|
2016-11-10 00:02:00 +00:00
|
|
|
[
|
2017-06-20 07:17:38 +00:00
|
|
|
(object)[ 'pp_page' => 0, 'pp_value' => 'A_Free.jpg',
|
2017-05-30 19:49:44 +00:00
|
|
|
'pp_propname' => PageImages::PROP_NAME_FREE ],
|
2017-06-20 07:17:38 +00:00
|
|
|
(object)[ 'pp_page' => 1, 'pp_value' => 'B_Free.jpg',
|
2017-05-30 19:49:44 +00:00
|
|
|
'pp_propname' => PageImages::PROP_NAME_FREE ],
|
2016-11-10 00:02:00 +00:00
|
|
|
],
|
|
|
|
2
|
|
|
|
],
|
2016-12-02 22:09:55 +00:00
|
|
|
[
|
2017-05-30 19:49:44 +00:00
|
|
|
[ 'prop' => [ 'thumbnail', 'original' ], 'thumbsize' => 510,
|
2020-08-12 10:32:53 +00:00
|
|
|
'limit' => 10, 'license' => 'free', 'langcode' => 'en' ],
|
2024-03-18 21:54:02 +00:00
|
|
|
[ 'Page 1', 'Page 2' ],
|
2017-05-30 19:49:44 +00:00
|
|
|
[ 0, 1 ],
|
2016-12-02 22:09:55 +00:00
|
|
|
[
|
2017-06-20 07:17:38 +00:00
|
|
|
(object)[
|
2017-05-30 19:49:44 +00:00
|
|
|
'pp_page' => 0, 'pp_value' => 'A_Free.jpg',
|
|
|
|
'pp_value_original' => 'A_Free_original.jpg', 'pp_original_width' => 80,
|
|
|
|
'pp_original_height' => 80, 'pp_propname' => PageImages::PROP_NAME_FREE
|
|
|
|
],
|
2017-06-20 07:17:38 +00:00
|
|
|
(object)[
|
2017-05-30 19:49:44 +00:00
|
|
|
'pp_page' => 1, 'pp_value' => 'B_Free.jpg',
|
|
|
|
'pp_value_original' => 'B_Free_original.jpg', 'pp_original_width' => 80,
|
|
|
|
'pp_original_height' => 80, 'pp_propname' => PageImages::PROP_NAME_FREE
|
|
|
|
],
|
2016-12-02 22:09:55 +00:00
|
|
|
],
|
|
|
|
2
|
|
|
|
],
|
2016-11-10 00:02:00 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-12-02 22:09:55 +00:00
|
|
|
private function hasExpectedProperties( $queryResults, $originalRequested ) {
|
|
|
|
if ( $originalRequested ) {
|
|
|
|
return $this->allResultsHaveProperty( $queryResults, 'pp_value_original' )
|
|
|
|
&& $this->allResultsHaveProperty( $queryResults, 'pp_original_width' )
|
|
|
|
&& $this->allResultsHaveProperty( $queryResults, 'pp_original_height' );
|
|
|
|
} else {
|
|
|
|
return $this->noResultsHaveProperty( $queryResults, 'pp_value_original' )
|
|
|
|
&& $this->noResultsHaveProperty( $queryResults, 'pp_original_width' )
|
|
|
|
&& $this->noResultsHaveProperty( $queryResults, 'pp_original_height' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function noResultsHaveProperty( $queryResults, $propName ) {
|
2017-05-30 19:49:44 +00:00
|
|
|
foreach ( $queryResults as $result ) {
|
2016-12-02 22:09:55 +00:00
|
|
|
if ( property_exists( $result, $propName ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function allResultsHaveProperty( $queryResults, $propName ) {
|
2017-05-30 19:49:44 +00:00
|
|
|
foreach ( $queryResults as $result ) {
|
2016-12-02 22:09:55 +00:00
|
|
|
if ( !property_exists( $result, $propName ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2015-10-02 08:58:54 +00:00
|
|
|
}
|