class IncidentTest in Radioactivity 8.3
Same name and namespace in other branches
- 4.0.x tests/src/Unit/IncidentTest.php \Drupal\Tests\radioactivity\Unit\IncidentTest
@coversDefaultClass \Drupal\radioactivity\Incident @group radioactivity
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\radioactivity\Unit\IncidentTest
Expanded class hierarchy of IncidentTest
File
- tests/
src/ Unit/ IncidentTest.php, line 13
Namespace
Drupal\Tests\radioactivity\UnitView source
class IncidentTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
// Initiate the Settings singleton used by this test.
new Settings([
'hash_salt' => 'liesjeleerdelotjelopen',
]);
}
/**
* @covers ::getFieldName
* @covers ::getEntityTypeId
* @covers ::getEntityId
* @covers ::getEnergy
*/
public function testGetters() {
$incident = new Incident('field_name', 'entity_type', '99', 5.5, '1234567890');
$this
->assertEquals($incident
->getFieldName(), 'field_name');
$this
->assertEquals($incident
->getEntityTypeId(), 'entity_type');
$this
->assertEquals($incident
->getEntityId(), '99');
$this
->assertEquals($incident
->getEnergy(), 5.5);
}
/**
* @covers ::createFromPostData
*/
public function testCreateFromPostData() {
$incident = Incident::createFromPostData([
'fn' => 'field_name',
'et' => 'entity_type',
'id' => '99',
'e' => 5.5,
'h' => '1234567890',
]);
$this
->assertEquals($incident
->getFieldName(), 'field_name');
$this
->assertEquals($incident
->getEntityTypeId(), 'entity_type');
$this
->assertEquals($incident
->getEntityId(), '99');
$this
->assertEquals($incident
->getEnergy(), 5.5);
}
/**
* @covers ::toJson
*/
public function testJson() {
$incident = new Incident('field_name', 'entity_type', '99', 5.5, '1234567890');
$this
->assertEquals($incident
->toJson(), '{"fn":"field_name","et":"entity_type","id":"99","e":5.5,"h":"5aa2ff01ac75da55751051a55021092768d079c5"}');
}
/**
* @covers ::isValid
*/
public function testValidHash() {
$incident = new Incident('field_name', 'entity_type', '99', 5.5, '1234567890');
$this
->assertFalse($incident
->isValid());
$incident = new Incident('field_name', 'entity_type', '99', 5.5, '5aa2ff01ac75da55751051a55021092768d079c5');
$this
->assertTrue($incident
->isValid());
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
IncidentTest:: |
protected | function |
Overrides UnitTestCase:: |
|
IncidentTest:: |
public | function | @covers ::createFromPostData | |
IncidentTest:: |
public | function | @covers ::getFieldName @covers ::getEntityTypeId @covers ::getEntityId @covers ::getEnergy | |
IncidentTest:: |
public | function | @covers ::toJson | |
IncidentTest:: |
public | function | @covers ::isValid | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |