Пример #1
0
 public function testBehaviors()
 {
     $component = new CComponent();
     $hash = new ARedisHash("testAttribute" . uniqid(), $this->getConnection());
     $component->attachBehavior("testAttribute", $hash);
     $this->assertTrue(isset($component->testAttribute));
     $this->assertTrue($component->testAttribute->add("test", true));
     $this->assertTrue((bool) $component->testAttribute['test']);
     $component->testAttribute->clear();
 }
Пример #2
0
 public function run($args)
 {
     $comp = new CComponent();
     $ubconfig = array_merge(array('class' => 'UpdaterBehavior', 'isConsole' => true, 'noHalt' => true));
     $comp->attachBehavior('UpdaterBehavior', $ubconfig);
     // The files directly involved in the update process:
     $updaterFiles = $comp->updaterFiles;
     // The web-based updater's action classes, which are defined separately:
     $updaterActions = $comp->getWebUpdaterActions(false);
     foreach ($updaterActions as $name => $properties) {
         $updaterFiles[] = UpdaterBehavior::classAliasPath($properties['class']);
     }
     echo "\$deps = ";
     var_export($updaterFiles);
 }
 public function instantiate()
 {
     $component = new CComponent();
     $component->attachBehavior('messageParser', array('class' => 'X2TranslationBehavior'));
     return $component;
 }
Пример #4
0
 /**
  * Instantiates a new CComponent object with {@link UpdaterBehavior attached
  * to it, and returns it.
  * @return CComponent
  */
 public function instantiateUBe($properties = array())
 {
     $comp = new CComponent();
     $ubconfig = array_merge(array('class' => 'UpdaterBehavior', 'isConsole' => true, 'noHalt' => true), $properties);
     $comp->attachBehavior('UpdaterBehavior', $ubconfig);
     return $comp;
 }
Пример #5
0
 public function instantiate($config = array())
 {
     $obj = new CComponent();
     $obj->attachBehavior('CampaignMailing', array_merge(array('class' => 'CampaignMailingBehavior', 'itemId' => $this->listItem('testUser_unsent')->id, 'campaign' => $this->campaign('testUser')), $config));
     return $obj;
 }
Пример #6
0
 /**
  * Verify correct operation of {@link prepareExportDeliverable}.
  * Currently, the exportDestinations with test cases include: download, server, ftp, scp
  * exportDestinations remaining to be tested: s3, gdrive
  */
 public function testPrepareExportDeliverable()
 {
     $component = new CComponent();
     $component->attachBehavior('importexport', new ImportExportBehavior());
     $testfile = implode(DIRECTORY_SEPARATOR, array(Yii::app()->basePath, 'tests', 'data', 'csvs', 'contacts.csv'));
     // Ensure failure when the exportDestination is not specified
     $ret = $component->prepareExportDeliverable($testfile, array());
     $this->assertFalse($ret);
     // Test standard browser download method
     $params = array('exportDestination' => 'download');
     $ret = $component->prepareExportDeliverable($testfile, $params);
     $this->assertTrue($ret);
     $params['compressOutput'] = true;
     $ret = $component->prepareExportDeliverable($testfile, $params);
     $this->assertTrue($ret);
     $this->assertFileExists($component->safePath('contacts.zip'));
     unlink($component->safePath('contacts.zip'));
 }