-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Harvest status page should reflect all registered harvests (#4048)
- Loading branch information
Showing
5 changed files
with
135 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
modules/harvest/tests/src/Kernel/DashboardControllerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace Drupal\Tests\harvest\Kernel; | ||
|
||
use Drupal\harvest\DashboardController; | ||
use Drupal\KernelTests\KernelTestBase; | ||
use Harvest\ETL\Extract\DataJson; | ||
use Harvest\ETL\Load\Simple; | ||
|
||
/** | ||
* @covers \Drupal\harvest\DashboardController | ||
* @coversDefaultClass \Drupal\harvest\DashboardController | ||
* | ||
* @group dkan | ||
* @group harvest | ||
* @group kernel | ||
*/ | ||
class DashboardControllerTest extends KernelTestBase { | ||
|
||
protected static $modules = [ | ||
'common', | ||
'harvest', | ||
'metastore', | ||
]; | ||
|
||
public function testRegisteredPlan() { | ||
/** @var \Drupal\harvest\HarvestService $harvest_service */ | ||
$harvest_service = $this->container->get('dkan.harvest.service'); | ||
|
||
$dashboard_controller = DashboardController::create($this->container); | ||
|
||
// There are no registered harvests, so there should be zero rows. We also | ||
// verify the empty table value. | ||
$render_array = $dashboard_controller->harvests(); | ||
$this->assertCount(0, $render_array['#rows'] ?? NULL); | ||
$this->assertEquals('No harvests found', $render_array['#empty'] ?? NULL); | ||
|
||
// Register a harvest plan but don't run it... | ||
$plan_identifier = 'test_plan'; | ||
$plan = (object) [ | ||
'identifier' => $plan_identifier, | ||
'extract' => (object) [ | ||
'type' => DataJson::class, | ||
'uri' => 'file://' . __DIR__ . '/../../files/data.json', | ||
], | ||
'transforms' => [], | ||
'load' => (object) [ | ||
'type' => Simple::class, | ||
], | ||
]; | ||
$this->assertNotNull($harvest_service->registerHarvest($plan)); | ||
|
||
// Revisit the dashboard. It should show the registered harvest. | ||
$render_array = $dashboard_controller->harvests(); | ||
$this->assertCount(1, $render_array['#rows'] ?? NULL); | ||
$this->assertNotNull($row = $render_array['#rows'][0] ?? NULL); | ||
/** @var \Drupal\Core\Link $link */ | ||
$this->assertNotNull($link = $row['harvest_link'] ?? NULL); | ||
$this->assertEquals($plan_identifier, $link->getText()); | ||
// Harvest was registered, but never run. | ||
$this->assertEquals('REGISTERED', $row['extract_status']['data'] ?? NULL); | ||
$this->assertEquals('never', $row['last_run'] ?? NULL); | ||
$this->assertEquals('unknown', $row['dataset_count'] ?? NULL); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters