You are here

public function DrupalComponentTest::testAssertNoCoreUseage in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Component/DrupalComponentTest.php \Drupal\Tests\Component\DrupalComponentTest::testAssertNoCoreUseage()

@covers \Drupal\Tests\Component\DrupalComponentTest::assertNoCoreUsage @dataProvider providerAssertNoCoreUseage

File

core/tests/Drupal/Tests/Component/DrupalComponentTest.php, line 114
Contains \Drupal\Tests\Component\DrupalComponentTest.

Class

DrupalComponentTest
General tests for \Drupal\Component that can't go anywhere else.

Namespace

Drupal\Tests\Component

Code

public function testAssertNoCoreUseage($expected_pass, $file_data) {

  // Set up a virtual file to read.
  $vfs_root = vfsStream::setup('root');
  vfsStream::newFile('Test.php')
    ->at($vfs_root)
    ->setContent($file_data);
  $file_uri = vfsStream::url('root/Test.php');
  try {
    $pass = true;
    $this
      ->assertNoCoreUsage($file_uri);
  } catch (\PHPUnit_Framework_AssertionFailedError $e) {
    $pass = false;
  }
  $this
    ->assertEquals($expected_pass, $pass, $expected_pass ? 'Test caused a false positive' : 'Test failed to detect Core usage');
}