Esempio n. 1
0
 protected function log(\Exception $e, $contextInfo = NULL)
 {
     if ($e instanceof \ErrorException) {
         $errorType = self::$errors[$e->getSeverity()];
     } else {
         $errorType = Code::getClass($e);
     }
     // wir müssen hier den error selbst loggen, da php nichts mehr macht (die faule banane)
     $php = NULL;
     $php .= 'PHP ' . $errorType . ': ' . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() . "\n";
     $php .= $errorType . ': ' . \Psc\Exception::getExceptionText($e, 'text') . "\n";
     error_log($php, 0);
     /* Debug-Mail */
     $debug = NULL;
     $debug .= '[' . date('d.M.Y H:i:s') . "] ";
     $debug .= $errorType . ': ' . \Psc\Exception::getExceptionText($e, 'text') . "\n";
     if ($e instanceof \Psc\Code\ErrorException) {
         $debug .= "\n" . $e->contextDump;
     }
     if (isset($contextInfo)) {
         $debug .= "\nContextInfo: \n" . $contextInfo;
     }
     if (isset($this->recipient) && !PSC::inTests()) {
         if ($ret = @mail($this->recipient, '[Psc-ErrorHandler] [' . $e->getCode() . '] ' . $e->getMessage(), $debug, 'From: www@' . PSC::getEnvironment()->getHostName() . "\r\n" . 'Content-Type: text/plain; charset=UTF-8' . "\r\n") === FALSE) {
             error_log('[\\Psc\\Code\\ErrorHandler.php:' . __LINE__ . '] Die Fehlerinformationen konnten nicht an den lokalen Mailer übergeben werden.', 0);
         }
     }
 }
Esempio n. 2
0
 public function __construct(Project $project, $inTests = FALSE)
 {
     parent::__construct($project);
     $this->entitiesNamespace = Config::get('doctrine.entities.namespace') ?: $this->project->getNamespace() . '\\Entities';
     $this->manager = PSC::getEventManager();
     $this->connectionName = $inTests ? 'tests' : 'default';
 }
Esempio n. 3
0
 public function __construct(GClass $class, Dir $testsDir = NULL)
 {
     $this->setLogger(new \Psc\System\BufferLogger());
     $this->class = $class;
     $this->dir = $testsDir ?: PSC::getProject()->dir('tests');
     $this->testClass = new GClass('\\Psc\\Code\\Test\\Base');
 }
Esempio n. 4
0
 /**
  * Erstellt "from" für eine Message
  *
  * Der $sender hat ein Default von Config[mail.from]
  * wenn das nicht gestzt ist, wird www@host genommen
  */
 public static function from($sender = NULL)
 {
     if (!isset($sender) && ($sender = Config::get('mail.from')) == NULL) {
         $sender = 'www@' . PSC::getEnvironment()->getHostName();
     }
     return self::recipient($sender);
 }
Esempio n. 5
0
 public function testBuilderCreatesPhar()
 {
     return;
     $coreBuilder = new CoreBuilder(nativePSC::getProject()->getClassPath()->up());
     $coreBuilder->compile($this->out);
     $this->out->exists();
 }
Esempio n. 6
0
 /**
  * @deprecated
  * @cc-ignore
  */
 public function getClass()
 {
     if (PSC::getProject()->isDevelopment()) {
         throw new \Psc\DeprecatedException('getClass ist deprecated. Bitte \\Psc\\Code\\Code::getClass($this) benutzen');
     }
     return get_class($this);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $file = $input->getArgument('file');
     $compile = (bool) $input->getOption('compile');
     if ($file == '') {
         $output->writeln('Datei nicht angegeben');
         return;
     }
     $file = new File($file);
     /* Performance: kein file_exists() */
     //if (!$file->exists()) {
     //  $output->writeln('Datei existiert nicht.');
     //  return;
     //}
     /* Der Source Path vom CMS */
     $cp = PSC::getProjectsFactory()->getProject('psc-cms')->getClassPath();
     //$output->writeln($file->getDirectory().' subDirOf ');
     //$output->writeln((string) $cp);
     /* Die Datei ist für uns (erstmal) nur interessant, wenn Sie im PSC-CMS Verzeichnis liegt
           Sie ist damit also eine SRC Datei und triggered das compilieren des Phars
        */
     if ($file->getDirectory()->isSubdirectoryOf($cp) || $file->getDirectory()->equals($cp)) {
         PSC::getEventManager()->dispatchEvent('Psc.SourceFileChanged', (object) array('file' => $file, 'compile' => $compile), $this);
         if ($compile) {
             $output->writeln('SourceDatei in psc-cms ' . $file->getName() . ' wurde compiled.');
         } else {
             $output->writeln('SourceDatei in psc-cms ' . $file->getName() . ' wurde als geändert markiert.');
         }
     } else {
         $output->writeln('SourceDatei ' . $file . ' wurde nicht markiert.');
     }
 }
