public function testWrapAroundDayBackwards() { // $this->markTestSkipped(); $clock = new Clock(5, 32); $clock->sub(25 * 60); $this->assertEquals('04:32', $clock->__toString()); }
function test_angle_smallerdiff() { //Arrange $test_angle = new Clock(); $input = 9; $input2 = 10; $result = $test_angle->angle($input, $input2); //Assert $this->assertEquals(150, $result); }
function test_checkAngle_lessThanNegativeOneEighty() { //Arrange $test_Clock = new Clock(); $input1 = 1; $input2 = 57; //Act $result = $test_Clock->checkAngle($input1, $input2); //Assert $this->assertEquals(76.5, $result); }
function test_ClockAngle() { //arrange $test_Clock = new Clock(); $input_hour = 3; $input_minute = 45; //act $result = $test_Clock->betweenHands($input_hour, $input_minute); //assert $this->assertEquals(157.5, $result); }
function test_angleBetweenHands_all() { // arrange $test_Clock = new Clock(); $input_time = '10:30'; $input_time2 = '12:30'; $input_time3 = '1:07'; // act $result = $test_Clock->angleBetweenHands($input_time); $result2 = $test_Clock->angleBetweenHands($input_time2); $result3 = $test_Clock->angleBetweenHands($input_time3); // assert $this->assertEquals(135, $result); $this->assertEquals(165, $result2); $this->assertEquals(8.5, $result3); }
function __construct() { parent::__construct(); $this->_DATABASE_SERVER = DB_SERVER; $this->_DATABASE_USERNAME = DB_USERNAME; $this->_DATABASE_PASSWORD = DB_PASSWORD; }
private function __construct() { #~ Complete Booting: Set Error Handler and Load Other Core modules ##set_error_handler( '\error_handler' ); ##set_exception_handler( '\exception_handler' ); #~ Enforce E_ALL, but allow users to set levels not part of E_ALL. error_reporting(E_ALL | error_reporting()); if (!isset($_SERVER['HTTP_REFERER'])) { $_SERVER['HTTP_REFERER'] = ''; } if (!isset($_SERVER['SERVER_PROTOCOL']) || $_SERVER['SERVER_PROTOCOL'] != 'HTTP/1.0' && $_SERVER['SERVER_PROTOCOL'] != 'HTTP/1.1') { $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.0'; } if (isset($_SERVER['HTTP_HOST'])) { $_SERVER['HTTP_HOST'] = strtolower($_SERVER['HTTP_HOST']); #~ As HTTP_HOST is user input, ensure it only contains characters allowed in hostnames. See RFC 952 (and RFC 2181). if (!preg_match('/^\\[?(?:[a-z0-9-:\\]_]+\\.?)+$/', $_SERVER['HTTP_HOST'])) { #~ HTTP_HOST is invalid, e.g. if containing slashes it may be an attack. header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request'); exit; } } else { #~ Some pre-HTTP/1.1 clients will not send a Host header. Ensure the key is defined for E_ALL compliance. $_SERVER['HTTP_HOST'] = ''; } #~ Initialize Current Request Path $this->RequestPath; #~ Prevent PHP from generating HTML error messages. ini_set('html_errors', 0); #~ Don't escape quotes when reading files from the database, disk, etc. ini_set('magic_quotes_runtime', '0'); #~ Use session cookies, not transparent sessions that puts the session id in the query string. ini_set('session.use_cookies', '1'); ini_set('session.use_only_cookies', '1'); ini_set('session.use_trans_sid', '0'); #~ Don't send HTTP headers using PHP's session handler. ini_set('session.cache_limiter', 'none'); #~ Use httponly session cookies. ini_set('session.cookie_httponly', '1'); #~ Start a Timer \Clock::Get()->Start('Global'); #~ Load global settings. require_once DocRoot . '/sites/sites.php'; #~ Decide Site Directory define('ConfPath', $this->ConfPath); #~ Load the settings for active domain require_once DocRoot . $this->ConfPath . '/settings.php'; global $settings; #~ Initialize the Session if (count(explode('.', $settings['cookie_domain'])) > 2 && !is_numeric(str_replace('.', '', $settings['cookie_domain']))) { ini_set('session.cookie_domain', $settings['cookie_domain']); } if ($this->HTTPS) { ini_set('session.cookie_secure', TRUE); session_name('SSES' . md5($settings['cookie_domain'])); } else { session_name('SESS' . md5($settings['cookie_domain'])); } }
public static function Get() { if (is_null(self::$self)) { $class = __CLASS__; self::$self = new $class(); } return self::$self; }
public function testBlockWithoutTimerIsNotBlocking() { declare (ticks=1); $clock = new Clock(); $start = microtime(true); $clock->block(); $duration = microtime(true) - $start; $this->assertGreaterThan(0, $duration); $this->assertLessThan(0.001, $duration); }
/** * ベースとなる Clock オブジェクトの getUnixTime() の結果を指定された秒数だけ加減した結果を返します. * * @return int unix time */ protected function getUnixTime() { return $this->base->getUnixTime() + $this->offset; }
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/Clock.php"; $app = new Silex\Application(); $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); $app->get("/", function () use($app) { return $app['twig']->render('index.html.twig'); }); $app->get("/angle", function () use($app) { $my_Clock = new Clock(); $results = $my_Clock->angleBetweenHands($_GET['time']); return $app['twig']->render('index.html.twig', array('result' => $results)); }); return $app;
public function testPastTheHour() { $clock = new Clock(11, 9); $this->assertEquals('11:09', $clock->__toString()); }
public function test_equals() { $a = Clock::systemUTC(); $b = Clock::systemUTC(); $this->assertEquals($a->equals($a), true); $this->assertEquals($a->equals($b), true); $this->assertEquals($b->equals($a), true); $this->assertEquals($b->equals($b), true); $c = Clock::system(self::PARIS()); $d = Clock::system(self::PARIS()); $this->assertEquals($c->equals($c), true); $this->assertEquals($c->equals($d), true); $this->assertEquals($d->equals($c), true); $this->assertEquals($d->equals($d), true); $this->assertEquals($a->equals($c), false); $this->assertEquals($c->equals($a), false); $this->assertEquals($a->equals(null), false); $this->assertEquals($a->equals("other type"), false); $this->assertEquals($a->equals(Clock::fixed(Instant::now(), ZoneOffset::UTC())), false); }
public function test_equals() { $a = Clock::offset(Clock::system(self::PARIS()), self::OFFSET()); $b = Clock::offset(Clock::system(self::PARIS()), self::OFFSET()); $this->assertEquals($a->equals($a), true); $this->assertEquals($a->equals($b), true); $this->assertEquals($b->equals($a), true); $this->assertEquals($b->equals($b), true); $c = Clock::offset(Clock::system(self::MOSCOW()), self::OFFSET()); $this->assertEquals($a->equals($c), false); $d = Clock::offset(Clock::system(self::PARIS()), self::OFFSET()->minusNanos(1)); $this->assertEquals($a->equals($d), false); $this->assertEquals($a->equals(null), false); $this->assertEquals($a->equals("other type"), false); $this->assertEquals($a->equals(Clock::systemUTC()), false); }
/** * * @return string HTML string for a clock */ function clock() { // Show the Eve time. if (config::get('show_evestatus')) { $sstatus = new ServerStatus(); return $sstatus->display(); } else { if (config::get('show_clock')) { $this->page->addOnLoad("setInterval('updateClock()', 60000 )"); $clock = new Clock(); return $clock->generate(); } } }
<?php require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../src/Clock.php'; $app = new Silex\Application(); $app['debug'] = TRUE; $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); $app->get('/', function () use($app) { return $app['twig']->render('time.html.twig'); }); $app->get('clock', function () use($app) { $my_Clock = new Clock(); $time = $my_Clock->angle($_GET['hour'], $_GET['minute']); return $app['twig']->render('clock.html.twig', array('degrees' => $time)); }); return $app;
/** * @param string $name */ public static function now($name) { return new self(Clock::now(), $name); }
public function test_equals() { $a = Clock::fixed(self::INSTANT(), ZoneOffset::UTC()); $b = Clock::fixed(self::INSTANT(), ZoneOffset::UTC()); $this->assertEquals($a->equals($a), true); $this->assertEquals($a->equals($b), true); $this->assertEquals($b->equals($a), true); $this->assertEquals($b->equals($b), true); $c = Clock::fixed(self::INSTANT(), self::PARIS()); $this->assertEquals($a->equals($c), false); $d = Clock::fixed(self::INSTANT()->minusNanos(1), ZoneOffset::UTC()); $this->assertEquals($a->equals($d), false); $this->assertEquals($a->equals(null), false); $this->assertEquals($a->equals("other type"), false); $this->assertEquals($a->equals(Clock::systemUTC()), false); }
public function __construct() { $this->now = Clock::now(); }
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/Clock.php"; $app = new Silex\Application(); $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); $app->get("/", function () use($app) { return $app['twig']->render('form.html.twig'); }); $app->get("/view_angle", function () use($app) { $my_Clock = new Clock(); $check_angle = $my_Clock->checkAngle($_GET['hour'], $_GET['minute']); return $app['twig']->render('clock_results.html.twig', array('result' => $check_angle)); }); return $app;
function clock() { // Show the Eve time. if (config::get('show_clock')) { $clock = new Clock(); return $clock->generate(); } }