function ConnectionTest::testDestroy

Same name in other branches
  1. 9 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 216

Class

ConnectionTest
Tests the Connection class.

Namespace

Drupal\Tests\Core\Database

Code

public function testDestroy() {
    $mock_pdo = $this->createMock('Drupal\\Tests\\Core\\Database\\Stub\\StubPDO');
    // Mocking StubConnection gives us access to the $schema attribute.
    $connection = new StubConnection($mock_pdo, [
        '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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.