Esempio n. 8
0
 public function __construct($method, $url, Configuration $hostConfig, Project $project = NULL)
 {
     $this->url = $url;
     $this->method = $method;
     $this->project = $project ?: \Psc\PSC::getProject();
     $this->hostConfig = $hostConfig;
 }
Esempio n. 9
0
 /**
  * Indicates if the unit/acceptance tests are run
  * 
  * this is NOT a flag to circumvent tests or behaviour. this is a flag to use the test-datbase for unit-tests
  * @return bool
  */
 public function inTests()
 {
     if (!isset($this->inTests)) {
         $this->inTests = PSC::isTravis() || PSC::isPHPUnit();
     }
     return $this->inTests;
 }
Esempio n. 10
0
 /**
  * Fügt ein TabsContentItem (nur V2) den Tabs hinzu
  *
  * der Content wird per Ajax geladen mit der URL die das TabsContentItem angibt
  */
 public function addItem(TabsContentItem $item)
 {
     if ($item instanceof \Psc\Doctrine\Entity && \Psc\PSC::getProject()->isDevelopment()) {
         throw new \Psc\DeprecatedException('Entities übergeben ist deprecated. Psc\\CMS\\Item\\Adapter benutzen.');
     }
     return $this->add($item->getTabsLabel(TabsContentItem::LABEL_TAB), NULL, $item->getTabsURL(), HTML::string2id(implode('-', $item->getTabsId())));
 }
Esempio n. 11
0
 public function setUp()
 {
     $this->debugOutDir = PSC::get(PSC::PATH_TESTDATA)->sub('webCompOut');
     if (!$this->debugOutDir->exists()) {
         $this->debugOutDir->make('-p');
     }
 }
Esempio n. 12
0
 public function __construct($fileName, array $vars = array(), $tabLabel = NULL, Dir $root = NULL)
 {
     $this->directory = $root ?: PSC::getProject()->dir('cms-tpl');
     $this->setFileName($fileName);
     $this->vars = $vars;
     $this->tabLabel = $tabLabel ?: $this->file->getName(File::WITHOUT_EXTENSION);
 }
Esempio n. 13
0
 public function testConstruct_DPI_Constructor()
 {
     $module = new Module(\Psc\PSC::getProject());
     $em = $this->doublesManager->createEntityManagerMock();
     $package = new DCPackage($module, $em);
     $this->assertSame($em, $package->getEntityManager());
     $this->assertSame($module, $package->getModule());
 }
Esempio n. 14
0
 public function setUp()
 {
     $this->someBody = array('format' => 'xlsx', 'soundExport' => true, 'label' => array('autoComplete' => 'aclabel with spaces', 'remove' => 'remove it'));
     if (\Psc\PSC::isTravis()) {
         $this->markTestSkipped('Kein Webserver bei Travis');
     }
     parent::setUp();
 }
Esempio n. 15
0
 /**
  * @param string $name der Name des JSManagers
  */
 public function __construct($name, Project $project = NULL)
 {
     parent::__construct($name);
     $this->project = $project ?: PSC::getProject();
     if ($this->name == 'default') {
         $this->url = $this->project->getConfiguration()->get(array('js', 'url'), '/js/');
     }
 }
Esempio n. 16
0
 /**
  * @return Webforge\Common\System\File
  */
 protected function getGClassFromFile()
 {
     $project = \Psc\PSC::getProject();
     $gClass = new GClass(Code::mapFileToClass($this->file, $project->dir('lib')));
     $gClass->setSrcFileName((string) $this->file);
     // damit wir wirklich fremde sourcen angeben können
     return $gClass;
 }
Esempio n. 17
0
 public function __construct(DCPackage $dc, array $languages, $language, ContentStreamConverter $contentStreamConverter = NULL)
 {
     $this->dc = $dc;
     $this->setLanguages($languages);
     $this->setLanguage($language);
     $this->contentStreamConverter = $contentStreamConverter;
     $this->project = PSC::getProject();
 }
 public function setUp()
 {
     $this->chainClass = 'Psc\\CMS\\Service\\StandardControllerService';
     parent::setUp();
     $this->svc = new StandardControllerService(\Psc\PSC::getProject());
     $this->ctrlClass = __NAMESPACE__ . '\\MyTestController';
     $this->svc->setControllerClass('test', $this->ctrlClass);
 }
Esempio n. 19
0
 public function testHandlerPrintsTextAndDelegatesToErrorHandler()
 {
     $handlerMock = $this->getMock('Psc\\Code\\ErrorHandler', array('handleCaughtException'));
     $handlerMock->expects($this->once())->method('handleCaughtException')->will($this->returnSelf());
     PSC::getEnvironment()->setErrorHandler($handlerMock);
     $this->expectOutputRegex('/does not matter/');
     Exception::handler(new Exception('does not matter'));
 }
Esempio n. 20
0
 public function testRegister()
 {
     $this->assertInstanceOf($this->c, PSC::registerErrorHandler());
     $eh = PSC::getEnvironment()->getErrorHandler();
     $this->assertEquals(\Psc\Config::get('debug.errorRecipient.mail'), $eh->getRecipient());
     // denn das steht in der Config
     PSC::unregisterErrorHandler();
 }
