Esempio n. 1
0
 public function testGetFactotyFromExistentXmlTagMapped()
 {
     try {
         /* @var $factoryManager \NFSe\Service\FactoryManager */
         $factoryManager = \NFSeTest\Bootstrap::getServiceManager()->get('NFSe\\Service\\FactoryManager');
         $entity = $factoryManager->get('AbstractTag');
         $this->assertInstanceOf("\\NFSe\\XML\\Factory\\AbstractFactory", $entity);
     } catch (\NFSe\Exception\InexistentXMLTagException $ex) {
         $this->fail("The 'AbstractTag' tag is not mapped");
     }
 }
Esempio n. 2
0
 public function testPassBuildEntity()
 {
     $xml = file_get_contents(__DIR__ . '/../../../xml-tests/abstractentity.xml');
     $xmlObject = new \SimpleXMLElement($xml);
     $tagName = $xmlObject->getName();
     try {
         /* @var $factoryManager \NFSe\Service\FactoryManager */
         $factoryManager = \NFSeTest\Bootstrap::getServiceManager()->get('NFSe\\Service\\FactoryManager');
         $factory = $factoryManager->get($tagName);
         $entity = $factory->buildEntity($xmlObject);
         $this->assertInstanceOf("\\NFSe\\XML\\Entity\\AbstractEntity", $entity);
     } catch (\NFSe\Exception\InexistentXMLTagException $ex) {
         $this->fail("The '{$tagName}' tag is not mapped");
     }
 }
Esempio n. 3
0
    {
        return static::$serviceManager;
    }
    protected static function initAutoloader()
    {
        $vendorPath = static::findParentPath('vendor');
        if (file_exists($vendorPath . '/autoload.php')) {
            include $vendorPath . '/autoload.php';
        }
        if (!class_exists('Zend\\Loader\\AutoloaderFactory')) {
            throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install`');
        }
        AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array(__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__))));
    }
    protected static function findParentPath($path)
    {
        $dir = __DIR__;
        $previousDir = '.';
        while (!is_dir($dir . '/' . $path)) {
            $dir = dirname($dir);
            if ($previousDir === $dir) {
                return false;
            }
            $previousDir = $dir;
        }
        return $dir . '/' . $path;
    }
}
Bootstrap::init();
Bootstrap::chroot();