コード例 #1
0
 public function testServiceCalls()
 {
     //        $debug = self::getProperty('debug');
     //        $debug->setValue($this->clientSocketApi, true);
     //
     //        $consoleOutput = new ConsoleOutput();
     //        $output = self::getProperty('output');
     //        $output->setValue($this->clientSocketApi, $consoleOutput);
     $init = $this->getProperty('init');
     $init->setValue($this->clientSocketApi, true);
     $result = $this->clientSocketApi->getBundleIndex();
     $this->assertFalse($result['result']);
     $result = $this->clientSocketApi->getCatalogIndex();
     $this->assertFalse($result['result']);
     $result = $this->clientSocketApi->getKeyIndex("messages");
     $this->assertFalse($result['result']);
     $result = $this->clientSocketApi->getMessages("messages", "test.key");
     $this->assertFalse($result['result']);
     $result = $this->clientSocketApi->getMessage("messages", "test.key", "en");
     $this->assertFalse($result['result']);
     $result = $this->clientSocketApi->getComment("messages", "test.key");
     $this->assertFalse($result['result']);
     $result = $this->clientSocketApi->putMessage("messages", "test.key", "en", "test");
     $this->assertFalse($result['result']);
     $result = $this->clientSocketApi->updateMessageIfNewest("messages", "test.key", "en", "test", new \DateTime());
     $this->assertFalse($result['result']);
     $result = $this->clientSocketApi->updateCommentIfNewest("messages", "test.key", "test", new \DateTime());
     $this->assertFalse($result['result']);
     $result = $this->clientSocketApi->uploadKeys("messages", array());
     $this->assertFalse($result['result']);
     $result = $this->clientSocketApi->downloadKeys("messages");
     $this->assertFalse($result['result']);
     $result = $this->clientSocketApi->transDocIndex();
     $this->assertFalse($result['result']);
     $result = $this->clientSocketApi->transDocSync("messages", "test.key", "en", "file", "document", new \DateTime());
     $this->assertFalse($result['result']);
     $result = $this->clientSocketApi->register();
     $this->assertFalse($result['result']);
     $shutdown = $this->getMethod('shutdown');
     $result = $shutdown->invoke($this->clientSocketApi);
     $this->assertFalse($result['result']);
     // the shutdown method switches init to false
     $init = $this->getProperty('init');
     $this->assertFalse($init->getValue($this->clientSocketApi));
 }
コード例 #2
0
ファイル: simple.php プロジェクト: jlaso/tradukoj-connector
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use JLaso\TradukojConnector\Model\Loader\ArrayLoader;
use JLaso\TradukojConnector\ClientSocketApi;
use JLaso\TradukojConnector\Socket\Socket;
use JLaso\TradukojConnector\PostClient\PostCurl;
use JLaso\TradukojConnector\Output\ConsoleOutput;
$loader = new ArrayLoader();
$config = $loader->load(array('project_id' => 1, 'key' => 'key', 'secret' => 'secret', 'url' => 'https://localhost/api/'));
$socketClient = new Socket();
$postClient = new PostCurl();
$consoleOutput = new ConsoleOutput();
$clientSocketApi = new ClientSocketApi($config, $socketClient, $postClient, $consoleOutput, true);
// initialize client
$clientSocketApi->init();
// getters
// fetch the list of bundles of the project
$bundles = $clientSocketApi->getBundleIndex();
// get the list of catalogs of the project
$catalogs = $clientSocketApi->getCatalogIndex();
$keys = $clientSocketApi->getKeyIndex($bundles[0]);
$messages = $clientSocketApi->getMessages($bundles[0], $keys[0]);