예제 #1
0
 /**
  * Reschedule the plugin for next run, and republish
  *
  *
  * @return void
  */
 protected function reschedule()
 {
     $now = JFactory::getDate();
     $now = $now->toUnix();
     $new = JFactory::getDate($this->row->nextrun);
     $tmp = $new->toUnix();
     switch ($this->row->unit) {
         case 'second':
             $inc = 1;
             break;
         case 'minute':
             $inc = 60;
             break;
         case 'hour':
             $inc = 60 * 60;
             break;
         default:
         case 'day':
             $inc = 60 * 60 * 24;
             break;
     }
     while ($tmp + $inc * $this->row->frequency < $now) {
         $tmp = $tmp + $inc * $this->row->frequency;
     }
     // Mark them as being run
     $nextRun = JFactory::getDate($tmp);
     $this->query->clear();
     $this->query->update('#__{package}_cron');
     $this->query->set('lastrun = ' . $this->db->quote($nextRun->toSql()));
     if ($this->pluginModel->shouldReschedule() && $this->pluginModel->doRunGating()) {
         $this->query->set("published = '1'");
     }
     if (!$this->pluginModel->shouldReschedule()) {
         $this->query->set("published = '0'");
         $this->log->message .= "\nPlugin has unpublished itself";
     }
     $this->query->where('id = ' . $this->row->id);
     $this->db->setQuery($this->query);
     $this->db->execute();
 }
	/**
	 * Tests the JDatabaseQuery::update method.
	 *
	 * @return  void
	 *
	 * @covers  JDatabaseQuery::update
	 * @since   11.3
	 */
	public function testUpdate()
	{
		$this->assertThat(
			$this->_instance->update('#__foo'),
			$this->identicalTo($this->_instance),
			'Tests chaining.'
		);

		$this->assertThat(
			$this->_instance->type,
			$this->equalTo('update'),
			'Tests the type property is set correctly.'
		);

		$this->assertThat(
			trim($this->_instance->update),
			$this->equalTo('UPDATE #__foo'),
			'Tests the update element is set correctly.'
		);
	}