EmitTest.php in Radioactivity 4.0.x
File
tests/src/FunctionalJavascript/EmitTest.php
View source
<?php
namespace Drupal\Tests\radioactivity\FunctionalJavascript;
use Drupal\Tests\Traits\Core\CronRunTrait;
class EmitTest extends RadioactivityFunctionalJavascriptTestBase {
use CronRunTrait;
protected $fieldName;
public function testCount() {
$this->fieldName = 'field_count_energy';
$this
->setEntityType('entity_test');
$this
->setEntityBundle('entity_test');
$this
->addCountEnergyField($this->fieldName);
$this
->createEnergyFormDisplay($this->fieldName);
$this
->createEmitterViewDisplay($this->fieldName, 1, 'raw');
$entity = $this
->createContent();
$this
->assetIncidentCount(0);
$this
->drupalGet($entity
->toUrl());
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assetIncidentCount(1);
$this
->assertPageEnergyValue($this->fieldName, 0);
$this
->assertFieldEnergyValue($entity, $this->fieldName, 0);
$this
->cronRun();
$entity = \Drupal::entityTypeManager()
->getStorage($this->entityType)
->load($entity
->id());
$this
->assetIncidentCount(0);
$this
->assertFieldEnergyValue($entity, $this->fieldName, 1);
$this
->drupalGet($entity
->toUrl());
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assertPageEnergyValue($this->fieldName, 1);
}
public function testUnpublished() {
$this->fieldName = 'field_count_energy';
$this
->setEntityType('entity_test_revpub');
$this
->setEntityBundle('entity_test_revpub');
$this
->addCountEnergyField($this->fieldName);
$this
->createEnergyFormDisplay($this->fieldName);
$this
->createEmitterViewDisplay($this->fieldName, 1, 'raw');
$entity = $this
->createContent();
$this
->assetIncidentCount(0);
$entity
->setUnpublished();
$entity
->save();
$this
->drupalGet('/entity_test_rev/manage/' . $entity
->id());
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assetIncidentCount(0);
}
}
Classes
Name |
Description |
EmitTest |
Testing the energy emission of the radioactivity field. |