PHP Classes

File: test/ClientTest.php

Recommend this page to a friend!
  Classes of Victor Bolshov  >  Zephir HandlerSocket Client  >  test/ClientTest.php  >  Download  
File: test/ClientTest.php
Role: Unit test script
Content type: text/plain
Description: Test
Class: Zephir HandlerSocket Client
Access MySQL tables as NoSQL with HandlerSocket
Author: By
Last change:
Date: 6 years ago
Size: 1,972 bytes


Class file image Download

namespace Zhandlersocket;

__DIR__ . "/BaseTest.php";

 * Created by PhpStorm.
 * User: vbolshov <>
 * Date: 5-10-15
 * Time: 20:47

class ClientTest extends BaseTest
testGetIndex() {
$client = $this->createClient();
$index1 = $client->getIndex("db", "table", "PRIMARY", ["id", "name"], ["name"]);
$this->assertEquals(1, $client->getIndexCount());

// should be the same instance as index1
$index2 = $client->getIndex("db", "table", "PRIMARY", ["id", "name"], ["name"]);
$this->assertEquals(1, $client->getIndexCount());
$this->assertEquals($index1, $index2);

// definition differs, so it must be a different instance
$index3 = $client->getIndex("db", "table", "PRIMARY", ["id", "name"]);
$this->assertEquals(2, $client->getIndexCount());
$this->assertNotEquals($index3, $index2);

testGetReadConnection() {
$client = $this->createClient();
$rc1 = $client->getReadConnection();
$this->assertInstanceOf(Connection::class, $rc1);

$rc2 = $client->getReadConnection();
$this->assertInstanceOf(Connection::class, $rc2);
$this->assertEquals($rc1, $rc2);

$client = $this->createClient();
$wc = $client->getWriteConnection();
$this->assertInstanceOf(Connection::class, $wc);

$rc3 = $client->getReadConnection();
$this->assertInstanceOf(Connection::class, $rc3);
$this->assertEquals($wc, $rc3);// client already established write connection, it should be reused

testGetWriteConnection() {
$client = $this->createClient();
$wc1 = $client->getWriteConnection();
$this->assertInstanceOf(Connection::class, $wc1);

$wc2 = $client->getWriteConnection();
$this->assertInstanceOf(Connection::class, $wc2);
$this->assertEquals($wc1, $wc2);

For more information send a message to info at phpclasses dot org.