/** * @test */ public function authForWriteTestErrorResponse() { $this->_writeStream->setResponse("1\t125"); $result = $this->_driver->auth(Ext_HandlerSocket_Driver::MODE_WRITE, 'test'); $this->assertEquals("A\t1\ttest", $this->_writeStream->getLastRequest()); $this->assertFalse($result); }
public function getDriver($auth = true) { if (is_null($this->_driver)) { $readOptions = $this->getReadOptions(); $writeOptions = $this->getWriteOptions(); $driverReadOptions = array('host' => $readOptions['host'], 'port' => $readOptions['port']); $driverWriteOptions = array('host' => $writeOptions['host'], 'port' => $writeOptions['port']); $this->_driver = new Ext_HandlerSocket_Driver($driverReadOptions, $driverWriteOptions); if ($auth && isset($readOptions['authKey'])) { $this->_driver->auth(Ext_HandlerSocket_Driver::MODE_READ, $readOptions['authKey'], $readOptions['authType']); } if ($auth && isset($writeOptions['authKey'])) { $this->_driver->auth(Ext_HandlerSocket_Driver::MODE_WRITE, $writeOptions['authKey'], $writeOptions['authType']); } } return $this->_driver; }
/** * @return int * @throws Exception */ public function getWriteIndex() { if (!$this->_writeIndexOpened) { $openIndexResult = $this->_driverInstance->openIndex(Ext_HandlerSocket_Driver::MODE_WRITE, $this->_writeIndexId, $this->_databaseName, $this->_tableName, $this->_indexName, $this->_fields, $this->_options); if (!$openIndexResult) { throw new Exception(); } $this->_writeIndexOpened = true; } return $this->_writeIndexId; }