class UnitTest in TacJS 8
Simple test to ensure that asserts pass.
@group tacjs
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\tacjs\UnitTest
Expanded class hierarchy of UnitTest
File
- tests/
src/ Unit/ UnitTest.php, line 14
Namespace
Drupal\tacjsView source
class UnitTest extends UnitTestCase {
protected $unit;
protected $fixture;
/**
* Before a test method is run, setUp() is invoked.
* Create new unit object.
*/
public function setUp() {
$this->unit = new TacjsSettings();
$this->fixture = new Unit();
}
/**
* @covers Drupal\tacjs\TacjsSettings::getFields
*/
public function testGetFields() {
$values = [
"purechat" => "purechat",
];
$data = TacjsSettings::SUPPORT;
$result = [
0 => [
"value" => "purechat",
"name" => "Purechat",
],
];
$this
->assertEquals($result, $this->fixture
->getFields($values, $data));
}
/**
* @covers Drupal\tacjs\TacjsSettings::getFields
*/
public function testSerializeValuesForm() {
$values = [
"type_social_networks" => [
"facebook" => "facebook",
],
"submit" => [],
"form_build_id" => "",
"form_token" => "",
"form_id" => "",
"op" => [],
];
$result = [
"type_social_networks" => [
"facebook" => "facebook",
],
];
$result = serialize($result);
$this
->assertEquals($result, $this->unit
->serializeValuesForm($values));
}
/**
* Once test method has finished running, whether it succeeded or failed, tearDown() will be invoked.
* Unset the $unit object.
*/
public function tearDown() {
unset($this->unit);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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. | |
UnitTest:: |
protected | property | ||
UnitTest:: |
protected | property | ||
UnitTest:: |
public | function |
Before a test method is run, setUp() is invoked.
Create new unit object. Overrides UnitTestCase:: |
|
UnitTest:: |
public | function | Once test method has finished running, whether it succeeded or failed, tearDown() will be invoked. Unset the $unit object. | |
UnitTest:: |
public | function | @covers Drupal\tacjs\TacjsSettings::getFields | |
UnitTest:: |
public | function | @covers Drupal\tacjs\TacjsSettings::getFields | |
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. |