function testReadConfig() { $dir = dirname(__FILE__); $values = Env\readConfig(array("{$dir}/conf1.ini", "{$dir}/conf2.ini")); assertEqual("hello", $values['this.that']); assertEqual("goodbye", $values['something.else']); assertEqual("overridden-value", $values['overridden']); }
function testOneEmailAddressMayNotBeAssociatedWithMultipleAccounts() { newUser($email = '*****@*****.**', $username = '******', $password = '******'); $this->get('/account/signup'); $this->submitFormExpectingErrors($this->getForm(), array('username' => 'bigkid', 'email' => '*****@*****.**', 'password1' => 't0pS33cret', 'password2' => 't0pS33cret')); $this->assertContains("//div[contains(., 'already have an account')]"); assertEqual(1, DB\countRows('users', 'email = ?', array('*****@*****.**'))); }
public function testDivide() { $this->objMath->setFirstOperand('100'); $this->objMath->setSecondOperand('2'); $answer = $this->objMath->calculate(); assertEqual($answer, 50); }
public function testModulus() { $this->objMath->setFirstOperand('5'); $this->objMath->setSecondOperand('2'); $answer = $this->objMath->calculate(); assertEqual($answer, 1); }
public function testMultiply() { $this->objMath->setFirstOperand('10'); $this->objMath->setSecondOperand('9'); $answer = $this->objMath->calculate(); assertEqual($answer, 90); }
public function testSubtract() { $this->objMath->setFirstOperand('10'); $this->objMath->setSecondOperand('5'); $answer = $this->objMath->calculate(); assertEqual($answer, 5); }
function testGetBalanceUsesLocallyCachedValueWhenAppropriate() { $address = '1K7dyLY6arFRXBidQhrtnyqksqJZdj2F37'; $actualBalance = BlockchainDotInfo\getBalanceInSatoshis($address); $cachedBalance = $actualBalance + 1000; DB\delete('bitcoin_addresses', 'address = ?', array($address)); DB\insertOne('bitcoin_addresses', array('address' => $address, 'satoshis' => $cachedBalance, 'updated_at' => new DateTime('now'))); $balance = Bitcoin\getBalance($address, null); assertEqual($cachedBalance, $balance->numSatoshis); assertEqual($cachedBalance / Bitcoin\satoshisPerBTC(), $balance->numBTC); }
public function testAdd() { $this->objMath->setFirstOperand('4'); $this->objMath->setSecondOperand('5'); $answer = $this->objMath->calculate(); assertEqual($answer, 9); }
function testTrimZeros() { $go = function ($a) { return Currency\trimZeros($a); }; assertEqual('2', $go(2.0)); assertEqual('2', $go('2.00000')); assertEqual('72.55', $go(72.55)); assertEqual('200', $go(200)); assertEqual('7500', $go('007500')); }
private function assertDatesAreEqual($d1, $d2) { if (empty($d1)) { fail("d1 is empty"); } if (empty($d2)) { fail("d2 is empty"); } $d1 = $d1 instanceof DateTime ? $d1 : new DateTime($d1); $d2 = $d2 instanceof DateTime ? $d2 : new DateTime($d2); assertEqual($d1->format('Y-m-d'), $d2->format('Y-m-d')); }
public function run() { $result = $this->ds->all('show tables'); output($result); $result = Sql::assistant($this->ds)->select_row('ycb_test_task', array('used_vu' => array(20, '>=')), 'task_name,agent_id'); output($result); $result = Sql::assistant($this->ds)->select('ycb_test_task', array('used_vu' => array(20, '>=')), 'task_name,agent_id'); output($result); $cond = "author_id=123 AND bookname='仓鼠'"; $result = Sql::assistant($this->ds)->cond($this->ds, $cond, FALSE); assertEqual($result, "author_id=123 AND bookname='仓鼠'"); // ? 为数组 $cond = array('author_id' => 123, 'bookname' => '仓鼠'); $result = Sql::assistant($this->ds)->cond($this->ds, $cond, FALSE); assertEqual($result, "author_id = 123 AND bookname = '仓鼠'"); // > < != $cond = array('author_id' => array(123, '>'), 'bookname' => '仓鼠'); $result = Sql::assistant($this->ds)->cond($this->ds, $cond, FALSE); assertEqual($result, "author_id > 123 AND bookname = '仓鼠'"); $cond = array('author_id' => array(123, '<'), 'bookname' => '仓鼠'); $result = Sql::assistant($this->ds)->cond($this->ds, $cond, FALSE); assertEqual($result, "author_id < 123 AND bookname = '仓鼠'"); $cond = array('author_id' => array(123, '!='), 'bookname' => '仓鼠'); $result = Sql::assistant($this->ds)->cond($this->ds, $cond, FALSE); assertEqual($result, "author_id != 123 AND bookname = '仓鼠'"); // 模糊查询 $cond = array('bookname' => array('%仓鼠%', 'LIKE')); $result = Sql::assistant($this->ds)->cond($this->ds, $cond, FALSE); assertEqual($result, "bookname LIKE '%仓鼠%'"); // 'IN','NOT IN' $cond = array('author_id' => array(array(123, 124, 125))); $result = Sql::assistant($this->ds)->cond($this->ds, $cond, FALSE); assertEqual($result, "author_id IN (123,124,125)"); $cond = array('author_id' => array(array(123, 124, 125), 'IN')); $result = Sql::assistant($this->ds)->cond($this->ds, $cond, FALSE); assertEqual($result, "author_id IN (123,124,125)"); $cond = array('author_id' => array(array(123, 124, 125), 'NOT IN')); $result = Sql::assistant($this->ds)->cond($this->ds, $cond, FALSE); assertEqual($result, "author_id NOT IN (123,124,125)"); // BETWEEN AND , NOT BETWEEN AND $cond = array('author_id' => array(array(10, 25), 'BETWEEN_AND')); $result = Sql::assistant($this->ds)->cond($this->ds, $cond, FALSE); assertEqual($result, "author_id BETWEEN 10 AND 25"); $cond = array('author_id' => array(array(10, 25), 'NOT_BETWEEN_AND')); $result = Sql::assistant($this->ds)->cond($this->ds, $cond, FALSE); assertEqual($result, "author_id NOT BETWEEN 10 AND 25"); // author_id > 15 OR author_id < 5 AND author_id != 32 $cond = array('author_id' => array(array(array(15, '>', 'OR'), array(5, '<', 'AND'), array(32, '!=')), 'FIELD_GROUP')); $result = Sql::assistant($this->ds)->cond($this->ds, $cond, FALSE); assertEqual($result, " (author_id > 15 OR author_id < 5 AND author_id != 32)"); // OR AND 连接符 $cond = array('author_id' => array(123, '!=', 'AND'), 'bookname' => array('仓鼠', '=', 'OR'), 'book_price' => array(45, '<=', 'AND')); $result = Sql::assistant($this->ds)->cond($this->ds, $cond, FALSE); assertEqual($result, "author_id != 123 AND bookname = '仓鼠' OR book_price <= 45"); // 传入的条件的值中的特殊字符会自动进行 qstr 转义 $cond = array('bookname' => array("%仓'仓%", 'LIKE')); $result = Sql::assistant($this->ds)->cond($this->ds, $cond, FALSE); assertEqual($result, "bookname LIKE '%仓\\'仓%'"); // 数据表字段名比较 $cond = array('author_id' => array(123, '!=', 'AND'), 'book_price' => array("market_parce", '>', 'AND', true)); $result = Sql::assistant($this->ds)->cond($this->ds, $cond, FALSE); assertEqual($result, "author_id != 123 AND book_price > market_parce"); }
assertEqual(getBigSubtract("14", "14"), "0"); assertEqual(getBigSubtract("15", "14"), "1"); assertEqual(getBigSubtract("14", "15"), "ERROR"); assertEqual(getBigSubtract("1400000000", "1500000000"), "ERROR"); assertEqual(getBigSubtract("1400000000000", "1500000000000"), "ERROR"); assertEqual(getBigSubtract("1500000000001", "1400000000002"), "99999999999"); assertEqual(getBigSubtract("1400000000000000", "1500000000000000"), "ERROR"); assertEqual(getBigSubtract("1500000000001001", "1400000000002003"), "99999999998998"); assertEqual(getBigAdd("19", "1"), "20"); assertEqual(getBigAdd("1900000000000000000001", "100000000000000000078"), "2000000000000000000079"); assertEqual(getBigAdd("1900000000000000000001000001", "10000000000000000007800009"), "1910000000000000000008800010"); assertEqual(getBigMultiply("1000", "1000"), "1000000"); assertEqual(getBigMultiply("1000000", "1000000"), "1000000000000"); assertEqual(getBigMultiply("10000000", "10000000"), "100000000000000"); assertEqual(getBigMultiply("100000000", "100000000"), "10000000000000000"); assertEqual(getBigMultiply("1000000001", "1000000001"), "1000000002000000001"); assertEqual(getBigMultiply("10000000001", "10000000001"), "100000000020000000001"); assertEqual(getBigMultiply("22", "22"), "484"); assertEqual(getBigDivide("14", "2"), "7"); assertEqual(getBigDivide("15", "2"), "7"); assertEqual(getBigDivide("16", "2"), "8"); assertEqual(getBigDivide("16000000000000000028", "222222222229998"), "71999"); assertEqual(getGreaterThan("10", "2"), TRUE); assertEqual(getGreaterThan("2", "10"), FALSE); assertEqual(isThisPrime('15730', '15727'), FALSE); assertEqual(getPreviousPrime('104761'), "104759"); assertEqual(getNextPrime("104759"), "104761"); assertEqual(getNextPrime(getBigVariable('last-prime')), "LAST_PRIME"); assertEqual(getBigSquareRoot("10000"), "100"); assertEqual(getBigSquareRoot("10000000000"), "100000");
private function assertProgressBarReads($percent) { $elems = $this->findElements("//*[@class='status-bar-container']//*[@class='bar']"); assertEqual("width: {$percent}%;", $elems[0]->getAttribute('style')); }
function runTests() { $test = new URI('http://*****:*****@webr3.org/a/b/cc/d/../.././nathan?egg=shell&norm=bob#s/../x'); $message = 'URI parsing and components'; assertEqual($test->scheme, 'http', $message); assertEqual($test->userinfo, 'frankety:234asf', $message); assertEqual($test->host, 'webr3.org', $message); assertEqual($test->path, '/a/b/cc/d/../.././nathan', $message); assertEqual($test->query, '?egg=shell&norm=bob', $message); assertEqual($test->fragment, '#s/../x', $message); $message = 'URI Defrag'; assertEqual($test->defrag()->equals('http://*****:*****@webr3.org/a/b/cc/d/../.././nathan?egg=shell&norm=bob'), true, $message); $message = 'Absolute URI functions'; assertEqual($test->isAbsolute(), false, $message); $test = $test->toAbsolute(); assertEqual($test->isAbsolute(), true, $message); assertEqual($test, 'http://*****:*****@webr3.org/a/b/nathan?egg=shell&norm=bob', $message); assertEqual($test->path, '/a/b/nathan', $message); $message = 'Relative URI Reference Resolution'; $test = new URI('http://a/b/c/d;p?q'); assertEqual($test->resolveReference('g:h'), 'g:h', $message); assertEqual($test->resolveReference('g'), 'http://a/b/c/g', $message); assertEqual($test->resolveReference('./g'), 'http://a/b/c/g', $message); assertEqual($test->resolveReference('g/'), 'http://a/b/c/g/', $message); assertEqual($test->resolveReference('/g'), 'http://a/g', $message); assertEqual($test->resolveReference('//g'), 'http://g', $message); assertEqual($test->resolveReference('?y'), 'http://a/b/c/d;p?y', $message); assertEqual($test->resolveReference('g?y'), 'http://a/b/c/g?y', $message); assertEqual($test->resolveReference('#s'), 'http://a/b/c/d;p?q#s', $message); assertEqual($test->resolveReference('g#s'), 'http://a/b/c/g#s', $message); assertEqual($test->resolveReference('g?y#s'), 'http://a/b/c/g?y#s', $message); assertEqual($test->resolveReference(';x'), 'http://a/b/c/;x', $message); assertEqual($test->resolveReference('g;x'), 'http://a/b/c/g;x', $message); assertEqual($test->resolveReference('g;x?y#s'), 'http://a/b/c/g;x?y#s', $message); assertEqual($test->resolveReference(''), 'http://a/b/c/d;p?q', $message); assertEqual($test->resolveReference('.'), 'http://a/b/c/', $message); assertEqual($test->resolveReference('./'), 'http://a/b/c/', $message); assertEqual($test->resolveReference('..'), 'http://a/b/', $message); assertEqual($test->resolveReference('../'), 'http://a/b/', $message); assertEqual($test->resolveReference('../g'), 'http://a/b/g', $message); assertEqual($test->resolveReference('../..'), 'http://a/', $message); assertEqual($test->resolveReference('../../'), 'http://a/', $message); assertEqual($test->resolveReference('../../g'), 'http://a/g', $message); assertEqual($test->resolveReference('../../../g'), 'http://a/g', $message); assertEqual($test->resolveReference('../../../../g'), 'http://a/g', $message); assertEqual($test->resolveReference('/./g'), 'http://a/g', $message); assertEqual($test->resolveReference('/../g'), 'http://a/g', $message); assertEqual($test->resolveReference('g.'), 'http://a/b/c/g.', $message); assertEqual($test->resolveReference('.g'), 'http://a/b/c/.g', $message); assertEqual($test->resolveReference('g..'), 'http://a/b/c/g..', $message); assertEqual($test->resolveReference('..g'), 'http://a/b/c/..g', $message); assertEqual($test->resolveReference('./../g'), 'http://a/b/g', $message); assertEqual($test->resolveReference('./g/.'), 'http://a/b/c/g/', $message); assertEqual($test->resolveReference('g/./h'), 'http://a/b/c/g/h', $message); assertEqual($test->resolveReference('g/../h'), 'http://a/b/c/h', $message); assertEqual($test->resolveReference('g;x=1/./y'), 'http://a/b/c/g;x=1/y', $message); assertEqual($test->resolveReference('g;x=1/../y'), 'http://a/b/c/y', $message); assertEqual($test->resolveReference('g?y/./x'), 'http://a/b/c/g?y/./x', $message); assertEqual($test->resolveReference('g?y/../x'), 'http://a/b/c/g?y/../x', $message); assertEqual($test->resolveReference('g#s/./x'), 'http://a/b/c/g#s/./x', $message); assertEqual($test->resolveReference('g#s/../x'), 'http://a/b/c/g#s/../x', $message); echo 'all tests passed'; }
function testEncodingAndDecodingWidgetID() { foreach (array(1, 792, 9533, 54728921) as $id) { assertEqual($id, ShortURL\decodeID(ShortURL\encodeID($id))); } }
public function testvideoinfo() { $u = "http://openapi.youku.com/v2/shows/videos.json?client_id=ce905694ae10ccab&show_id=z0375f6ec568a11e4a080"; //videoinfo($u); assertEqual("ssss", videoinfo($u)); }
print "ERROR: the full ua-parser project needs to be loaded for the test suite to work. sorry.\n"; exit; } // test files and properties normally in them $test_files = array("test_user_agent_parser", "test_user_agent_parser_os", "additional_os_tests", "test_device", "firefox_user_agent_strings"); $test_props = array("family", "major", "minor", "patch", "patch_minor"); $test_types = array("test_device" => "device", "test_user_agent_parser_os" => "os", "additional_os_tests" => "os", "test_user_agent_parser" => "ua", "firefox_user_agent_strings" => "ua"); foreach ($test_files as $test_file) { print "\n\nrunning uaparser.php against " . $test_file . ".yaml...\n"; $data = Spyc::YAMLLoad($basePath . "../test_resources/" . $test_file . ".yaml"); foreach ($data["test_cases"] as $test_case) { if (!isset($test_case["js_ua"])) { $bool = true; $result = $parser->parse($test_case["user_agent_string"]); foreach ($test_props as $test_prop) { if ($bool) { $bool = isset($test_case[$test_prop]) ? assertEqual($result->{$test_types}[$test_file]->{$test_prop}, $test_case[$test_prop]) : $bool; } } if (!$bool) { reportMismatch($result, $test_case, $test_file); } else { print "."; } } } } print "\n\ndone testing...\n"; } else { print "You must run this file from the command line."; }