class OfficeHoursDatetimeUnitTest in Office Hours 8
Tests the new entity API for the office_hours field type.
@group office_hours
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\office_hours\Unit\OfficeHoursDatetimeUnitTest
Expanded class hierarchy of OfficeHoursDatetimeUnitTest
See also
https://www.drupal.org/docs/automated-testing/phpunit-in-drupal
https://www.drupal.org/docs/testing/phpunit-in-drupal/running-phpunit-te...
File
- tests/
src/ Unit/ OfficeHoursDatetimeUnitTest.php, line 18
Namespace
Drupal\Tests\office_hours\UnitView source
class OfficeHoursDatetimeUnitTest extends UnitTestCase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'office_hours',
];
/**
* Tests using entity fields of the datetime field type.
*/
public function testDateTimeIsEmpty() {
$this::assertTrue(OfficeHoursDatetime::isEmpty(NULL), 'Test Datetime NULL is empty.');
$this::assertNotTrue(OfficeHoursDatetime::isEmpty(-1), 'Test 24:00 is not empty.');
$this::assertTrue(OfficeHoursDatetime::isEmpty(''), 'Test empty slot is empty.');
$this::assertTrue(OfficeHoursDatetime::isEmpty([
'time' => '',
]), "Test empty 'time' value is empty.");
$this::assertNotTrue(OfficeHoursDatetime::isEmpty([
'time' => 'a time',
]), "Test not-empty 'time' value is not empty.");
$this::assertTrue(OfficeHoursDatetime::isEmpty([
'day' => '2',
'starthours' => '',
'endhours' => '',
'comment' => '',
]), "Test complete array - only 'day' is set.");
$this::assertNotTrue(OfficeHoursDatetime::isEmpty([
'day' => '2',
'starthours' => '',
'endhours' => '',
'comment' => 'There is a comment, so not empty.',
]), "Test complete array - only 'day' and 'comment' is set.");
$this::assertTrue(OfficeHoursDatetime::isEmpty([
'day' => NULL,
'starthours' => NULL,
'endhours' => NULL,
'comment' => NULL,
]), "Test complete array with 4 NULL (from devel_generate).");
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OfficeHoursDatetimeUnitTest:: |
protected static | property | Modules to enable. | |
OfficeHoursDatetimeUnitTest:: |
public | function | Tests using entity fields of the datetime field type. | |
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. | |
UnitTestCase:: |
protected | function | 340 |