コード例 #1
0
 public function testDecrement()
 {
     $key1 = 'test';
     $key2 = 'test2';
     Counter::reset($key1);
     Counter::reset($key2);
     $this->assertEquals(10, Counter::increment($key1, 10));
     $this->assertEquals(10, Counter::increment($key2, 10));
     $this->assertEquals(9, Counter::decrement($key1));
     $this->assertEquals(8, Counter::decrement($key1));
     $this->assertEquals(9, Counter::decrement($key2));
     $this->assertEquals(8, Counter::decrement($key2));
     $this->assertEquals(6, Counter::decrement($key2, 2));
     $this->assertEquals(6, Counter::decrement($key1, 2));
     $this->assertEquals(-2, Counter::decrement($key2, 8));
     $this->assertEquals(-2, Counter::decrement($key1, 8));
 }
コード例 #2
0
ファイル: TestCase.php プロジェクト: phwoolcon/phwoolcon
 public function setUp()
 {
     $_SERVER['SCRIPT_NAME'] = '/index.php';
     $_SERVER['PHWOOLCON_PHALCON_VERSION'] = Version::getId();
     /* @var Di $di */
     $di = $this->di = Di::getDefault();
     Events::register($di);
     DiFix::register($di);
     Db::register($di);
     Cache::register($di);
     Log::register($di);
     Config::register($di);
     Counter::register($this->di);
     Aliases::register($di);
     I18n::register($di);
     Cookies::register($di);
     Session::register($di);
     Cache::flush();
     Config::clearCache();
     parent::setUp();
     $class = get_class($this);
     Log::debug("================== Running {$class}::{$this->getName()}() ... ==================");
     Timer::start();
 }
コード例 #3
0
ファイル: di.php プロジェクト: phwoolcon/phwoolcon
use Phalcon\Version;
use Phwoolcon\Aliases;
use Phwoolcon\Cache;
use Phwoolcon\Config;
use Phwoolcon\Cookies;
use Phwoolcon\Db;
use Phwoolcon\DiFix;
use Phwoolcon\Events;
use Phwoolcon\I18n;
use Phwoolcon\Log;
use Phwoolcon\Queue;
use Phwoolcon\Router;
use Phwoolcon\Session;
use Phwoolcon\Util\Counter;
use Phwoolcon\View;
$_SERVER['PHWOOLCON_PHALCON_VERSION'] = Version::getId();
Events::register($di);
DiFix::register($di);
Db::register($di);
Cache::register($di);
Log::register($di);
Config::register($di);
Counter::register($di);
Aliases::register($di);
Router::register($di);
I18n::register($di);
Cookies::register($di);
Session::register($di);
View::register($di);
Queue::register($di);
$loader->registerNamespaces(Config::get('app.autoload.namespaces', []), true);
コード例 #4
0
ファイル: Model.php プロジェクト: phwoolcon/phwoolcon
 public function generateDistributedId()
 {
     $prefix = time() - static::$_distributedOptions['start_time'];
     $suffix = Text::padOrTruncate(Counter::increment($this->_table), '0', 4);
     $id = $prefix . static::$_distributedOptions['node_id'] . $suffix;
     return $this->setId($id);
 }