Exemple #1
0
 public static function instance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemple #2
0
 public function testPropertiesAreAssignedAndRetrievedViaProperties()
 {
     $random = rand(100, 200);
     $reg_one = Tidbit_Registry::instance();
     $reg_two = Tidbit_Registry::instance();
     $reg_one->random = $random;
     $this->assertEqual($reg_one->random, $reg_two->random);
     $this->assertEqual($random, $reg_one->random);
     $this->assertIdentical($reg_one, $reg_two);
     $this->assertNoErrors();
 }
Exemple #3
0
 public function generate($number)
 {
     for ($i = 0; $i < $number; $i++) {
         $kb_id = 'seed-' . create_guid();
         $this->_rev->id = 'seed-' . create_guid();
         $this->_rev->latest = 1;
         $this->_content->id = 'seed-' . create_guid();
         $this->_rev->kbcontent_id = $this->_content->id;
         $this->_doc->id = $kb_id;
         $this->_doc->active_date = Tidbit_Registry::instance()->timedate->to_display_date(gmdate("Y-m-d"), false);
         $this->_doc->kbdocument_name = (string) new Tidbit_Gibberish(rand(3, 10));
         $this->_rev->kbdocument_id = $kb_id;
         $this->_doc->is_external = 0;
         $this->_doc->new_with_id = true;
         $this->_rev->new_with_id = true;
         $this->_content->new_with_id = true;
         $this->_doc->status_id = $this->_valid_statuses[rand(0, count($this->_valid_statuses) - 1)];
         $this->_doc->save();
         $this->_rev->save();
         $this->_content->kbdocument_body = (string) new Tidbit_Gibberish(rand(1000, 2000));
         $this->_content->save();
     }
 }
Exemple #4
0
 public function testWillUseRegistrysTimeDateObjectForGeneratingTime()
 {
     $mock = new MockTimeDate();
     $mock->expectAtLeastOnce('to_display_date');
     $mock->expectArguments('to_display_date', array(gmdate("Y-m-d"), false));
     $random = "Random #: " . rand(100, 200);
     $mock->setReturnValue('to_display_date', $random);
     Tidbit_Registry::instance()->timedate = $mock;
     $gen = new Tidbit_Generator_KBDocument($this->_doc, $this->_rev, $this->_content);
     $gen->generate(1);
     $this->assertEqual($random, $this->_doc->active_date);
 }
Exemple #5
0
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/

if (!defined('sugarEntry')) {
    define('sugarEntry', true);
}
set_include_path(
    dirname(__FILE__) . '/' . PATH_SEPARATOR .
    dirname(__FILE__) . '/..' . PATH_SEPARATOR .
    get_include_path()
);
chdir('..');

require_once 'config.php';
require_once('include/utils.php');
require_once('include/modules.php');
require_once('include/database/PearDatabase.php');
require_once('include/SugarTheme/SugarTheme.php');
require_once('include/utils/sugar_file_utils.php');

class FakeLogger { public function __call($m, $a) { } }
$GLOBALS['log'] = new FakeLogger();
$GLOBALS['app_list_strings'] = return_app_list_strings_language('en_us');
$GLOBALS['db'] = PearDatabase::getInstance();

require_once 'include/TimeDate.php';
require_once 'Tidbit/Registry.php';
Tidbit_Registry::instance()->timedate = $GLOBALS['timedate'] = new TimeDate();