当前位置: 首页>>代码示例>>PHP>>正文


PHP R::nuke方法代码示例

本文整理汇总了PHP中R::nuke方法的典型用法代码示例。如果您正苦于以下问题:PHP R::nuke方法的具体用法?PHP R::nuke怎么用?PHP R::nuke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在R的用法示例。


在下文中一共展示了R::nuke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:daviddeutsch,项目名称:redbean-adaptive,代码行数:62,代码来源:Typechecking.php

示例2: testCreate

 public function testCreate()
 {
     \R::nuke();
     $this->user->create($this->email, $this->username, $this->password, $this->password);
     $id = $this->user->unbox()->id;
     $this->assertEquals(1, $id);
 }
开发者ID:dazmiller,项目名称:red4,代码行数:7,代码来源:UserTest.php

示例3: testExtAssoc

 /**
  * Test extended associations.
  * 
  * @return void
  */
 public function testExtAssoc()
 {
     $toolbox = R::$toolbox;
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     R::nuke();
     $webpage = $redbean->dispense("webpage");
     $webpage->title = "page with ads";
     $ad = $redbean->dispense("ad");
     $ad->title = "buy this!";
     $top = $redbean->dispense("placement");
     $top->position = "top";
     $bottom = $redbean->dispense("placement");
     $bottom->position = "bottom";
     $ea = new RedBean_AssociationManager_ExtAssociationManager($toolbox);
     $ea->extAssociate($ad, $webpage, $top);
     $ads = $redbean->batch("ad", $ea->related($webpage, "ad"));
     $adsPos = $redbean->batch("ad_webpage", $ea->related($webpage, "ad", TRUE));
     asrt(count($ads), 1);
     asrt(count($adsPos), 1);
     $theAd = array_pop($ads);
     $theAdPos = array_pop($adsPos);
     asrt($theAd->title, $ad->title);
     asrt($theAdPos->position, $top->position);
     $ad2 = $redbean->dispense("ad");
     $ad2->title = "buy this too!";
     $ea->extAssociate($ad2, $webpage, $bottom);
     $ads = $redbean->batch("ad", $ea->related($webpage, "ad", TRUE));
     asrt(count($ads), 2);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:37,代码来源:Extassoc.php

示例4: prepare

 /**
  * @BeforeSuite
  */
 public static function prepare(SuiteEvent $event)
 {
     // prepare system for test suite
     // before it runs
     $config = json_decode(file_get_contents(__DIR__ . "/../../.config/database.json"));
     R::setup($config->driver . ':host=' . $config->host . ';dbname=' . $config->dbname, $config->user, $config->pass);
     R::nuke();
 }
开发者ID:renomx,项目名称:apistarter,代码行数:11,代码来源:FeatureContext.php

示例5: tearDown

 function tearDown()
 {
     // Must use nuke() to clear caches etc.
     R::nuke();
     R::close();
     $this->bbs = NULL;
     system("rm -rf " . self::DATA);
 }
开发者ID:chrispoupart,项目名称:BicBucStriim,代码行数:8,代码来源:test_bicbucstriim.php

示例6: testVaria

 /**
  * Various tests for OCI.
  * 
  * @return void
  */
 public function testVaria()
 {
     $toolbox = R::$toolbox;
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $page = $redbean->dispense("page");
     try {
         $adapter->exec("an invalid query");
         fail();
     } catch (RedBean_Exception_SQL $e) {
         pass();
     }
     asrt((int) $adapter->getCell("SELECT 123 FROM DUAL"), 123);
     $page->aname = "my page";
     $id = (int) $redbean->store($page);
     asrt((int) $page->id, 1);
     asrt((int) $pdo->GetCell("SELECT count(*) FROM page"), 1);
     asrt($pdo->GetCell("SELECT aname FROM page WHERE ROWNUM<=1"), "my page");
     asrt((int) $id, 1);
     $page = $redbean->load("page", 1);
     asrt($page->aname, "my page");
     asrt((bool) $page->getMeta("type"), TRUE);
     asrt(isset($page->id), TRUE);
     asrt($page->getMeta("type"), "page");
     asrt((int) $page->id, $id);
     R::nuke();
     $rooms = R::dispense('room', 2);
     $rooms[0]->kind = 'suite';
     $rooms[1]->kind = 'classic';
     $rooms[0]->number = 6;
     $rooms[1]->number = 7;
     R::store($rooms[0]);
     R::store($rooms[1]);
     $rooms = R::getAssoc('SELECT ' . R::$writer->esc('number') . ', kind FROM room ORDER BY kind ASC');
     foreach ($rooms as $key => $room) {
         asrt($key === 6 || $key === 7, TRUE);
         asrt($room == 'classic' || $room == 'suite', TRUE);
     }
     $rooms = R::$adapter->getAssoc('SELECT kind FROM room');
     foreach ($rooms as $key => $room) {
         asrt($room == 'classic' || $room == 'suite', TRUE);
         asrt($room, $key);
     }
     $rooms = R::getAssoc('SELECT ' . R::$writer->esc('number') . ', kind FROM rooms2 ORDER BY kind ASC');
     asrt(count($rooms), 0);
     asrt(is_array($rooms), TRUE);
     $date = R::dispense('mydate');
     $date->date = '2012-12-12 20:50';
     $date->time = '12:15';
     $id = R::store($date);
     $ok = R::load('mydate', 1);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:59,代码来源:Database.php

示例7: run

 /**
  * Begin testing.
  * This method runs the actual test pack.
  * 
  * @return void
  */
 public function run()
 {
     R::nuke();
     file_put_contents('/tmp/test_log.txt', '');
     R::log('/tmp/test_log.txt');
     $bean = R::dispense('bean');
     $bean->name = TRUE;
     R::store($bean);
     $bean->name = 'test';
     R::store($bean);
     $log = file_get_contents('/tmp/test_log.txt');
     asrt(strlen($log) > 0, TRUE);
     echo $log;
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:20,代码来源:Timeline.php

示例8: testInspect

 /**
  * Tests the R::inspect() method on the Facade.
  *
  * @return void
  */
 public function testInspect()
 {
     testpack('Test R::inspect() ');
     R::nuke();
     R::store(R::graph(array('type' => 'book', 'title' => 'book')));
     $info = R::inspect();
     asrt(count($info), 1);
     asrt(strtolower($info[0]), 'book');
     $info = R::inspect('book');
     asrt(count($info), 2);
     $keys = array_keys($info);
     sort($keys);
     asrt(strtolower($keys[0]), 'id');
     asrt(strtolower($keys[1]), 'title');
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:20,代码来源:Misc.php

示例9: testNuke

 /**
  * Nuclear test suite.
  * 
  * @return void
  */
 public function testNuke()
 {
     $bean = R::dispense('bean');
     R::store($bean);
     asrt(count(R::$writer->getTables()), 1);
     R::nuke();
     asrt(count(R::$writer->getTables()), 0);
     $bean = R::dispense('bean');
     R::store($bean);
     asrt(count(R::$writer->getTables()), 1);
     R::freeze();
     R::nuke();
     // No effect
     asrt(count(R::$writer->getTables()), 1);
     R::freeze(FALSE);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:21,代码来源:Nuke.php

示例10: 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:daviddeutsch,项目名称:redbean-adaptive,代码行数:28,代码来源:Database.php

示例11: testKeywords

 /**
  * Test if RedBeanPHP can properly handle keywords.
  * 
  * @return void
  */
 public function testKeywords()
 {
     $keywords = array('anokeyword', 'znokeyword', 'group', 'DROP', 'inner', 'JOIN', 'select', 'table', 'int', 'cascade', 'float', 'CALL', 'in', 'status', 'order', 'limit', 'having', 'else', 'if', 'while', 'distinct', 'like');
     R::setStrictTyping(FALSE);
     RedBean_OODBBean::setFlagBeautifulColumnNames(FALSE);
     foreach ($keywords as $k) {
         R::nuke();
         $bean = R::dispense($k);
         $bean->{$k} = $k;
         $id = R::store($bean);
         $bean = R::load($k, $id);
         $bean2 = R::dispense('other');
         $bean2->name = $k;
         $bean->bean = $bean2;
         $bean->ownBean[] = $bean2;
         $bean->sharedBean[] = $bean2;
         $id = R::store($bean);
         R::trash($bean);
         pass();
     }
     RedBean_OODBBean::setFlagBeautifulColumnNames(TRUE);
     R::setStrictTyping(TRUE);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:28,代码来源:Keywords.php

示例12: testMySQL

 /**
  * MySQL specific tests.
  * 
  * @return void
  */
 public function testMySQL()
 {
     if ($this->currentlyActiveDriverID !== 'mysql') {
         return;
     }
     testpack('Throw exception in case of issue with assoc constraint');
     $bunny = R::dispense('bunny');
     $carrot = R::dispense('carrot');
     $faultyWriter = new FaultyWriter(R::$toolbox->getDatabaseAdapter());
     $faultyToolbox = new RedBean_ToolBox(R::$toolbox->getRedBean(), R::$toolbox->getDatabaseAdapter(), $faultyWriter);
     $faultyAssociationManager = new RedBean_AssociationManager($faultyToolbox);
     $faultyWriter->setSQLState('23000');
     $faultyAssociationManager->associate($bunny, $carrot);
     pass();
     $faultyWriter->setSQLState('42S22');
     R::nuke();
     try {
         $faultyAssociationManager->associate($bunny, $carrot);
         fail();
     } catch (RedBean_Exception_SQL $exception) {
         pass();
     }
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:28,代码来源:Association.php

示例13: droptables

function droptables()
{
    global $nukepass;
    R::nuke();
    if (!count($t = R::$writer->getTables())) {
        $nukepass++;
    } else {
        echo "\nFailed to clean up database: " . print_r($t, 1);
        fail();
    }
    return;
    if ($db == 'mysql') {
        R::exec('SET FOREIGN_KEY_CHECKS=0;');
    }
    if ($db == 'sqlite') {
        R::exec('PRAGMA foreign_keys = 0 ');
    }
    R::exec('drop view if exists people');
    R::exec('drop view if exists library2');
    foreach (R::$writer->getTables() as $t) {
        if ($db == 'mysql') {
            R::exec("drop table `{$t}`");
        }
        if ($db == 'pgsql') {
            R::exec("drop table \"{$t}\" cascade");
        }
        if ($db == 'sqlite') {
            R::exec("drop table {$t} ");
        }
    }
    if ($db == 'mysql') {
        R::exec('SET FOREIGN_KEY_CHECKS=1;');
    }
    if ($db == 'sqlite') {
        R::exec('PRAGMA foreign_keys = 1 ');
    }
}
开发者ID:ryjkov,项目名称:redbean,代码行数:37,代码来源:n1test.php

示例14: testBoxing

 /**
  * Test boxing beans.
  * 
  * @return void
  */
 public function testBoxing()
 {
     R::nuke();
     $bean = R::dispense('boxedbean')->box();
     R::trash($bean);
     pass();
     $bean = R::dispense('boxedbean');
     $bean->sharedBoxbean = R::dispense('boxedbean')->box();
     R::store($bean);
     pass();
     $bean = R::dispense('boxedbean');
     $bean->ownBoxedbean = R::dispense('boxedbean')->box();
     R::store($bean);
     pass();
     $bean = R::dispense('boxedbean');
     $bean->other = R::dispense('boxedbean')->box();
     R::store($bean);
     pass();
     $bean = R::dispense('boxedbean');
     $bean->title = 'MyBean';
     $box = $bean->box();
     asrt($box instanceof Model_Boxedbean, TRUE);
     R::store($box);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:29,代码来源:Boxing.php

示例15: run

 /**
  * Run the actual test
  */
 public function run()
 {
     $class = new ReflectionClass($this);
     $skip = array('run', 'getTargetDrivers', 'onEvent');
     // Call all methods except run automatically
     foreach ($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
         // Skip methods inherited from parent class
         if ($method->class != $class->getName()) {
             continue;
         }
         if (in_array($method->name, $skip)) {
             continue;
         }
         $classname = str_replace($class->getParentClass()->getName() . '_', '', $method->class);
         printtext("\n\t" . $classname . "->" . $method->name . " [" . $method->class . "->" . $method->name . "]" . " \n\t");
         $call = $method->name;
         $this->{$call}();
         try {
             R::nuke();
         } catch (PDOException $e) {
             // Some tests use a broken database on purpose, so an exception is ok
         }
     }
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:27,代码来源:RedUNIT.php


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