コード例 #1
0
ファイル: StoreTest.php プロジェクト: joetm/sameAs-Lite
 /**
  * Can get the correct statistics
  *
  * @covers \SameAsLite\StoreInterface::statistics
  */
 public function testStatistics()
 {
     $stats = $this->store->statistics();
     $this->assertEquals(['symbols' => 5, 'bundles' => 3], $stats);
 }
コード例 #2
0
ファイル: WebApp.php プロジェクト: joetm/sameAs-Lite
 /**
  * Add a dataset to this web application
  *
  * @param \SameAsLite\StoreInterface $store   A class implimenting StoreInterface to contain the data
  * @param array                      $options Array of configration options describing the dataset
  *
  * @throws \SameAsLite\ConfigException if there are problems with arguments in config.ini
  */
 public function addDataset(\SameAsLite\StoreInterface $store, array $options)
 {
     foreach (array('slug', 'shortName') as $configoption) {
         if (!isset($options[$configoption])) {
             throw new Exception\ConfigException('The Store array is missing required key/value "' . $configoption . '" in config.ini');
         }
     }
     if (!isset($options['fullName'])) {
         // as promised in config.ini, if fullName is not defined, it is set to shortName
         // $options['fullName'] = ucwords($options['shortName']);
         $options['fullName'] = $options['shortName'];
     }
     if (!preg_match('/^[A-Za-z0-9_\\-]*$/', $options['slug'])) {
         throw new Exception\ConfigException('The value for "slug" in config.ini may contain only characters a-z, A-Z, 0-9, hyphen and underscore');
     }
     if (isset($this->stores[$options['slug']])) {
         throw new Exception\ConfigException('You have already added a store with "slug" value of ' . $options['slug'] . ' in config.ini.');
     }
     // Connect to the DB
     $store->connect();
     $this->stores[$options['slug']] = $store;
     $this->storeOptions[$options['slug']] = $options;
     // store the slug for analysis output
     $this->stores[$options['slug']]->storeSlug($options['slug']);
 }