コード例 #1
0
 public function execute($arguments = array(), $options = array())
 {
     $projectDir = UtilPsdf::fixPath($arguments['pjpath']);
     $packagesDir = $projectDir . DIRECTORY_SEPARATOR . $arguments['pkpath'] . DIRECTORY_SEPARATOR;
     if (is_dir($projectDir)) {
         throw new sfCommandException(sprintf('The project "%s" already exists.', $projectDir));
     }
     $filesystem = new sfFilesystem();
     // Create basic workspace structure
     $skeletonDir = dirname(__FILE__) . '/../../data/generator/skeleton/psdfProject';
     $finder = sfFinder::type('any')->discard('.sf');
     $filesystem->mirror($skeletonDir, $projectDir, $finder);
     // Actualizo tokens
     $constants = array('PROJECT_NAME' => $arguments['pjname']);
     $finder = sfFinder::type('file')->name('.project');
     $filesystem->replaceTokens($finder->in($projectDir), '##', '##', $constants);
     // Create packages files (subdir por cada macro)
     $packages = $arguments['packages'];
     foreach ($packages as $pack) {
         if (!is_dir($packagesDir . $pack['macro'])) {
             $filesystem->mkdirs($packagesDir . $pack['macro']);
         }
         $file = $packagesDir . $pack['macro'] . DIRECTORY_SEPARATOR . $pack['name'] . '.xpdl';
         $filesystem->touch($file);
         file_put_contents($file, $pack['xpdl']);
     }
 }
コード例 #2
0
ファイル: chartTest.php プロジェクト: rbolliger/otokou
$t->isa_ok($sha1, 'string', '->save() creates a sha for each chart');
$g->setKilometersFrom(235);
$g->save();
$sha2 = $g->getHash();
$t->cmp_ok($sha1, '!=', $sha2, '->save() The hash field is updated each time the object is changed');
$g = new Chart();
$g->setFormat('png');
$g->setKilometersTo(12423);
$g->setUserId($ut->getUserId('ruf'));
$g->link('Vehicles', array($ut->getVehicleId('vw-touran-1-4-tsi')));
$g->link('Categories', array($ut->getIdForCategory('Fuel')));
$sha = $g->getHash();
$g2 = new Chart();
$g2->setUserId($ut->getUserId('ruf'));
$g->save();
$finalsha = $g->getHash();
$t->isnt($sha, $finalsha, 'When saving the object, ->save() checks that a unique sha is set. If not, a new one is generated.');
// ->delete()
$t->diag('->delete()');
$g = new Chart();
$g->setUserId($ut->getUserId('ruf'));
$g->save();
$id = $g->getId();
$path = $g->getChartFileSystemPath();
$fs = new sfFilesystem(new sfEventDispatcher());
$fs->touch($path);
$t->cmp_ok(file_exists($path), '===', true, 'A Chart may have an associated figure file.');
$g->delete();
$g2 = Doctrine_Core::getTable('Chart')->findOneById($id);
$t->cmp_ok($g2, '===', false, '->delete() deletes the chart from the DB');
$t->cmp_ok(file_exists($path), '===', false, '->delete() also deletes the image associated to the Chart');
コード例 #3
0
ファイル: chartBuilderTest.php プロジェクト: rbolliger/otokou
    $fs->remove($fullpath);
}
$g->checkPath($g->getChartsSystemPath(), false);
$t->ok(!file_exists(sfConfig::get('sf_web_dir') . $path), '->getChartsSystemPath() accepts a "create" option. If set to false, the path is not created, if not found.');
try {
    $g->checkPath($g->getChartsWebPath());
    $t->fail('no code should be executed after throwing an exception');
} catch (Exception $e) {
    $t->pass('->checkPath() only accepts system paths');
}
// ->chartSourceIsAvailable()
$t->diag('->chartSourceIsAvailable()');
$g = newChart();
$t->cmp_ok($g->chartSourceIsAvailable(), '===', false, 'Chart source file is not available for new charts');
$fs = new sfFilesystem();
$fs->touch($g->getChartFileSystemPath());
$t->cmp_ok($g->chartSourceIsAvailable(), '===', true, 'Chart source file is found, if it exists');
$fs->remove($g->getChartFileSystemPath());
$fs->remove($g->getChartsSystemPath());
// ->getAttributes()
$t->diag('->getAttributes()');
$attr = array('test' => 'sdfgdg');
$g = newChart(array(), array(), $attr);
$t->cmp_ok($g->getAttributes(), '===', $attr, '->getAttributes() returns attributes set via ChartBuilder constructor');
// ->addAttributes()
$t->diag('->addAttributes()');
$attr2 = array('a1234' => '34');
$g->addAttributes($attr2);
$t->cmp_ok($g->getAttributes(), '===', array_merge($attr, $attr2), '->addAttributes() appends new attributes');
// ->setAttributes()
$attr = array('dfsdf' => 'asdfgsdg');