Mwjames has uploaded a new change for review.
https://gerrit.wikimedia.org/r/60092
Change subject: Add SMW\Statistics class
......................................................................
Add SMW\Statistics class
* Move statisitcs into a separate class
* Add unit test for each statistics
* Add profiling point for each statistics
* Add caching of statistics results
* Add $smwgStatisticsCache and $smwgStatisticsCacheExpiry settings
## Default settings
$smwgStatisticsCache = true
$smwgStatisticsCacheExpiry = 3600
$smwgCacheType uses SMW's general purpose setting
Change-Id: Id189dd17c7e2591764896baf6e344b4590ca65e4
---
M SemanticMediaWiki.hooks.php
M SemanticMediaWiki.settings.php
M includes/Setup.php
A includes/Statistics.php
M includes/storage/SQLStore/SMW_SQLStore3_SpecialPageHandlers.php
A tests/phpunit/includes/StatisticsTest.php
6 files changed, 633 insertions(+), 104 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticMediaWiki
refs/changes/92/60092/1
diff --git a/SemanticMediaWiki.hooks.php b/SemanticMediaWiki.hooks.php
index 86a2b9a..ddef572 100644
--- a/SemanticMediaWiki.hooks.php
+++ b/SemanticMediaWiki.hooks.php
@@ -278,6 +278,7 @@
'Infolink',
'QueryProcessor',
'Hooks',
+ 'Statistics',
'dataitems/DI_Blob',
'dataitems/DI_Bool',
diff --git a/SemanticMediaWiki.settings.php b/SemanticMediaWiki.settings.php
index 36fc19c..8fe8a98 100644
--- a/SemanticMediaWiki.settings.php
+++ b/SemanticMediaWiki.settings.php
@@ -557,3 +557,15 @@
##
$smwgAutoRefreshOnPageMove = true;
##
+
+###
+# Enable to serve statistics from cache using the smwgCacheType setting
+#
+# @since 1.9
+###
+$smwgStatisticsCache = true;
+#
+# Number of seconds before the statistics cache expires
+##
+$smwgStatisticsCacheExpiry = 3600;
+##
\ No newline at end of file
diff --git a/includes/Setup.php b/includes/Setup.php
index b8fd9e7..5ed7835 100644
--- a/includes/Setup.php
+++ b/includes/Setup.php
@@ -141,6 +141,7 @@
$wgAutoloadClasses['SMW\ParserParameterFormatter'] = $incDir .
'ParserParameterFormatter.php';
$wgAutoloadClasses['SMW\Settings'] = $incDir .
'Settings.php';
+ $wgAutoloadClasses['SMW\Statistics'] = $incDir .
'Statistics.php';
// Article pages
$apDir = $smwgIP . 'includes/articlepages/';
diff --git a/includes/Statistics.php b/includes/Statistics.php
new file mode 100644
index 0000000..eddde8e
--- /dev/null
+++ b/includes/Statistics.php
@@ -0,0 +1,404 @@
+<?php
+
+namespace SMW;
+
+use DatabaseBase;
+use SMWDIProperty;
+use SMWStore;
+
+/**
+ * Access statistical information
+ *
+ * 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 2 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 1.9
+ *
+ * @file
+ * @ingroup SMW
+ *
+ * @licence GNU GPL v2+
+ * @author mwjames
+ */
+
+/**
+ * This class enables to access statistical information (count statistics)
+ * and trace them by the profiler individually while supporting to store
+ * statistics in cache to decrease database load
+ *
+ * @ingroup SMW
+ */
+class Statistics {
+
+ /**
+ * Represents the Store object
+ * @var SMWStore
+ */
+ protected $store;
+
+ /**
+ * Represents the DatabaseBase object
+ * @var DatabaseBase
+ */
+ protected $dbw;
+
+ /**
+ * Represents the Settings object
+ * @var Settings
+ */
+ protected $settings;
+
+ /**
+ * Represents a property table array
+ * @var array
+ */
+ protected static $propertyTables = null;
+
+ /**
+ * @since 1.9
+ *
+ * @param SMWStore $store
+ * @param DatabaseBase $dbw
+ * @param Settings $settings
+ */
+ public function __construct( SMWStore $store, DatabaseBase $dbw,
Settings $settings = null ) {
+ $this->store = $store;
+ $this->dbw = $dbw;
+ $this->settings = $settings;
+ }
+
+ /**
+ * Factory method for convenience instantiation of a Statistics object
+ *
+ * @par Example:
+ * @code
+ * $store = smwfGetStore();
+ * $statistics = SMW\Statistics::newFromStore( $store )->get();
+ * @endcode
+ *
+ * @since 1.9
+ *
+ * @param SMWStore $store
+ * @param $database Boolean or DatabaseBase:
+ * - Boolean: whether to use a dedicated DB or Slave
+ * - DatabaseBase: database connection to use
+ *
+ * @return Statistics
+ */
+ public static function newFromStore( SMWStore $store, $database = false
) {
+ $database = $database instanceof DatabaseBase ? $database :
wfGetDB( DB_SLAVE );
+ $settings = Settings::newFromArray( array(
+ 'smwgCacheType' => $GLOBALS['smwgCacheType'],
+ 'smwgStatisticsCache' =>
$GLOBALS['smwgStatisticsCache'],
+ 'smwgStatisticsCacheExpiry' =>
$GLOBALS['smwgStatisticsCacheExpiry']
+ ) );
+ return new self(
+ $store,
+ $database,
+ $settings
+ );
+ }
+
+ /**
+ * Return statistical information as an associative array with the
+ * following keys:
+ * - 'PROPUSES': Number of property instances (value assignments) in
the database
+ * - 'USEDPROPS': Number of properties that are used with at least one
value
+ * - 'DECLPROPS': Number of properties that have been declared (i.e.
assigned a type)
+ * - 'OWNPAGE': Number of properties with their own page
+ * - 'QUERY': Number of inline queries
+ * - 'QUERYSIZE': Represents collective query size
+ * - 'CONCEPTS': Number of declared concepts
+ * - 'SUBOBJECTS': Number of declared subobjects
+ * - 'QUERYFORMATS': Array of used formats and its usage count
+ *
+ * @note Results are cacheable if the corresponding settings are
available,
+ * access methods are not cached which means that only when using get()
+ * results are cacheable
+ *
+ * @see $smwgStatisticsCache
+ * @see $smwgStatisticsCacheExpiry
+ *
+ * @since 1.9
+ *
+ * @return array
+ */
+ public function get() {
+
+ // FIXME Use the new SMW\ICache, SMW\Cache class here instead
+ $cache = \ObjectCache::getInstance( $this->settings->get(
'smwgCacheType' ) );
+ $cacheKey = 'smw:statistics';
+ if ( $this->settings->get( 'smwgStatisticsCache' ) &&
+ $cache->get( $cacheKey ) ) {
+ wfDebug( __METHOD__ . ' statistics have been served
from cache' . "\n");
+ return $cache->get( $cacheKey );
+ }
+
+ $statistics = array(
+ 'OWNPAGE' => $this->getPropertyPageCount(),
+ 'QUERY' => $this->getQueryCount(),
+ 'QUERYSIZE' => $this->getQuerySize(),
+ 'QUERYFORMATS' => $this->getQueryFormatsCount(),
+ 'CONCEPTS' => $this->getConceptCount(),
+ 'SUBOBJECTS' => $this->getSubobjectCount(),
+ 'DECLPROPS' => $this->getDeclaredPropertiesCount(),
+ 'PROPUSES' => $this->getPropertyUsageCount(),
+ 'USEDPROPS' => $this->getUsedPropertiesCount()
+ );
+
+ if ( $this->settings->get( 'smwgStatisticsCache' ) ){
+ $cache->set(
+ $cacheKey,
+ $statistics,
+ $this->settings->get(
'smwgStatisticsCacheExpiry' )
+ );
+ }
+
+ return $statistics;
+ }
+
+ /**
+ * Convenience method to count on a single table for a given type
+ *
+ * @note Always ensure to set the array initially to 0/[] to avoid
+ * problems when accessing the array via a key
+ *
+ * @since 1.9
+ *
+ * @param string $type
+ * @param string $method a caller method to distinguish calls in the
profiler
+ *
+ * @return number
+ */
+ public function count( $type, $method = '' ) {
+ wfProfileIn( $method );
+
+ $count = 0;
+ $res = $this->dbw->select(
+ $this->getTypeTable( $type )->getName(),
+ 'COUNT(s_id) AS count',
+ array(),
+ __METHOD__
+ );
+ $row = $this->dbw->fetchObject( $res );
+
+ wfProfileOut( $method );
+ return (int)$row->count;
+ }
+
+ /**
+ * Count existing inline queries
+ *
+ * @since 1.9
+ *
+ * @return number
+ */
+ public function getQueryCount() {
+ return $this->count( '_ASK', __METHOD__ );
+ }
+
+ /**
+ * Count existing inline queries
+ *
+ * @since 1.9
+ *
+ * @return number
+ */
+ public function getQuerySize() {
+ return $this->count( '_ASKSI', __METHOD__ );
+ }
+
+ /**
+ * Count existing concepts
+ *
+ * @since 1.9
+ *
+ * @return number
+ */
+ public function getConceptCount() {
+ return $this->count( '_CONC', __METHOD__ );
+ }
+
+ /**
+ * Count existing subobjects
+ *
+ * @since 1.9
+ *
+ * @return number
+ */
+ public function getSubobjectCount() {
+ return $this->count( SMWDIProperty::TYPE_SUBOBJECT, __METHOD__
);
+ }
+
+ /**
+ * Count number of declared properties by counting "has type"
annotations
+ *
+ * @since 1.9
+ *
+ * @return number
+ */
+ public function getDeclaredPropertiesCount() {
+ return $this->count( SMWDIProperty::TYPE_HAS_TYPE, __METHOD__ );
+ }
+
+ /**
+ * Count used formats
+ *
+ * @since 1.9
+ *
+ * @return number
+ */
+ public function getQueryFormatsCount() {
+ wfProfileIn( __METHOD__ );
+
+ $count = array();
+ $res = $this->dbw->select(
+ $this->getTypeTable( '_ASKFO' )->getName(),
+ 'o_hash, COUNT(s_id) AS count',
+ array(),
+ __METHOD__,
+ array(
+ 'ORDER BY' => 'count DESC',
+ 'GROUP BY' => 'o_hash'
+ )
+ );
+
+ foreach ( $res as $row ) {
+ $count[$row->o_hash] = (int)$row->count;
+ }
+
+ wfProfileOut( __METHOD__ );
+ return $count;
+ }
+
+ /**
+ * Count properties with their own page
+ *
+ * @since 1.9
+ *
+ * @return number
+ */
+ public function getPropertyPageCount() {
+ wfProfileIn( __METHOD__ );
+
+ $count = 0;
+ $count = $this->dbw->estimateRowCount(
+ 'page',
+ '*',
+ array( 'page_namespace' => SMW_NS_PROPERTY )
+ );
+
+ wfProfileOut( __METHOD__ );
+ return (int)$count;
+ }
+
+ /**
+ * Count property uses by counting rows in property tables
+ *
+ * @note subproperties that are part of container values are counted
+ * individually and it does not seem to be important to filter them by
+ * adding more conditions.
+ *
+ * @since 1.9
+ *
+ * @return number
+ */
+ public function getPropertyUsageCount() {
+ wfProfileIn( __METHOD__ );
+
+ $count = 0;
+ foreach ( $this->getPropertyTables() as $propertyTable ) {
+ $res = $this->dbw->select(
+ $propertyTable->getName(),
+ 'COUNT(*) AS count',
+ array(),
+ __METHOD__
+ );
+ $row = $this->dbw->fetchObject( $res );
+ $count += $row->count;
+ }
+
+ wfProfileOut( __METHOD__ );
+ return (int)$count;
+ }
+
+ /**
+ * Count used properties by counting distinct properties in each table
+ *
+ * @since 1.9
+ *
+ * @return number
+ */
+ public function getUsedPropertiesCount() {
+ wfProfileIn( __METHOD__ );
+
+ $count = 0;
+ foreach ( $this->getPropertyTables() as $propertyTable ) {
+ if ( !$propertyTable->isFixedPropertyTable() ) {
+ $res = $this->dbw->select(
+ $propertyTable->getName(),
+ 'COUNT(DISTINCT(p_id)) AS count',
+ array(),
+ __METHOD__
+ );
+ $row = $this->dbw->fetchObject( $res );
+ $count += $row->count;
+ } else {
+ $res = $this->dbw->select(
+ $propertyTable->getName(),
+ '*',
+ array(),
+ __METHOD__,
+ array( 'LIMIT' => 1 )
+ );
+ if ( $this->dbw->numRows( $res ) > 0 ) {
+ $count++;
+ }
+ }
+ }
+
+ wfProfileOut( __METHOD__ );
+ return (int)$count;
+ }
+
+ /**
+ * Returns an array of predefined property table declarations
+ *
+ * @since 1.9
+ *
+ * @return array
+ */
+ protected function getPropertyTables() {
+ if ( self::$propertyTables === null ) {
+ self::$propertyTables =
$this->store->getPropertyTables();
+ }
+ return self::$propertyTables;
+ }
+
+ /**
+ * Returns a table declarations for a given type
+ *
+ * @since 1.9
+ *
+ * @param string $type
+ *
+ * @return array
+ */
+ protected function getTypeTable( $type ) {
+ $typeProp = new SMWDIProperty( $type );
+ $propertyTables = $this->getPropertyTables();
+ return $propertyTables[$this->store->findPropertyTableID(
$typeProp )];
+ }
+}
diff --git a/includes/storage/SQLStore/SMW_SQLStore3_SpecialPageHandlers.php
b/includes/storage/SQLStore/SMW_SQLStore3_SpecialPageHandlers.php
index 52b596e..fb0a634 100644
--- a/includes/storage/SQLStore/SMW_SQLStore3_SpecialPageHandlers.php
+++ b/includes/storage/SQLStore/SMW_SQLStore3_SpecialPageHandlers.php
@@ -189,113 +189,12 @@
/**
* @see SMWStore::getStatistics
- *
- * @note Always ensure to set the array initially to 0 to avoid
problems when
- * accessing the array via a key
+ * @see Statistics:get
*
* @return array
*/
public function getStatistics() {
- wfProfileIn( 'SMWSQLStore3::getStatistics (SMW)' );
-
- $dbr = wfGetDB( DB_SLAVE );
- $result = array();
- $propertyTables = SMWSQLStore3::getPropertyTables();
-
- // Properties with their own page
- $result['OWNPAGE'] = 0;
- $result['OWNPAGE'] = $dbr->estimateRowCount( 'page', '*',
array( 'page_namespace' => SMW_NS_PROPERTY ) );
-
- // Count existing inline queries
- $result['QUERY'] = 0;
- $typeProp = new SMWDIProperty( '_ASK' );
- $typeTable = $propertyTables[SMWSQLStore3::findPropertyTableID(
$typeProp )];
- $res = $dbr->select( $typeTable->getName(), 'COUNT(s_id) AS
count', array(), 'SMW::getStatistics' );
- $row = $dbr->fetchObject( $res );
- $result['QUERY'] = $row->count;
- $dbr->freeResult( $res );
-
- // Count query size
- $result['QUERYSIZE'] = 0;
- $typeProp = new SMWDIProperty( '_ASKSI' );
- $typeTable = $propertyTables[SMWSQLStore3::findPropertyTableID(
$typeProp )];
- $res = $dbr->select( $typeTable->getName(), 'COUNT(s_id) AS
count', array(), 'SMW::getStatistics' );
- $row = $dbr->fetchObject( $res );
- $result['QUERYSIZE'] = $row->count;
- $dbr->freeResult( $res );
-
- // Count used formats
- $result['QUERYFORMATS'] = array();
- $typeProp = new SMWDIProperty( '_ASKFO' );
- $typeTable = $propertyTables[SMWSQLStore3::findPropertyTableID(
$typeProp )];
- $res = $dbr->select(
- $typeTable->getName(),
- 'o_hash, COUNT(s_id) AS count',
- array(),
- 'SMW::getStatistics',
- array(
- 'ORDER BY' => 'count DESC',
- 'GROUP BY' => 'o_hash'
- )
- );
-
- foreach ( $res as $row ) {
- $result['QUERYFORMATS'][$row->o_hash] =
(int)$row->count;
- }
- $dbr->freeResult( $res );
-
- // Count existing concepts
- $result['CONCEPTS'] = 0;
- $typeProp = new SMWDIProperty( '_CONC' );
- $typeTable = $propertyTables[SMWSQLStore3::findPropertyTableID(
$typeProp )];
- $res = $dbr->select( $typeTable->getName(), 'COUNT(s_id) AS
count', array(), 'SMW::getStatistics' );
- $row = $dbr->fetchObject( $res );
- $result['CONCEPTS'] = $row->count;
- $dbr->freeResult( $res );
-
- // Count existing subobjects
- $result['SUBOBJECTS'] = 0;
- $typeProp = new SMWDIProperty( SMWDIProperty::TYPE_SUBOBJECT );
- $typeTable = $propertyTables[SMWSQLStore3::findPropertyTableID(
$typeProp )];
- $res = $dbr->select( $typeTable->getName(), 'COUNT(s_id) AS
count', array(), 'SMW::getStatistics' );
- $row = $dbr->fetchObject( $res );
- $result['SUBOBJECTS'] = $row->count;
- $dbr->freeResult( $res );
-
- // count number of declared properties by counting "has type"
annotations
- $typeProp = new SMWDIProperty( '_TYPE' );
- $typeTable = $propertyTables[SMWSQLStore3::findPropertyTableID(
$typeProp )];
- $res = $dbr->select( $typeTable->getName(), 'COUNT(s_id) AS
count', array(), 'SMW::getStatistics' );
- $row = $dbr->fetchObject( $res );
- $result['DECLPROPS'] = $row->count;
- $dbr->freeResult( $res );
-
- // count property uses by counting rows in property tables,
- // count used properties by counting distinct properties in
each table
- $result['PROPUSES'] = 0;
- $result['USEDPROPS'] = 0;
-
- foreach ( SMWSQLStore3::getPropertyTables() as $propertyTable )
{
- /// Note: subproperties that are part of container
values are counted individually;
- /// It does not seem to be important to filter them by
adding more conditions.
- $res = $dbr->select( $propertyTable->getName(),
'COUNT(*) AS count', '', 'SMW::getStatistics' );
- $row = $dbr->fetchObject( $res );
- $result['PROPUSES'] += $row->count;
- $dbr->freeResult( $res );
-
- if ( !$propertyTable->isFixedPropertyTable() ) {
- $res = $dbr->select( $propertyTable->getName(),
'COUNT(DISTINCT(p_id)) AS count', '', 'SMW::getStatistics' );
- $row = $dbr->fetchObject( $res );
- $result['USEDPROPS'] += $row->count;
- } else {
- $res = $dbr->select( $propertyTable->getName(),
'*', '', 'SMW::getStatistics', array( 'LIMIT' => 1 ) );
- if ( $dbr->numRows( $res ) > 0 )
$result['USEDPROPS']++;
- }
-
- $dbr->freeResult( $res );
- }
-
- wfProfileOut( 'SMWSQLStore3::getStatistics (SMW)' );
- return $result;
+ // Profiling is done in the Statistics class
+ return \SMW\Statistics::newFromStore( smwfGetStore() )->get();
}
}
diff --git a/tests/phpunit/includes/StatisticsTest.php
b/tests/phpunit/includes/StatisticsTest.php
new file mode 100644
index 0000000..086a58e
--- /dev/null
+++ b/tests/phpunit/includes/StatisticsTest.php
@@ -0,0 +1,212 @@
+<?php
+
+namespace SMW\Test;
+
+use SMW\Statistics;
+use SMW\Settings;
+
+/**
+ * Tests for the SMW\Statistics class
+ *
+ * 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 2 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 1.9
+ *
+ * @file
+ * @ingroup SMW
+ * @ingroup Test
+ *
+ * @group SMW
+ * @group SMWExtension
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ * @author mwjames
+ */
+
+/**
+ * This class tests methods provided by the SMW\Statistics class
+ *
+ * @ingroup SMW
+ * @ingroup Test
+ */
+class StatisticsTest extends \MediaWikiTestCase {
+
+ protected $className = 'SMW\Statistics';
+
+ /**
+ * Helper method that returns a Statistics object
+ *
+ * @since 1.9
+ *
+ * @return Settings
+ */
+ private function getInstance() {
+ $settings = Settings::newFromArray( array(
+ 'smwgCacheType' => CACHE_ANYTHING,
+ 'smwgStatisticsCache' => false,
+ 'smwgStatisticsCacheExpiry' => 3600
+ ) );
+ return new Statistics(
+ smwfGetStore(),
+ wfGetDB( DB_SLAVE ),
+ $settings
+ );
+ }
+
+ /**
+ * Test Statistics::__construct
+ *
+ * @since 1.9
+ */
+ public function testConstructor() {
+ $instance = $this->getInstance();
+ $this->assertInstanceOf( $this->className, $instance );
+ }
+
+ /**
+ * Test Statistics::newFromStore
+ *
+ * @since 1.9
+ */
+ public function testNewFromStore() {
+ $instance = Statistics::newFromStore( smwfGetStore() );
+ $this->assertInstanceOf( $this->className, $instance );
+ }
+
+ /**
+ * Test Statistics::getPropertyPageCount
+ *
+ * @since 1.9
+ */
+ public function testGetPropertyPageCount() {
+ $instance = $this->getInstance();
+ $this->assertInternalType( 'integer',
$instance->getPropertyPageCount() );
+ }
+
+ /**
+ * Test Statistics::getQueryCount
+ *
+ * @since 1.9
+ */
+ public function testGetQueryCount() {
+ $instance = $this->getInstance();
+ $this->assertInternalType( 'integer',
$instance->getQueryCount() );
+ }
+
+ /**
+ * Test Statistics::getQuerySize
+ *
+ * @since 1.9
+ */
+ public function testGetQuerySize() {
+ $instance = $this->getInstance();
+ $this->assertInternalType( 'integer', $instance->getQuerySize()
);
+ }
+
+ /**
+ * Test Statistics::getQueryFormatsCount
+ *
+ * @since 1.9
+ */
+ public function testGetQueryFormatsCount() {
+ $instance = $this->getInstance();
+ $this->assertInternalType( 'array',
$instance->getQueryFormatsCount() );
+ }
+
+ /**
+ * Test Statistics::getConceptCount
+ *
+ * @since 1.9
+ */
+ public function testGetConceptCount() {
+ $instance = $this->getInstance();
+ $this->assertInternalType( 'integer',
$instance->getConceptCount() );
+ }
+
+ /**
+ * Test Statistics::getSubobjectCount
+ *
+ * @since 1.9
+ */
+ public function testGetSubobjectCount() {
+ $instance = $this->getInstance();
+ $this->assertInternalType( 'integer',
$instance->getSubobjectCount() );
+ }
+
+ /**
+ * Test Statistics::getDeclaredPropertiesCount
+ *
+ * @since 1.9
+ */
+ public function testGetDeclaredPropertiesCount() {
+ $instance = $this->getInstance();
+ $this->assertInternalType( 'integer',
$instance->getDeclaredPropertiesCount() );
+ }
+
+ /**
+ * Test Statistics::getPropertyUsageCount
+ *
+ * @since 1.9
+ */
+ public function testGetPropertyUsageCount() {
+ $instance = $this->getInstance();
+ $this->assertInternalType( 'integer',
$instance->getPropertyUsageCount() );
+ }
+
+ /**
+ * Test Statistics::getUsedPropertiesCount
+ *
+ * @since 1.9
+ */
+ public function testGetUsedPropertiesCount() {
+ $instance = $this->getInstance();
+ $this->assertInternalType( 'integer',
$instance->getUsedPropertiesCount() );
+ }
+
+ /**
+ * DataProvider
+ *
+ * @return array
+ */
+ public function getDataProvider() {
+ return array(
+ array( 'OWNPAGE' ),
+ array( 'QUERY' ),
+ array( 'QUERYSIZE' ),
+ array( 'QUERYFORMATS' ),
+ array( 'CONCEPTS' ),
+ array( 'SUBOBJECTS' ),
+ array( 'DECLPROPS' ),
+ array( 'USEDPROPS' ),
+ array( 'PROPUSES' )
+ );
+ }
+
+ /**
+ * Test Statistics::get
+ *
+ * @since 1.9
+ *
+ * @dataProvider getDataProvider
+ * @param $segment
+ */
+ public function testGet( $segment ) {
+ $instance = $this->getInstance();
+ $result = $instance->get();
+ $this->assertNotEmpty( $result[$segment] );
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/60092
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id189dd17c7e2591764896baf6e344b4590ca65e4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits