• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP testpack函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中testpack函数的典型用法代码示例。如果您正苦于以下问题:PHP testpack函数的具体用法?PHP testpack怎么用?PHP testpack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了testpack函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: testTypes

 /**
  * Test types.
  * Test how RedBeanPHP OODB and OODBBean handle type and type casts.
  * 
  * Rules:
  * 
  * 1. before storing a bean all types are preserved except booleans (they are converted to STRINGS '0' or '1')
  * 2. after store-reload all bean property values are STRINGS or NULL 
  *    (or ARRAYS but that's only from a user perspective because these are lazy loaded)
  * 3. the ID returned by store() is an INTEGER (if possible; on 32 bit systems overflowing values will be cast to STRINGS!)
  * 
  * After loading:
  * ALL VALUES EXCEPT NULL -> STRING
  * NULL -> NULL
  * 
  * @note Why not simply return bean->id in store()? Because not every driver returns the same type:
  * databases without insert_id support require a separate query or a suffix returning STRINGS, not INTEGERS.
  * 
  * @note Why not preserve types? I.e. I store integer, why do I get back a string?
  * Answer: types are handled different across database platforms, would cause overhead to inspect every value for type,
  * also PHP is a dynamically typed language so types should not matter that much. Another reason: due to the nature
  * of RB columns in the database might change (INT -> STRING) this would cause return types to change as well which would
  * cause 'cascading errors', i.e. a column gets widened and suddenly your code would break.
  * 
  * @note Unfortunately the 32/64-bit issue cannot be tested fully. Return-strategy store() is probably the safest
  * solution.
  * 
  * @return void
  */
 public function testTypes()
 {
     testpack('Beans can only contain STRING and NULL after reload');
     R::nuke();
     $bean = R::dispense('bean');
     $bean->number = 123;
     $bean->float = 12.3;
     $bean->bool = false;
     $bean->bool2 = true;
     $bean->text = 'abc';
     $bean->null = null;
     $bean->datetime = new \DateTime('NOW', new \DateTimeZone('Europe/Amsterdam'));
     $id = R::store($bean);
     asrt(is_int($id), TRUE);
     asrt(is_float($bean->float), TRUE);
     asrt(is_integer($bean->number), TRUE);
     asrt(is_string($bean->bool), TRUE);
     asrt(is_string($bean->bool2), TRUE);
     asrt(is_string($bean->datetime), TRUE);
     asrt(is_string($bean->text), TRUE);
     asrt(is_null($bean->null), TRUE);
     $bean = R::load('bean', $id);
     asrt(is_string($bean->id), TRUE);
     asrt(is_string($bean->float), TRUE);
     asrt(is_string($bean->number), TRUE);
     asrt(is_string($bean->bool), TRUE);
     asrt(is_string($bean->bool2), TRUE);
     asrt(is_string($bean->datetime), TRUE);
     asrt(is_string($bean->text), TRUE);
     asrt(is_null($bean->null), TRUE);
     asrt($bean->bool, '0');
     asrt($bean->bool2, '1');
 }
开发者ID:skullyframework,项目名称:skully,代码行数:62,代码来源:Typechecking.php


示例2: testTainted

 /**
  * Test tainted.
  *
  * @return void
  */
 public function testTainted()
 {
     testpack('Original Tainted Tests');
     $redbean = R::getRedBean();
     $spoon = $redbean->dispense("spoon");
     asrt($spoon->getMeta("tainted"), TRUE);
     $spoon->dirty = "yes";
     asrt($spoon->getMeta("tainted"), TRUE);
     testpack('Tainted List test');
     $note = R::dispense('note');
     $note->text = 'abc';
     $note->ownNote[] = R::dispense('note')->setAttr('text', 'def');
     $id = R::store($note);
     $note = R::load('note', $id);
     asrt($note->isTainted(), FALSE);
     // Shouldn't affect tainted
     $note->text;
     asrt($note->isTainted(), FALSE);
     $note->ownNote;
     asrt($note->isTainted(), TRUE);
     testpack('Tainted Test Old Value');
     $text = $note->old('text');
     asrt($text, 'abc');
     asrt($note->hasChanged('text'), FALSE);
     $note->text = 'xxx';
     asrt($note->hasChanged('text'), TRUE);
     $text = $note->old('text');
     asrt($text, 'abc');
     testpack('Tainted Non-exist');
     asrt($note->hasChanged('text2'), FALSE);
     testpack('Misc Tainted Tests');
     $bean = R::dispense('bean');
     $bean->hasChanged('prop');
     $bean->old('prop');
 }
