|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Copyright 2015-2017 DataStax, Inc. |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +namespace Cassandra; |
| 20 | + |
| 21 | +/** |
| 22 | + * Session integration tests |
| 23 | + */ |
| 24 | +class SessionIntegrationTest extends BasicIntegrationTest { |
| 25 | + |
| 26 | + /** |
| 27 | + * Ensure the driver does not crash connecting to a non-existent server |
| 28 | + * |
| 29 | + * This test will ensure that when attempting to connect to a non-existent |
| 30 | + * server instance asynchronously, the driver will not crash. |
| 31 | + * |
| 32 | + * @jira_ticket PHP-144 |
| 33 | + * @test_category connection |
| 34 | + * @since 1.3.0 |
| 35 | + * @excpected_result Driver will not connect and continue to function |
| 36 | + */ |
| 37 | + public function testAsyncConnectionNoHost() { |
| 38 | + // Stop the server instance (no hosts are required) |
| 39 | + $this->ccm->stop(); |
| 40 | + |
| 41 | + // Create and close sessions asynchronously |
| 42 | + $connect_future = $this->cluster->connectAsync(); |
| 43 | + try { |
| 44 | + $connect_future->get(); |
| 45 | + $this->fail("Connection established"); |
| 46 | + } catch (Exception\RuntimeException $re) { |
| 47 | + $this->assertTrue(true); |
| 48 | + } |
| 49 | + |
| 50 | + // Restart the server instance |
| 51 | + $this->ccm->start(); |
| 52 | + |
| 53 | + } |
| 54 | +} |
0 commit comments