You are here

public function ConnectionTest::testDestroy in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Database/ConnectionTest.php \Drupal\Tests\Core\Database\ConnectionTest::testDestroy()

Test Connection::destroy().

File

core/tests/Drupal/Tests/Core/Database/ConnectionTest.php, line 224
Contains \Drupal\Tests\Core\Database\ConnectionTest.

Class

ConnectionTest
Tests the Connection class.

Namespace

Drupal\Tests\Core\Database

Code

public function testDestroy() {
  $mock_pdo = $this
    ->getMock('Drupal\\Tests\\Core\\Database\\Stub\\StubPDO');

  // Mocking StubConnection gives us access to the $schema attribute.
  $connection = $this
    ->getMock('Drupal\\Tests\\Core\\Database\\Stub\\StubConnection', NULL, array(
    $mock_pdo,
    array(
      'namespace' => 'Drupal\\Tests\\Core\\Database\\Stub\\Driver',
    ),
  ));

  // Generate a schema object in order to verify that we've NULLed it later.
  $this
    ->assertInstanceOf('Drupal\\Tests\\Core\\Database\\Stub\\Driver\\Schema', $connection
    ->schema());
  $connection
    ->destroy();
  $this
    ->assertAttributeEquals(NULL, 'schema', $connection);
}