You are here

class UnitTest in TacJS 8

Simple test to ensure that asserts pass.

@group tacjs

Hierarchy

Expanded class hierarchy of UnitTest

File

tests/src/Unit/UnitTest.php, line 14

Namespace

Drupal\tacjs
View 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

Namesort descending Modifiers Type Description Overrides
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
UnitTest::$fixture protected property
UnitTest::$unit protected property
UnitTest::setUp public function Before a test method is run, setUp() is invoked. Create new unit object. Overrides UnitTestCase::setUp
UnitTest::tearDown public function Once test method has finished running, whether it succeeded or failed, tearDown() will be invoked. Unset the $unit object.
UnitTest::testGetFields public function @covers Drupal\tacjs\TacjsSettings::getFields
UnitTest::testSerializeValuesForm public function @covers Drupal\tacjs\TacjsSettings::getFields
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.