public static function tearDownAfterClass()
 {
     $cliente = self::$cliente;
     if (!is_null($cliente)) {
         $session = new NashEarlySession(self::$config["authenticationPath"], self::$config['servicePath']);
         $session->logout();
         $session->login(self::$config);
         $service = new ClienteService($session);
         $result = $service->read($cliente->getId());
         if ($result->getStatus() == Result::SUCCESS) {
             $service->delete($result->getModel()->getId());
         }
         $session->logout();
     }
     self::$cliente = null;
 }
 public function testEstadoDoObjetoAposLogout()
 {
     $this->object->login(self::$config);
     $this->assertTrue($this->object->isAuthenticated());
     $this->assertTrue($this->object->logout());
     $this->assertNull($this->object->getUsername());
     $this->assertEquals(ISession::NOT_AUTHENTICATED, $this->object->getResultCode());
 }
<?php

require_once '../bootstrap.php';
$config = (require '../config.php');
$config = $config[$config['running']];
$servicePath = $config['servicePath'];
$authenticationPath = $config['authenticationPath'];
$session = new NashEarlySession($authenticationPath, $servicePath);
$service = new MunicipioService($session);
$empresaService = new EmpresaService($session);
$session->login($config);
$empresas = $empresaService->getEmpresasSelecionaveis(1, 0);
$empresaService->selecionaEmpresa($empresas[0]->getId());
$result = $service->retrieve(10, 0);
//Terceiro parâmentro de filtro opcional
$municipios = $result->getModel()->Data;
echo "\r\nTotal de Registros: {$result->getModel()->Total}\r\n";
echo "Total Apresentado: " . count($result->getModel()->Data) . "\r\n";
print_r($municipios);
$session->logout();
示例#4
0
<?php

require_once '../bootstrap.php';
$config = (require '../config.php');
$config = $config[$config['running']];
$servicePath = $config['servicePath'];
$authenticationPath = $config['authenticationPath'];
$session = new NashEarlySession($authenticationPath, $servicePath);
$service = new ClienteService($session);
$empresaService = new EmpresaService($session);
$session->login($config);
//var_dump($session);
$empresas = $empresaService->getEmpresasSelecionaveis(1, 0);
$empresaService->selecionaEmpresa($empresas[0]->getId());
$cliente = getCliente($session);
$result = $service->create($cliente);
print_r($result->getStatus());
print_r($result->getModel());
function getMunicipio($session1)
{
    $service1 = new MunicipioService($session1);
    $result1 = $service1->retrieve(1, 0);
    $municipio = $result1->getModel()->Data[0];
    return $municipio;
}
function getCliente($session2)
{
    $cliente = new Cliente();
    $cliente->setNomeFantasia("Nome do Cliente");
    $cliente->setRazaoSocial("Nome do Cliente");
    $cliente->setCPFCNPJ("00000000000000");