-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
258 additions
and
4 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
plan_id,plant_id,plant_type,seeding_date,seeding_location,transplanting_date,transplanting_location,transplant_days,maturity_days,harvest_days | ||
1,1,Corn,2024-06-01T00:00:00+10:00,"Field A",2024-07-01T00:00:00+10:00,"Field A",30,60,7 | ||
1,2,Beans,2024-07-01T00:00:00+10:00,"Field A",2024-08-01T00:00:00+10:00,"Field A",30,60,7 | ||
1,3,Squash,2024-08-01T00:00:00+10:00,"Field A",2024-09-01T00:00:00+10:00,"Field A",30,60,7 |
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,48 @@ | ||
<?php | ||
|
||
namespace Drupal\Tests\farm_crop_plan\Functional; | ||
|
||
use Drupal\Tests\farm_crop_plan\Traits\MockCropPlanEntitiesTrait; | ||
use Drupal\Tests\farm_test\Functional\FarmBrowserTestBase; | ||
|
||
/** | ||
* Tests for farmOS crop plan. | ||
* | ||
* @group farm_crop_plan | ||
*/ | ||
class CropPlanTest extends FarmBrowserTestBase { | ||
|
||
use MockCropPlanEntitiesTrait; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected static $modules = [ | ||
'farm_crop_plan', | ||
'farm_land', | ||
'farm_seeding', | ||
'farm_transplanting', | ||
]; | ||
|
||
/** | ||
* Test crop plan export. | ||
*/ | ||
public function testCropPlanExport() { | ||
|
||
// Create mock plan entities. | ||
$this->createMockPlanEntities(); | ||
|
||
// Create and login a test user with access to view crop plans and logs. | ||
$user = $this->createUser(['view any crop plan', 'view any log']); | ||
$this->drupalLogin($user); | ||
|
||
// Test that the plan export contains expected headers and content. | ||
$output = $this->drupalGet('plan/1/export'); | ||
$this->assertSession()->statusCodeEquals(200); | ||
$this->assertSession()->responseHeaderContains('Content-Type', 'application/csv'); | ||
$this->assertSession()->responseHeaderContains('Content-Disposition', 'attachment; filename="crop-plan-1.csv'); | ||
$expected = file_get_contents(__DIR__ . '/../../files/export-crop-plan.csv'); | ||
$this->assertEquals($expected, $output); | ||
} | ||
|
||
} |