First step for the [meta] Jobless / continuous translators.

Add a new type field to the job entity type, list_string with allowed values, the allowed values being normal or continuous (as constants on JobInterface). Default to normal. This will also need an update function to add the field, we already have committed examples for this. The existing view needs a new condition and only show normal jobs. Nothing should visibly change yet for users.

Test coverage: Extend existing job crud tests, make sure that jobs by default are normal but can be created as continuous. Test that continuous jobs are not shown in the job overview.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sanja_m created an issue. See original summary.

sanja_m’s picture

Assigned: Unassigned » sanja_m

@MarinkoIg and I started to work on this.

sanja_m’s picture

Status: Active » Needs review
FileSize
6.57 KB

Added a new type field to the job entity type with test coverage.

sanja_m’s picture

FileSize
6.57 KB
512 bytes

Updated views.view.tmgmt_job_overview.yml (exported properly).

Berdir’s picture

Status: Needs review » Needs work
  1. +++ b/src/Entity/Job.php
    @@ -190,6 +197,16 @@ class Job extends ContentEntityBase implements EntityOwnerInterface, JobInterfac
       /**
    +   * Returns the job type.
    +   *
    +   * @return string
    +   *   The job type.
    +   */
    +  public function getJobType() {
    

    should be added to JobInterface too and documented there instead.

  2. +++ b/src/Tests/TMGMTUiTest.php
    @@ -1138,4 +1138,13 @@ class TMGMTUiTest extends TMGMTTestBase {
    +  /**
    +   * Test that continuous jobs are not shown in the job overview.
    +   */
    +  public function testJobOverview() {
    +    $job = $this->createJob('en', 'de', 0, ['job_type' => 'continuous']);
    +    $this->drupalGet('admin/tmgmt/jobs');
    +    $this->assertText('No jobs available.', 'Continuous job is not displayed on job overview page.');
    

    the UI test is already very slow, I think we should just make this part of an existing test method.

    Then you will have to do an assertNoText() instead.

sanja_m’s picture

Status: Needs work » Needs review
FileSize
7.01 KB
2.1 KB

Fixed bugs from #5.

Berdir’s picture

Status: Needs review » Needs work

Missed this before, sorry:

  1. +++ b/src/Entity/Job.php
    @@ -137,6 +137,13 @@ class Job extends ContentEntityBase implements EntityOwnerInterface, JobInterfac
    +      ->setSetting('allowed_values', [Job::TYPE_NORMAL, Job::TYPE_CONTINUOUS])
    +      ->setDefaultValue(Job::TYPE_NORMAL);
    

    Use static::... here instead of Job::

  2. +++ b/src/Tests/CrudTest.php
    @@ -59,6 +59,11 @@ class CrudTest extends TMGMTKernelTestBase {
     
    +    $continuous_job = $this->createJob('en', 'de', 0, ['job_type' => 'continuous']);
    +
    +    $this->assertEqual('normal', $job->getJobType());
    +    $this->assertEqual('continuous', $continuous_job->getJobType());
    

    Lets also use the constants here

sanja_m’s picture

Status: Needs work » Needs review
FileSize
7.04 KB
1.43 KB

Fixed bugs from #7 too.

Berdir’s picture

Status: Needs review » Fixed
+++ b/tmgmt.install
@@ -40,3 +41,17 @@ function tmgmt_update_8002() {
+ * Add type field to Job entity.
+ */
+function tmgmt_update_8101() {

Changed this to 8003 (should be an incremental number, we'll switch to 810x after a stable release I think)

Committed, thanks.

  • Berdir committed e1551c4 on authored by sanja_m
    Issue #2664486 by sanja_m: Add a new type field to the job entity type
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.