Esempio n. 21
0
 public function testSmokes()
 {
     if (PSC::isTravis()) {
         $html = '<div class="content"><h1>Mail aus dem Test</h2>Toll, ne?</div>';
         $msg = email::send(email::htmlMessage('Test Mail aus dem Test', $html, '*****@*****.**'));
     } else {
         $this->markTestSkipped('no mailer is configured');
     }
 }
Esempio n. 22
0
 public function setUp()
 {
     $this->chainClass = 'Psc\\CMS\\Service\\EntityService';
     parent::setUp();
     $this->project = clone \Psc\PSC::getProject();
     $this->dc = new \Psc\Doctrine\DCPackage($this->getModule('Doctrine'));
     $this->factory = new Factory('Psc\\Test\\Controllers', $this->getContainer());
     $this->svc = new EntityService($this->dc, $this->factory, $this->project, 'entities');
 }
Esempio n. 23
0
 public function setUp()
 {
     $this->assertNotEmpty($this->entityName, 'EntityName muss für den RepositoryTestCase gesetzt sein (nur der ClassName)');
     // henne + ei problem hier:
     $entityFQN = $this->entityName;
     $this->chainClass = \Psc\PSC::getProject()->getModule('Doctrine')->getEntitiesNamespace($entityFQN . 'Repository');
     parent::setUp();
     $this->repository = $this->em->getRepository($entityFQN);
 }
Esempio n. 24
0
 public function setUp()
 {
     $config = PSC::getProject()->getConfiguration();
     if ($config->get('executables.rar') === NULL) {
         // sonst macht der test hier keinen sinn
         $this->markTestSkipped('Kann Test nicht ausführen, da kein rar-Executable in der Config angegeben ist.');
     }
     $this->finder = new ExecutableFinder($config->get('executables'));
 }
Esempio n. 25
0
 public function testWrappedConstructor()
 {
     $fileString = 'phar://' . ($pf = \Psc\PSC::getEnvironment()->isWindows() ? 'D:/' : '/') . 'does/not/matter/my.phar.gz/i/am/wrapped/class.php';
     $file = new File($fileString);
     $this->assertEquals('php', $file->getExtension());
     $this->assertEquals('class.php', $file->getName());
     $this->assertEquals('phar://' . $pf . 'does/not/matter/my.phar.gz/i/am/wrapped/', (string) $file->getDirectory());
     $this->assertEquals($fileString, (string) $file);
 }
Esempio n. 26
0
 /**
  * Erstellt ein neues Modul
  *
  * wird nur einmal aufgerufen pro Request
  * vorher wurde mit isModule ($name) bereits überprüft
  * @return Psc\CMS\Module
  */
 protected function create($name)
 {
     $c = $this->avaibleModules[$name]['class'];
     $module = new $c($this->project, $this->inTests);
     $module->setName($name);
     $this->modules[$name] = $module;
     PSC::getEventManager()->dispatchEvent('Psc.ModuleCreated', NULL, $module);
     return $module;
 }
Esempio n. 27
0
 public function testToSubstr()
 {
     $env = PSC::getEnvironment();
     $env->addIncludePath('/var/share/PEAR/');
     $evil = '/var/share/';
     $this->assertFalse($env->hasIncludePath($evil), 'hasIncludePath');
     $this->assertInstanceOf('\\Psc\\Environment', $env->addIncludePath($evil), 'append');
     $this->assertTrue($env->hasIncludePath($evil), 'hasIncludePath');
 }
Esempio n. 28
0
 public function __construct($name = 'requirejs', $main = '/js/boot.js', $requirejsSource = '/psc-cms-js/vendor/require.js')
 {
     if (\Psc\PSC::getProject()->isDevelopment()) {
         throw new DeprecatedException('Dont use this, use HTML\\Frameworkpage');
     }
     parent::__construct($name);
     $this->requirejsSource = $requirejsSource;
     $this->main = $main;
 }
Esempio n. 29
0
 public function testUserManagerCall()
 {
     if (\Psc\PSC::isTravis()) {
         $this->markTestSkipped('kein lokaler webserver am start');
     }
     $this->main->init($this->request);
     $this->assertCount(2, $this->main->getFrontController()->getRequestHandler()->getServices(), 'Ist EntityService hinzugefügt worden?');
     $this->response = $this->request('GET', '/entities/users/grid');
     $this->assertResponse(200);
 }
Esempio n. 30
0
 /**
  * 
  * Config::require('key1','key2','key3');
  * oder
  * Config::require('key1.key2.key3');
  * @param string $key Array indizes können mit . getrennt werden
  * @exception wenn es den Config eintrag nicht gibt
  * @return mixed
  */
 public static function req($key)
 {
     $args = func_get_args();
     if (count($args) > 1) {
         return PSC::getProject()->getConfiguration()->req($args);
     } else {
         return PSC::getProject()->getConfiguration()->req($key);
     }
     return $array;
 }