Hi I am working on a Drupal 8 version of entityqueue. Attached you can find a zip already. It is a work in progress. I have a branch ready to commit as well. It it possible that you make me co-maintainer than i can push the branch.

Comments

ghuygens created an issue. See original summary.

wouters_f’s picture

StatusFileSize
new14.25 KB

Added in a (very basic) kernel test
Which we don't seem to get working correctly...

<?php

namespace Drupal\Tests\entityqueue_scheduler\Kernel;


use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\Tests\field\Kernel\FieldKernelTestBase;


/**
 * Unit tests for entityqueue_scheduler functions.
 *
 * @group entityqueue_scheduler
 */
class entityqueue_schedulerKernelTest extends FieldKernelTestBase {

  public static $modules = array(
    'field',
    'user',
    'entityqueue',
    'entityqueue_scheduler',
    'node',
    'datetime',
    'options',
    'system',
    'entity_test',
    'file'
  );

  public function setUp() {
    parent::setUp();

    // installSchema works
    $this->installSchema('entityqueue_scheduler', array('eq_schedule'));

    FieldStorageConfig::create(array(
      'entity_type' => 'entity_test',
      'field_name'  => 'field_eq_test',
      'type'        => 'eqs_field',
    ))->save();
    FieldConfig::create([
      'entity_type' => 'entity_test',
      'field_name'  => 'field_eq_test',
      'bundle'      => 'entity_test',
    ])->save();
  }

  /**
   * Tests to add node.
   */

  public function testCreateNode() {

    // if succeeded not shown
    $entity = EntityTest::create();
    $this->assertFalse($entity->field_eq_test[0] instanceof FieldItemInterface, 'field_eq_test - Field implements interface. FALSE');

// @TODO Dit deel werkt niet -------------------------------
    $entity->field_eq_test->startdate = '2014-01-01T20:00:00Z';;
    $entity->field_eq_test->enddate = strtotime("now + 10");
    $entity->name->value = $this->randomMachineName();
    $entity->save();
// -------------------------------------

    $entity = EntityTest::load($entity->id());
    $this->assertTrue($entity->field_eq_test instanceof FieldItemListInterface, 'field_eq_test - Field implements interface. TRUE');
    $this->assertTrue($entity->field_eq_test[0] instanceof FieldItemInterface, 'field_eq_test - Field item implements interface.');
    $this->assertNull(!$entity->field_eq_test->startdate);
    $this->assertEqual($entity->field_eq_test->startdate, '2014-01-01T20:00:00Z');
  }
}

pfrenssen’s picture

It looks like you cannot retrieve the value of the field_eq_test field because its select property is not set. Only the startdate and enddate are set, but it is the select property which is used to determine if the value is set.

From EntityqueueSchedulerFieldType:

  public function isEmpty() {
    $value = $this->get('select')->getValue();
    // $value = null;.
    return $value == "empty" || $value === NULL || $value === '';
  }

When an entity is saved, first its values are filtered by FieldItemList::filterEmptyItems() which calls isEmpty() on all field items.

So in order for the test to succeed you should either populate the select property, or change the isEmpty() method to check for the startdate or enddate.

wouters_f’s picture

Since we created this as a field and this will likely be hard to migrate from the drupal 7 version to a unexisting field you can find the port under https://www.drupal.org/project/eqsf
In this project Glen allows a field to be added to entities where you can put them in the queue (planned).

chris matthews’s picture

Assigned: ghuygens » Unassigned
Status: Active » Closed (outdated)

Closing as "outdated" as the Entityqueue Scheduler Field module appears to be the D8 heir to the D7 Entityqueue Scheduler module.