Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mstenta committed Jun 11, 2024
1 parent c019eab commit a4bdebd
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 1 deletion.
1 change: 1 addition & 0 deletions farm_crop_plan.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ dependencies:
- farm_migrate
- farm_plant
- farm_season
- farm_seeding
- plan
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: farmOS Crop Plan Test
description: Support module for CSV Crop Plan testing.
type: module
package: Testing
core_version_requirement: ^10
dependencies:
- farm:farm_crop_plan
2 changes: 1 addition & 1 deletion tests/src/Functional/CropPlanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testCropPlanExport() {
$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');
$expected = file_get_contents(__DIR__ . '/../../artifacts/export-crop-plan.csv');
$this->assertEquals($expected, $output);
}

Expand Down
91 changes: 91 additions & 0 deletions tests/src/Kernel/CropPlanImportTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

namespace Drupal\Tests\farm_crop_plan\Kernel;

use Drupal\Tests\farm_crop_plan\Traits\MockCropPlanEntitiesTrait;
use Drupal\Tests\farm_import_csv\Kernel\CsvImportTestBase;

/**
* Tests for farmOS crop plan importer.
*
* @group farm_crop_plan
*/
class CropPlanImportTest extends CsvImportTestBase {

use MockCropPlanEntitiesTrait;

/**
* {@inheritdoc}
*/
protected static $modules = [
// 'asset',
// 'entity',
// 'entity_reference_validators',
'farm_crop_plan',
// 'farm_entity',
'farm_id_tag',
// 'farm_import_csv',
// 'farm_field',
'farm_land',
'farm_location',
'farm_log',
// 'farm_log_asset',
'farm_map',
// 'farm_migrate',
'farm_plant',
'farm_plant_type',
'farm_seeding',
'farm_transplanting',
'field',
// 'file',
'geofield',
// 'image',
// 'log',
// 'migrate_plus',
// 'migrate_source_csv',
// 'options',
'plan',
// 'quantity',
// 'state_machine',
// 'taxonomy',
// 'text',
// 'user',
];

/**
* {@inheritdoc}
*/
public function setUp(): void {
parent::setUp();
$this->installEntitySchema('plan');
$this->installEntitySchema('plan_record');
$this->installConfig([
'farm_crop_plan',
'farm_land',
'farm_plant',
'farm_plant_type',
'farm_seeding',
'farm_transplanting',
]);

// Set the private:// filesystem to use this module's artifacts directory.
$this->setSetting('file_private_path', \Drupal::service('extension.list.module')->getPath('farm_crop_plan_test') . '/artifacts');
}

/**
* Test crop plan import.
*/
public function testCropPlanImport() {
$this->importCsv('import-crop-plan.csv', 'crop_plan_records');
$d=1;
}

/**
* Test crop plan update.
*/
public function testCropPlanUpdate() {
$this->importCsv('import-crop-plan.csv', 'crop_plan_records');
$d=1;
}

}
3 changes: 3 additions & 0 deletions tests/src/Kernel/CropPlanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class CropPlanTest extends MigrateTestBase {
'entity_reference_validators',
'farm_crop_plan',
'farm_entity',
'farm_id_tag',
'farm_import_csv',
'farm_field',
'farm_land',
'farm_location',
Expand All @@ -44,6 +46,7 @@ class CropPlanTest extends MigrateTestBase {
'migrate_source_csv',
'options',
'plan',
'quantity',
'state_machine',
'taxonomy',
'text',
Expand Down

0 comments on commit a4bdebd

Please sign in to comment.