You are here

class Drupal7Test in Realistic Dummy Content 8.2

Same name and namespace in other branches
  1. 7.2 api/src/test/Framework/Drupal7Test.php \Drupal\realistic_dummy_content_api\Framework\Drupal7Test

Tests for \Drupal\realistic_dummy_content_api\Framework\Drupal7.

@group realistic_dummy_content

Hierarchy

  • class \Drupal\realistic_dummy_content_api\Framework\Drupal7Test extends \Drupal\realistic_dummy_content_api\Framework\PHPUnit_Framework_TestCase

Expanded class hierarchy of Drupal7Test

File

api/src/test/Framework/Drupal7Test.php, line 24

Namespace

Drupal\realistic_dummy_content_api\Framework
View source
class Drupal7Test extends \PHPUnit_Framework_TestCase {

  /**
   * Tests Drupal7::entityIsDummy().
   *
   * @dataProvider providerTestEntityIsDummy
   */
  public function testEntityIsDummy($account, $type, $expected) {
    $framework = $this
      ->getMockBuilder('Drupal\\realistic_dummy_content_api\\Framework\\Drupal7')
      ->setMethods(array(
      'drupalSubstr',
    ))
      ->getMock();
    $framework
      ->method('drupalSubstr')
      ->will($this
      ->returnCallback('substr'));
    $result = $framework
      ->entityIsDummy($account, $type);
    $this
      ->assertTrue($result === $expected, 'Account ' . serialize($account) . ' returned ' . serialize($result) . ' (expected result is ' . $expected . ')');
  }

  /**
   * Data provider for $this->testEntityIsDummy().
   */
  public function providerTestEntityIsDummy() {
    return array(
      array(
        (object) array(
          'mail' => 'whatever@example.com.invalid',
        ),
        'user',
        TRUE,
      ),
      array(
        (object) array(
          'mail' => 'whatever@example.com',
          'devel_generate' => TRUE,
        ),
        'user',
        TRUE,
      ),
      array(
        (object) array(
          'mail' => 'whatever@example.com',
        ),
        'user',
        FALSE,
      ),
      array(
        (object) array(
          'devel_generate' => TRUE,
        ),
        'node',
        TRUE,
      ),
      array(
        (object) array(),
        'node',
        FALSE,
      ),
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Drupal7Test::providerTestEntityIsDummy public function Data provider for $this->testEntityIsDummy().
Drupal7Test::testEntityIsDummy public function Tests Drupal7::entityIsDummy().