Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert OnPreReferenceTest to BTB #4249

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 19 additions & 32 deletions modules/metastore/tests/src/Functional/OnPreReferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@

namespace Drupal\Tests\metastore\Functional;

use Drupal\Tests\common\Traits\CleanUp;
use weitzman\DrupalTestTraits\ExistingSiteBase;
use Drupal\Tests\BrowserTestBase;

/**
* Run tests in separate processes, since they rely on the value of
* drupal_static().
* @runTestsInSeparateProcesses
* @group dkan
* @group metastore
* @group functional
* @group btb
*/
class OnPreReferenceTest extends ExistingSiteBase {
use CleanUp;
class OnPreReferenceTest extends BrowserTestBase {

private $downloadUrl = "https://dkan-default-content-files.s3.amazonaws.com/phpunit/district_centerpoints_small.csv";
protected static $modules = [
'datastore',
'metastore',
'node',
];

protected $defaultTheme = 'stark';

private $downloadUrl = 'https://dkan-default-content-files.s3.amazonaws.com/phpunit/district_centerpoints_small.csv';

/**
*
*/
private function getData($downloadUrl) {
return '
{
Expand All @@ -37,21 +41,16 @@ private function getData($downloadUrl) {
}';
}

/**
*
*/
public function test() {
/** @var \Drupal\Core\Config\ConfigFactory $config_factory */
$config_factory = \Drupal::service('config.factory');
// Ensure the proper triggering properties are set for datastore comparison.
$datastore_settings = $config_factory->getEditable('datastore.settings');
$datastore_settings->set('triggering_properties', ['modified']);
$datastore_settings->save();
$this->config('datastore.settings')
->set('triggering_properties', ['modified'])
->save();

// Test posting a dataset to the metastore.
$data = $this->getData($this->downloadUrl);
/** @var \Drupal\metastore\MetastoreService $metastore */
$metastore = \Drupal::service('dkan.metastore.service');
$metastore = $this->container->get('dkan.metastore.service');
$dataset = $metastore->getValidMetadataFactory()->get($data, 'dataset');
$metastore->post('dataset', $dataset);

Expand All @@ -66,16 +65,4 @@ public function test() {
$this->assertEquals(1, $rev);
}

/**
*
*/
public function tearDown(): void {
parent::tearDown();
$this->removeAllNodes();
$this->removeAllMappedFiles();
$this->removeAllFileFetchingJobs();
$this->flushQueues();
$this->removeFiles();
$this->removeDatastoreTables();
}
}