开发者ID:cesium147,项目名称:redbean,代码行数:40,代码来源:Tainted.php


示例3: testTags

 /**
  * Some basic tests.
  * 
  * @return void
  */
 public function testTags()
 {
     list($c, $d, $e, $f) = R::dispense('coffee', 4);
     R::tag($c, 'strong,black');
     R::tag($d, 'black');
     R::tag($e, 'strong,sweet');
     R::tag($f, 'black,strong');
     //$x = array_intersect(R::tagged('coffee','sweet'),R::tagged('coffee','strong'));
     asrt(count(R::taggedAll('coffee', 'strong,sweet')), 1);
     asrt(count(R::taggedAll('coffee', 'strong')), 3);
     asrt(count(R::taggedAll('coffee', '')), 0);
     asrt(count(R::taggedAll('coffee', 'sweet')), 1);
     asrt(count(R::taggedAll('coffee', 'sweet,strong')), 1);
     asrt(count(R::taggedAll('coffee', 'black,strong')), 2);
     asrt(count(R::taggedAll('coffee', array('black', 'strong'))), 2);
     asrt(count(R::taggedAll('coffee', 'salty')), 0);
     $blog = R::dispense('blog');
     $blog->title = 'testing';
     $blog->blog = 'tesing';
     R::store($blog);
     $blogpost = R::load("blog", 1);
     $post = R::dispense("post");
     $post->message = "hello";
     R::tag($post, "lousy,smart");
     asrt(implode(',', R::tag($post)), "lousy,smart");
     R::tag($post, "clever,smart");
     $tagz = implode(',', R::tag($post));
     asrt($tagz == "smart,clever" || $tagz == "clever,smart", TRUE);
     R::tag($blog, array("smart", "interesting"));
     asrt(implode(',', R::tag($blog)), "smart,interesting");
     try {
         R::tag($blog, array("smart", "interesting", "lousy!"));
         pass();
     } catch (RedBean_Exception $e) {
         fail();
     }
     asrt(implode(',', R::tag($blog)), "smart,interesting,lousy!");
     R::untag($blog, array("smart", "interesting"));
     asrt(implode(",", R::tag($blog)), "lousy!");
     asrt(R::hasTag($blog, array("lousy!")), TRUE);
     asrt(R::hasTag($blog, array("lousy!", "smart")), TRUE);
     asrt(R::hasTag($blog, array("lousy!", "smart"), TRUE), FALSE);
     R::tag($blog, FALSE);
     asrt(count(R::tag($blog)), 0);
     R::tag($blog, array("funny", "comic"));
     asrt(count(R::tag($blog)), 2);
     R::addTags($blog, array("halloween"));
     asrt(count(R::tag($blog)), 3);
     asrt(R::hasTag($blog, array("funny", "commic", "halloween"), TRUE), FALSE);
     R::unTag($blog, "funny");
     R::addTags($blog, "horror");
     asrt(count(R::tag($blog)), 3);
     asrt(R::hasTag($blog, array("horror", "commic", "halloween"), TRUE), FALSE);
     //no double tags
     R::addTags($blog, "horror");
     asrt(R::hasTag($blog, array("horror", "commic", "halloween"), TRUE), FALSE);
     asrt(R::hasTag($blog, "horror,commic,halloween", TRUE), FALSE);
     asrt(count(R::tag($blog)), 3);
     testpack("fetch tagged items");
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:65,代码来源:Tags.php


示例4: testNamedParamsInSnippets

 /**
  * Test usage of named parameters in SQL snippets.
  * Issue #299 on Github.
  *
  * @return void
  */
 public function testNamedParamsInSnippets()
 {
     testpack('Test whether we can use named parameters in SQL snippets.');
     R::nuke();
     $book = R::dispense('book');
     $page = R::dispense('page');
     $book->title = 'book';
     $book->sharedPage[] = $page;
     R::store($book);
     //should not give error like: Uncaught [HY093] - SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters
     $books = $page->withCondition(' title = :title ', array(':title' => 'book'))->sharedBook;
     asrt(count($books), 1);
     //should not give error...
     $books = $page->withCondition(' title = :title ', array(':title' => 'book'))->sharedBook;
     asrt(count($books), 1);
     R::nuke();
     $book = R::dispense('book');
     $page = R::dispense('page');
     $book->title = 'book';
     $book->comment = 'comment';
     $page->title = 'page';
     $book->ownPage[] = $page;
     R::store($book);
     //should also not give error..
     $count = $book->countOwn('page');
     asrt($count, 1);
     $book = $book->fresh();
     //should also not give error..
     $count = $book->withCondition(' title = ? ', array('page'))->countOwn('page');
     asrt($count, 1);
     $book = $book->fresh();
     //should also not give error..
     $count = $book->withCondition(' title = :title ', array(':title' => 'page'))->countOwn('page');
     asrt($count, 1);
     $book = $book->fresh();
     $pages = $book->withCondition(' title = :title ', array(':title' => 'page'))->ownPage;
     asrt(count($pages), 1);
     //test with duplicate slots...
     $page = reset($pages);
     $page2 = R::dispense('page');
     $page2->ownPage[] = $page;
     R::store($page2);
     $page2 = $page2->fresh();
     $pages = $page2->withCondition(' title = :title ', array(':title' => 'page'))->ownPage;
     asrt(count($pages), 1);
     //test with find()
     $books = R::getRedBean()->find('book', array('title' => array('book')), ' AND title = :title ', array(':title' => 'book'));
     asrt(count($books), 1);
     $books = R::getRedBean()->find('book', array('title' => array('book', 'book2'), 'comment' => array('comment', 'comment2')), ' AND title = :title ', array(':title' => 'book'));
     asrt(count($books), 1);
     //just check numeric works as well...
     $books = R::getRedBean()->find('book', array('title' => array('book', 'book2'), 'comment' => array('comment', 'comment2')), ' AND title = ? ', array('book'));
     asrt(count($books), 1);
     //just extra check to verify glue works
     $books = R::getRedBean()->find('book', array('title' => array('book', 'book2'), 'comment' => array('comment', 'comment2')), ' ORDER BY id ');
     asrt(count($books), 1);
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:63,代码来源:Namedparams.php


示例5: testMissingBeans

 /**
  * Test missing bean scenarios.
  * 
  * @return void
  */
 public function testMissingBeans()
 {
     testpack('deal with missing beans');
     $id = R::store(R::dispense('beer'));
     $bottles = R::batch('beer', array($id, $id + 1, $id + 2));
     asrt(count($bottles), 3);
     asrt((int) $bottles[$id]->id, (int) $id);
     asrt((int) $bottles[$id + 1]->id, 0);
     asrt((int) $bottles[$id + 2]->id, 0);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:15,代码来源:Batch.php


示例6: testLabels

 /**
  * Test basic labels.
  * 
  * @return void
  */
 public function testLabels()
 {
     testpack('Test Labels');
     $meals = R::dispenseLabels('meal', array('meat', 'fish', 'vegetarian'));
     asrt(is_array($meals), TRUE);
     asrt(count($meals), 3);
     foreach ($meals as $m) {
         asrt($m instanceof RedBean_OODBBean, TRUE);
     }
     $listOfMeals = implode(',', R::gatherLabels($meals));
     asrt($listOfMeals, 'fish,meat,vegetarian');
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:17,代码来源:Labels.php


示例7: testIssue259

 /**
  * Test to make sure stash cache works with recursively opening models
  * with FUSE.
  *
  * @return void
  */
 public function testIssue259()
 {
     testpack('Testing Issue #259 - Stash Cache breaks model delegation in open().');
     $mother = R::dispense('mother');
     $mother->desc = 'I am mother';
     R::store($mother);
     $child = R::dispense('child');
     $child->mother = $mother;
     $child->desc = 'I am child';
     $id = R::store($child);
     R::findOne('child', ' id = ?', array($id));
     R::find('child', ' id = ? ', array($id));
     R::load('child', $id);
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:20,代码来源:Issue259.php


示例8: testImportFromAndTainted

 /**
  * Test import from and tainted.
  * 
  * @return void
  */
 public function testImportFromAndTainted()
 {
     testpack('Test importFrom() and Tainted');
     $bean = R::dispense('bean');
     R::store($bean);
     $bean->name = 'abc';
     asrt($bean->getMeta('tainted'), TRUE);
     R::store($bean);
     asrt($bean->getMeta('tainted'), FALSE);
     $copy = R::dispense('bean');
     R::store($copy);
     $copy = R::load('bean', $copy->id);
     asrt($copy->getMeta('tainted'), FALSE);
     $copy->import(array('name' => 'xyz'));
     asrt($copy->getMeta('tainted'), TRUE);
     $copy->setMeta('tainted', FALSE);
     asrt($copy->getMeta('tainted'), FALSE);
     $copy->importFrom($bean);
     asrt($copy->getMeta('tainted'), TRUE);
     testpack('Test basic import() feature.');
     $bean = new RedBean_OODBBean();
     $bean->import(array("a" => 1, "b" => 2));
     asrt($bean->a, 1);
     asrt($bean->b, 2);
     $bean->import(array("a" => 3, "b" => 4), "a,b");
     asrt($bean->a, 3);
     asrt($bean->b, 4);
     $bean->import(array("a" => 5, "b" => 6), " a , b ");
     asrt($bean->a, 5);
     asrt($bean->b, 6);
     $bean->import(array("a" => 1, "b" => 2));
     testpack('Test inject() feature.');
     $coffee = R::dispense('coffee');
     $coffee->id = 2;
     $coffee->liquid = 'black';
     $cup = R::dispense('cup');
     $cup->color = 'green';
     // Pour coffee in cup
     $cup->inject($coffee);
     // Do we still have our own property?
     asrt($cup->color, 'green');
     // Did we pour the liquid in the cup?
     asrt($cup->liquid, 'black');
     // Id should not be transferred
     asrt($cup->id, 0);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:51,代码来源:Import.php


示例9: testDynamicPlugins

 /**
  * Test if we can dynamically extend the R-facade.
  * 
  * @return void
  */
 public function testDynamicPlugins()
 {
     testpack('Test dynamic plugins');
     //basic behaviour
     R::ext('makeTea', function () {
         return 'sorry cant do that!';
     });
     asrt(R::makeTea(), 'sorry cant do that!');
     //with parameters
     R::ext('multiply', function ($a, $b) {
         return $a * $b;
     });
     asrt(R::multiply(3, 4), 12);
     //can we call R inside?
     R::ext('singVersion', function () {
         return R::getVersion() . ' lalala !';
     });
     asrt(R::singVersion(), R::getVersion() . ' lalala !');
     //should also work with Facade
     asrt(Facade::singVersion(), R::getVersion() . ' lalala !');
     //test error handling
     try {
         R::ext('---', function () {
         });
         fail();
     } catch (RedException $e) {
         asrt($e->getMessage(), 'Plugin name may only contain alphanumeric characters.');
     }
     try {
         R::__callStatic('---', function () {
         });
         fail();
     } catch (RedException $e) {
         asrt($e->getMessage(), 'Plugin name may only contain alphanumeric characters.');
     }
     try {
         R::invalidMethod();
         fail();
     } catch (RedException $e) {
         asrt($e->getMessage(), 'Plugin \'invalidMethod\' does not exist, add this plugin using: R::ext(\'invalidMethod\')');
     }
 }
开发者ID:skullyframework,项目名称:skully,代码行数:47,代码来源:Plugins.php


示例10: testCountAndWipe

 /**
  * Test count and wipe.
  *
  * @return void
  */
 public function testCountAndWipe()
 {
     testpack("Test count and wipe");
     $page = R::dispense("page");
     $page->name = "ABC";
     R::store($page);
     $n1 = R::count("page");
     $page = R::dispense("page");
     $page->name = "DEF";
     R::store($page);
     $n2 = R::count("page");
     asrt($n1 + 1, $n2);
     R::wipe("page");
     asrt(R::count("page"), 0);
     asrt(R::getRedBean()->count("page"), 0);
     asrt(R::getRedBean()->count("kazoo"), 0);
     // non existing table
     R::freeze(TRUE);
     asrt(R::getRedBean()->count("kazoo"), 0);
     // non existing table
     R::freeze(FALSE);
     $page = R::dispense('page');
     $page->name = 'foo';
     R::store($page);
     $page = R::dispense('page');
     $page->name = 'bar';
     R::store($page);
     asrt(R::count('page', ' name = ? ', array('foo')), 1);
     // Now count something that does not exist, this should return 0. (just be polite)
     asrt(R::count('teapot', ' name = ? ', array('flying')), 0);
     asrt(R::count('teapot'), 0);
     $currentDriver = $this->currentlyActiveDriverID;
     // Some drivers don't support that many error codes.
     if ($currentDriver === 'mysql' || $currentDriver === 'postgres') {
         try {
             R::count('teaport', ' for tea ');
             fail();
         } catch (SQL $e) {
             pass();
         }
     }
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:47,代码来源:Count.php


示例11: testEmptyBean

 /**
  * Tests whether we can store an empty bean.
  * An empty bean has no properties, only ID. Normally we would
  * skip the ID field in an INSERT, this test forces the driver
  * to specify a value for the ID field. Different writers have to
  * use different values: Mysql uses NULL to insert a new auto-generated ID,
  * while Postgres has to use DEFAULT.
  */
 public function testEmptyBean()
 {
     testpack('Test Empty Bean Storage.');
     R::nuke();
     $bean = R::dispense('emptybean');
     $id = R::store($bean);
     asrt($id > 0, TRUE);
     asrt(R::count('emptybean'), 1);
     $bean = R::dispense('emptybean');
     $id = R::store($bean);
     asrt($id > 0, TRUE);
     asrt(R::count('emptybean'), 2);
     //also test in frozen mode
     R::freeze(TRUE);
     $bean = R::dispense('emptybean');
     $id = R::store($bean);
     asrt($id > 0, TRUE);
     asrt(R::count('emptybean'), 3);
     R::freeze(FALSE);
 }
开发者ID:skullyframework,项目名称:skully,代码行数:28,代码来源:Database.php


示例12: testParamBindingWithPostgres

 /**
  * Test parameter binding.
  * 
  * @return void
  */
 public function testParamBindingWithPostgres()
 {
     testpack("param binding pgsql");
     $page = R::dispense("page");
     $page->name = "abc";
     $page->number = 2;
     R::store($page);
     R::exec("insert into page (name) values(:name) ", array(":name" => "my name"));
     R::exec("insert into page (number) values(:one) ", array(":one" => 1));
     R::exec("insert into page (number) values(:one) ", array(":one" => "1"));
     R::exec("insert into page (number) values(:one) ", array(":one" => "1234"));
     R::exec("insert into page (number) values(:one) ", array(":one" => "-21"));
     pass();
     testpack('Test whether we can properly bind and receive NULL values');
     $adapter = R::$adapter;
     asrt($adapter->getCell('SELECT TEXT( :nil ) ', array(':nil' => 'NULL')), 'NULL');
     asrt($adapter->getCell('SELECT TEXT( :nil ) ', array(':nil' => NULL)), NULL);
     asrt($adapter->getCell('SELECT TEXT( ? ) ', array('NULL')), 'NULL');
     asrt($adapter->getCell('SELECT TEXT( ? ) ', array(NULL)), NULL);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:25,代码来源:Parambind.php


示例13: testIssue303

 /**
  * Test whether we have two different exception messages for
  * properties and values.
  *
  * @return void
  */
 public function testIssue303()
 {
     testpack('Testing Issue #303 - Test splitting bean exception property/value.');
     try {
         R::store(R::dispense('invalidbean')->setAttr('invalid.property', 'value'));
         fail();
     } catch (RedException $e) {
         asrt($e->getMessage(), 'Invalid Bean property: property invalid.property');
     }
     try {
         R::store(R::dispense('invalidbean')->setAttr('property', array()));
         fail();
     } catch (RedException $e) {
         asrt($e->getMessage(), 'Invalid Bean value: property property');
     }
     try {
         R::store(R::dispense('invalidbean')->setAttr('property', new \stdClass()));
         fail();
     } catch (RedException $e) {
         asrt($e->getMessage(), 'Invalid Bean value: property property');
     }
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:28,代码来源:Issue303.php


示例14: testParamBindWithSQLite

 /**
  * Test parameter binding with SQLite.
  * 
  * @return void
  */
 public function testParamBindWithSQLite()
 {
     $toolbox = R::$toolbox;
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     asrt((int) $adapter->getCell("SELECT 123"), 123);
     asrt((int) $adapter->getCell("SELECT ?", array("987")), 987);
     asrt((int) $adapter->getCell("SELECT ?+?", array("987", "2")), 989);
     asrt((int) $adapter->getCell("SELECT :numberOne+:numberTwo", array(":numberOne" => 42, ":numberTwo" => 50)), 92);
     $pair = $adapter->getAssoc("SELECT 'thekey','thevalue' ");
     asrt(is_array($pair), TRUE);
     asrt(count($pair), 1);
     asrt(isset($pair["thekey"]), TRUE);
     asrt($pair["thekey"], "thevalue");
     testpack('Test whether we can properly bind and receive NULL values');
     asrt($adapter->getCell('SELECT :nil ', array(':nil' => 'NULL')), 'NULL');
     asrt($adapter->getCell('SELECT :nil ', array(':nil' => NULL)), NULL);
     asrt($adapter->getCell('SELECT ? ', array('NULL')), 'NULL');
     asrt($adapter->getCell('SELECT ? ', array(NULL)), NULL);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:27,代码来源:Parambind.php


示例15: testMetaData

 /**
  * Test meta data methods.
  * 
  * @return void
  */
 public function testMetaData()
 {
     testpack('Test meta data');
     $bean = new RedBean_OODBBean();
     $bean->setMeta("this.is.a.custom.metaproperty", "yes");
     asrt($bean->getMeta("this.is.a.custom.metaproperty"), "yes");
     asrt($bean->getMeta("nonexistant"), NULL);
     asrt($bean->getMeta("nonexistant", "abc"), "abc");
     asrt($bean->getMeta("nonexistant.nested"), NULL);
     asrt($bean->getMeta("nonexistant,nested", "abc"), "abc");
     $bean->setMeta("test.two", "second");
     asrt($bean->getMeta("test.two"), "second");
     $bean->setMeta("another.little.property", "yes");
     asrt($bean->getMeta("another.little.property"), "yes");
     asrt($bean->getMeta("test.two"), "second");
     // Copy Metadata
     $bean = new RedBean_OODBBean();
     $bean->setMeta("meta.meta", "123");
     $bean2 = new RedBean_OODBBean();
     asrt($bean2->getMeta("meta.meta"), NULL);
     $bean2->copyMetaFrom($bean);
     asrt($bean2->getMeta("meta.meta"), "123");
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:28,代码来源:Meta.php


示例16: asrt

 asrt(setget("a"), "a");
 asrt(setget("."), ".");
 asrt(setget("\""), "\"");
 asrt(setget("just some text"), "just some text");
 asrt(setget(true), "1");
 asrt(setget(false), "0");
 asrt(setget("true"), "true");
 asrt(setget("false"), "false");
 asrt(setget("null"), "null");
 asrt(setget("NULL"), "NULL");
 asrt(setget(null), null);
 asrt(setget(0) == 0, true);
 asrt(setget(1) == 1, true);
 asrt(setget(true) == true, true);
 asrt(setget(false) == false, true);
 testpack("test views");
 class Fm implements RedBean_IBeanFormatter
 {
     public function formatBeanTable($table)
     {
         return "prefix_{$table}";
     }
     public function formatBeanID($table)
     {
         return $table . "__id";
     }
     public function getAlias($a)
     {
         return '__';
     }
 }
开发者ID:ryjkov,项目名称:redbean,代码行数:31,代码来源:pgtest.php


示例17: testSpecialDataTypes

 /**
  * Test special data types.
  *
  * @return void
  */
 public function testSpecialDataTypes()
 {
     testpack('Special data types');
     $bean = R::dispense('bean');
     $bean->date = 'someday';
     R::store($bean);
     $cols = R::getColumns('bean');
     asrt($cols['date'], 'TEXT');
     $bean = R::dispense('bean');
     $bean->date = '2011-10-10';
     R::nuke();
     $bean = R::dispense('bean');
     $bean->date = '2011-10-10';
     R::store($bean);
     $cols = R::getColumns('bean');
     asrt($cols['date'], 'NUMERIC');
 }
开发者ID:cesium147,项目名称:redbean,代码行数:22,代码来源:Writer.php


示例18: testTypes

 /**
  * Test special types.
  *
  * @return void
  */
 public function testTypes()
 {
     testpack('Special data types');
     $bean = R::dispense('bean');
     $bean->date = 'someday';
     R::store($bean);
     $cols = R::getColumns('bean');
     asrt($cols['date'], 'text');
     $bean = R::dispense('bean');
     $bean->date = '2011-10-10';
     R::store($bean);
     $cols = R::getColumns('bean');
     asrt($cols['date'], 'text');
 }
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:19,代码来源:Writer.php


示例19: testpack

<?php

/**
 * Pretest
 *
 * These tests will run before the configuration takes place
 * in the unit test suite (mostly error handling tests).
 *
 * @file    RedUNIT/Pretest.php
 * @desc    Test scripts that run before configuration
 * @author  Gabor de Mooij and the RedBeanPHP Community
 * @license New BSD/GPLv2
 *
 * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
 * This source file is subject to the New BSD/GPLv2 License that is bundled
 * with this source code in the file license.txt.
 */
testpack('Running pre-tests. (before config).');
try {
    R::debug(TRUE);
    fail();
} catch (Exception $e) {
    pass();
}
asrt(R::testConnection(), FALSE);
R::addDatabase('broken', 'mysql:host=nowhere', 'defunct', 'void');
R::selectDatabase('broken');
asrt(R::testConnection(), FALSE);
开发者ID:diego-vieira,项目名称:redbean,代码行数:28,代码来源:Pretest.php


示例20: testSingleColUniqueConstraint

 /**
  * Test single column bases unique constraints.
  * 
  * @return void
  */
 public function testSingleColUniqueConstraint()
 {
     testpack('Testing unique constraint on single column');
     //mysql cant handle this due to utf8mb4 fuckup Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
     if ($this->currentlyActiveDriverID === 'mysql') {
         return;
     }
     $book = R::dispense('book');
     $book->setMeta('buildcommand.unique', array(array('title')));
     $book->title = 'bla';
     $book->extra = 2;
     $id = R::store($book);
     $book = R::dispense('book');
     $book->title = 'bla';
     $expected = NULL;
     try {
         R::store($book);
         fail();
     } catch (RedBean_Exception_SQL $e) {
         $expected = $e;
     }
     asrt($expected instanceof RedBean_Exception_SQL, TRUE);
     asrt(R::count('book'), 1);
     $book = R::load('book', $id);
     // Causes failure, table will be rebuild
     $book->extra = 'CHANGE';
     $id2 = R::store($book);
     $book2 = R::load('book', $id2);
     $book = R::dispense('book');
     $book->title = 'bla';
     try {
         R::store($book);
         fail();
     } catch (RedBean_Exception_SQL $e) {
         $expected = $e;
     }
     asrt($expected instanceof RedBean_Exception_SQL, TRUE);
     asrt(R::count('book'), 1);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:44,代码来源:Association.php



注:本文中的testpack函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP tests_add_filter函数代码示例发布时间:2022-05-23
下一篇:
PHP testlinkInitPage函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap