1 simpletest_example.test public SimpleTestUnitTestExampleTestCase::testSimpleTestUnitTestExampleFunction()

Test simpletest_example_empty_mysql_date().

Note that no environment is provided; we're just testing the correct behavior of a function when passed specific arguments.


modules/examples/simpletest_example/simpletest_example.test, line 143
An example of simpletest tests to accompany the tutorial at http://DOCUMENTATION_PENDING/node/890654.


Although most core test cases are based on BackdropWebTestCase and are functional tests (exercising the web UI) we also have BackdropUnitTestCase, which executes much faster because a Backdrop install does not have to be one. No environment is…


public function testSimpleTestUnitTestExampleFunction() {
  $result = simpletest_example_empty_mysql_date(NULL);
  // Note that test assertion messages should never be translated, so
  // this string is not wrapped in t().
  $message = 'A NULL value should return TRUE.';
  $this->assertTrue($result, $message);

  $result = simpletest_example_empty_mysql_date('');
  $message = 'An empty string should return TRUE.';
  $this->assertTrue($result, $message);

  $result = simpletest_example_empty_mysql_date('0000-00-00');
  $message = 'An "empty" MySQL DATE should return TRUE.';
  $this->assertTrue($result, $message);

  $result = simpletest_example_empty_mysql_date(date('Y-m-d'));
  $message = 'A valid date should return FALSE.';
  $this->assertFalse($result, $message);