Ejemplo n.º 1
0
 public function testInsertImageFileReturnsImageEntity()
 {
     $file = File::createTemporary();
     $file->writeContents($this->getFile('img1.jpg')->getContents());
     $image = $this->imageCtrl->insertImageFile($file, (object) array('specification', 'not', 'yet', 'specified'));
     $this->assertSame($this->bud, $this->getResponseData($image));
 }
Ejemplo n.º 2
0
 public function testConstruct()
 {
     $tpl = new MainTemplate();
     $tpl->addMarkupText('Dies ist ein kleiner aber schöner Test');
     $file = File::createTemporary();
     $tpl->write($file);
     $this->assertFileExists((string) $file);
     $file->delete();
 }
Ejemplo n.º 3
0
 public function __construct($url, File $cookieJar = NULL)
 {
     $this->setUrl($url);
     $this->ch = curl_init();
     $this->cookieJar = $cookieJar ?: File::createTemporary();
     $this->data = new stdClass();
     if (Helper::isHTTPS($this->url)) {
         $this->useSSL();
     }
     $this->manager = new EventManager();
 }
Ejemplo n.º 4
0
 public function testMultiPartHTTPRequetsDataConversionIntoFiles()
 {
     $request = new Request(Request::POST, '/cms/images');
     $request->setHeaderField('Content-Type', 'multipart/form-data; boundary=-----------------------------41184676334')->setBody(array('bodyAsJSON' => '{"types":["jpg","png","gif"]}'))->setFiles(array('uploadFile' => \Webforge\Common\System\File::createTemporary()));
     // das würde der HTTPRequest schona lles bei infer() checken
     $serviceRequest = $this->requestConverter->fromHTTPRequest($request);
     $this->assertTrue($serviceRequest->hasFiles());
     $this->assertInternalType('array', $files = $serviceRequest->getFiles());
     $this->assertCount(1, $files);
     $this->assertInstanceOf('Webforge\\Common\\System\\File', $files['uploadFile']);
     $this->assertEquals((object) array('types' => array('jpg', 'png', 'gif')), $serviceRequest->getBody());
 }
Ejemplo n.º 5
0
    public function testSyntaxCheckFailure()
    {
        $file = File::createTemporary();
        $file->writeContents(<<<'PHP'
<?php

namespace psc-cms;

?>
PHP
);
        $writer = new ClassWriter();
        $this->assertFalse($writer->syntaxCheck($file, 'return'));
        try {
            $writer->syntaxCheck($file);
        } catch (\Psc\Code\Generate\SyntaxErrorException $e) {
            $this->assertContains("syntax error", $e->getMessage(), 'syntax error ist nicht ausgezeichnet');
            return;
        }
        $this->fail('Exception erwartet für failure');
    }
Ejemplo n.º 6
0
 public function build()
 {
     $this->prepareTemp();
     /* Dateien ins Temp-Verzeichnis kopieren */
     $class2path = array();
     $relDir = $this->classPath->up();
     // wir wollen ja den Namespace als erstes Verzeichnis haben
     foreach ($this->getClassFiles() as $file) {
         $class = $this->inferClassName($file);
         // $class2path[ $class ] = $fileURL;
         $class2path[ltrim($class, '\\')] = $url = $file->getURL($relDir);
         // statt hier Code::mapClassToFile() zu machen nehmen wir die url
         $targetFile = File::createFromURL($url, $this->tempSrc);
         $targetFile->getDirectory()->create();
         $this->log(str_pad('Add: ' . $url, 80, ' ', STR_PAD_RIGHT) . " [" . $class . "]", 2);
         $file->copy($targetFile);
     }
     foreach ($this->additionalFiles as $list) {
         list($file, $fileInPhar) = $list;
         $targetFile = new File($this->tempSrc . $fileInPhar);
         $targetFile->getDirectory()->create();
         $this->log('Add: ' . $fileInPhar);
         $file->copy($targetFile);
     }
     /* Bootstrapping */
     $bootstrapCode = $this->getBootstrapCode($class2path);
     $bootstrapFile = new File($this->tempSrc, 'index.php');
     $bootstrapFile->writeContents($bootstrapCode);
     /* Build */
     try {
         $tmp = File::createTemporary();
         $tmp->setExtension('phar.gz');
         $this->phar = new PHPPhar((string) $tmp);
         $this->phar->compress(PHPPHAR::GZ);
         $this->phar->startBuffering();
         $this->phar->buildFromDirectory($this->tempSrc);
         $this->phar->stopBuffering();
         $this->tempSrc->delete();
         $this->out->delete();
         $tmp->copy($this->out);
     } catch (\Exception $e) {
         $this->tempSrc->delete();
         throw $e;
     }
 }
Ejemplo n.º 7
0
 public function testSha1Hashing()
 {
     $content = 'sldfjsldfj';
     $otherContent = 's00000000';
     $file = File::createTemporary();
     $file->writeContents($content);
     $this->assertEquals(sha1($content), $file->getSha1());
     // test caching
     $file->writeContents($otherContent);
     //$this->assertNotEquals(sha1($content), $file->getSha1());
     $this->assertEquals(sha1($otherContent), $file->getSha1());
 }