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


PHP Facade::getRedBean方法代码示例

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


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

示例1: 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

示例2: testCustomBeanHelper

 /**
  * Test whether we can override the getModelForBean() method
  * of the BeanHelper and use a custom BeanHelper to attach a model
  * based on type.
  *
  * @return void
  */
 public function testCustomBeanHelper()
 {
     $customBeanHelper = new \SoupBeanHelper(R::getToolbox());
     $oldBeanHelper = R::getRedBean()->getBeanHelper();
     asrt($oldBeanHelper instanceof SimpleFacadeBeanHelper, TRUE);
     R::getRedBean()->setBeanHelper($customBeanHelper);
     $meal = R::dispense('meal');
     asrt($meal->box() instanceof \Model_Soup, TRUE);
     $cake = R::dispense('cake');
     asrt(is_null($cake->box()), TRUE);
     $bean = R::dispense('coffee');
     asrt($bean->box() instanceof \Model_Coffee, TRUE);
     $meal->setFlavour('tomato');
     asrt($meal->getFlavour(), 'tomato');
     $meal->rating = 5;
     R::store($meal);
     asrt($meal->getFlavour(), 'tomato');
     $meal = $meal->unbox();
     asrt($meal->getFlavour(), 'tomato');
     $meal = R::findOne('meal');
     asrt($meal->box() instanceof \Model_Soup, TRUE);
     asrt($meal->getFlavour(), '');
     $meal->setFlavour('tomato');
     asrt($meal->getFlavour(), 'tomato');
     $meal = $meal->unbox();
     asrt($meal->getFlavour(), 'tomato');
     R::getRedBean()->setBeanHelper($oldBeanHelper);
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:35,代码来源:Fuse.php

示例3: 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

示例4: testDispenseArray

 /**
  * Tests different return values of dispense().
  *
  * @return void
  */
 public function testDispenseArray()
 {
     $oodb = R::getRedBean();
     $array = $oodb->dispense('book', 0, TRUE);
     asrt(is_array($array), TRUE);
     $array = $oodb->dispense('book', 1, TRUE);
     asrt(is_array($array), TRUE);
     $array = $oodb->dispense('book', 2, TRUE);
     asrt(is_array($array), TRUE);
     $array = R::dispense('book', 0, TRUE);
     asrt(is_array($array), TRUE);
     $array = R::dispense('book', 1, TRUE);
     asrt(is_array($array), TRUE);
     $array = R::dispense('book', 2, TRUE);
     asrt(is_array($array), TRUE);
     $array = $oodb->dispense('book', 0, FALSE);
     asrt(is_array($array), FALSE);
     asrt(is_null($array), TRUE);
     $array = $oodb->dispense('book', 1, FALSE);
     asrt(is_array($array), FALSE);
     asrt($array instanceof OODBBean, TRUE);
     $array = $oodb->dispense('book', 2, FALSE);
     asrt(is_array($array), TRUE);
     $array = R::dispense('book', 0, FALSE);
     asrt(is_array($array), FALSE);
     $array = R::dispense('book', 1, FALSE);
     asrt(is_array($array), FALSE);
     $array = R::dispense('book', 2, FALSE);
     asrt(is_array($array), TRUE);
     $array = $oodb->dispense('book', 0);
     asrt(is_array($array), FALSE);
     asrt(is_null($array), TRUE);
     $array = $oodb->dispense('book', 1);
     asrt(is_array($array), FALSE);
     asrt($array instanceof OODBBean, TRUE);
     $array = $oodb->dispense('book', 2);
     asrt(is_array($array), TRUE);
     $array = R::dispense('book', 0);
     asrt(is_array($array), FALSE);
     $array = R::dispense('book', 1);
     asrt(is_array($array), FALSE);
     $array = R::dispense('book', 2);
     asrt(is_array($array), TRUE);
 }
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:49,代码来源:Dispense.php

示例5: function

<?php

namespace RedUNIT\Base;

use RedUNIT\Base;
use RedBeanPHP\Facade as R;
use RedBeanPHP\OODBBean;
use RedBeanPHP\QueryWriter\AQueryWriter;
R::ext('xdispense', function ($type) {
    return R::getRedBean()->dispense($type);
});
define('BOOK', 'tbl_book');
define('AUTHOR', 'tbl_author');
define('COAUTHOR', 'coAuthor');
define('FRIEND', 'tbl_friend');
define('PUBLISHER', 'tbl_publisher');
define('BOOKLIST', 'ownTbl_book');
define('FRIENDLIST', 'sharedTbl_friend');
/**
 * Prefixes
 *
 * @file    RedUNIT/Base/Prefixes.php
 * @desc    Tests whether you can use RedBeanPHP with table prefixes.
 * @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.
 */
class Prefixes extends Base
开发者ID:diego-vieira,项目名称:redbean,代码行数:31,代码来源:Prefixes.php

示例6: testWideningColumnForConstraint

 /**
  * Test widen for constraint.
  *
  * @return void
  */
 public function testWideningColumnForConstraint()
 {
     testpack('widening column for constraint');
     $bean1 = R::dispense('project');
     $bean2 = R::dispense('invoice');
     $bean3 = R::getRedBean()->dispense('invoice_project');
     $bean3->project_id = false;
     $bean3->invoice_id = true;
     R::store($bean3);
     $cols = R::getColumns('invoice_project');
     asrt($cols['project_id'], "int(11) unsigned");
     asrt($cols['invoice_id'], "int(11) unsigned");
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:18,代码来源:Foreignkeys.php

示例7: testBeautifulColumnNames

 /**
  * Test beautification of column names.
  *
  * @return void
  */
 public function testBeautifulColumnNames()
 {
     testpack('Beautiful column names');
     $town = R::dispense('town');
     $town->isCapital = FALSE;
     $town->hasTrainStation = TRUE;
     $town->name = 'BeautyVille';
     $houses = R::dispense('house', 2);
     $houses[0]->isForSale = TRUE;
     $town->ownHouse = $houses;
     R::store($town);
     $town = R::load('town', $town->id);
     asrt($town->isCapital == FALSE, TRUE);
     asrt($town->hasTrainStation == TRUE, TRUE);
     asrt($town->name == 'BeautyVille', TRUE);
     testpack('Accept datetime objects.');
     $cal = R::dispense('calendar');
     $cal->when = new \DateTime('2000-01-01', new \DateTimeZone('Pacific/Nauru'));
     asrt($cal->when, '2000-01-01 00:00:00');
     testpack('Affected rows test');
     $currentDriver = $this->currentlyActiveDriverID;
     $toolbox = R::getToolBox();
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $bean = $redbean->dispense('bean');
     $bean->prop = 3;
     //make test run with strict mode as well
     $redbean->store($bean);
     $adapter->exec('UPDATE bean SET prop = 2');
     asrt($adapter->getAffectedRows(), 1);
     testpack('Testing Logger');
     R::getDatabaseAdapter()->getDatabase()->setLogger(new RDefault());
     asrt(R::getDatabaseAdapter()->getDatabase()->getLogger() instanceof Logger, TRUE);
     asrt(R::getDatabaseAdapter()->getDatabase()->getLogger() instanceof RDefault, TRUE);
     $bean = R::dispense('bean');
     $bean->property = 1;
     $bean->unsetAll(array('property'));
     asrt($bean->property, NULL);
     asrt($bean->setAttr('property', 2) instanceof OODBBean, TRUE);
     asrt($bean->property, 2);
     asrt(preg_match('/\\d\\d\\d\\d\\-\\d\\d\\-\\d\\d/', R::isoDate()), 1);
     asrt(preg_match('/\\d\\d\\d\\d\\-\\d\\d\\-\\d\\d\\s\\d\\d:\\d\\d:\\d\\d/', R::isoDateTime()), 1);
     $redbean = R::getRedBean();
     $adapter = R::getDatabaseAdapter();
     $writer = R::getWriter();
     asrt($redbean instanceof OODB, TRUE);
     asrt($adapter instanceof Adapter, TRUE);
     asrt($writer instanceof QueryWriter, TRUE);
     R::setRedBean($redbean);
     pass();
     //cant really test this
     R::setDatabaseAdapter($adapter);
     pass();
     //cant really test this
     R::setWriter($writer);
     pass();
     //cant really test this
     $u1 = R::dispense('user');
     $u1->name = 'Gabor';
     $u1->login = 'g';
     $u2 = R::dispense('user');
     $u2->name = 'Eric';
     $u2->login = 'e';
     R::store($u1);
     R::store($u2);
     $list = R::getAssoc('select login,' . R::getWriter()->esc('name') . ' from ' . R::getWriter()->esc('user') . ' ');
     asrt($list['e'], 'Eric');
     asrt($list['g'], 'Gabor');
     $painting = R::dispense('painting');
     $painting->name = 'Nighthawks';
     $id = R::store($painting);
     testpack('Testing SQL Error Types');
     foreach ($writer->typeno_sqltype as $code => $text) {
         asrt(is_integer($code), TRUE);
         asrt(is_string($text), TRUE);
     }
     foreach ($writer->sqltype_typeno as $text => $code) {
         asrt(is_integer($code), TRUE);
         asrt(is_string($text), TRUE);
     }
     testpack('Testing Nowhere Pt. 1 (unfrozen)');
     foreach (array('exec', 'getAll', 'getCell', 'getAssoc', 'getRow', 'getCol') as $method) {
         R::$method('select * from nowhere');
         pass();
     }
     testpack('Testing Nowhere Pt. 2 (frozen)');
     R::freeze(TRUE);
     foreach (array('exec', 'getAll', 'getCell', 'getAssoc', 'getRow', 'getCol') as $method) {
         try {
             R::$method('select * from nowhere');
             fail();
         } catch (SQL $e) {
             pass();
//.........这里部分代码省略.........
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:101,代码来源:Misc.php

示例8: testCommonUsageFacade

 /**
  * Test common Facade usage scenarios.
  *
  * @return void
  */
 public function testCommonUsageFacade()
 {
     $toolbox = R::getToolBox();
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $a = new AssociationManager($toolbox);
     asrt(R::getRedBean() instanceof OODB, TRUE);
     asrt(R::getToolBox() instanceof ToolBox, TRUE);
     asrt(R::getDatabaseAdapter() instanceof Adapter, TRUE);
     asrt(R::getWriter() instanceof QueryWriter, TRUE);
     $book = R::dispense("book");
     asrt($book instanceof OODBBean, TRUE);
     $book->title = "a nice book";
     $id = R::store($book);
     asrt($id > 0, TRUE);
     $book = R::load("book", (int) $id);
     asrt($book->title, "a nice book");
     asrt(R::load('book', 999)->title, NULL);
     R::freeze(TRUE);
     try {
         R::load('bookies', 999);
         fail();
     } catch (\Exception $e) {
         pass();
     }
     R::freeze(FALSE);
     $author = R::dispense("author");
     $author->name = "me";
     R::store($author);
     $book9 = R::dispense("book");
     $author9 = R::dispense("author");
     $author9->name = "mr Nine";
     $a9 = R::store($author9);
     $book9->author_id = $a9;
     $bk9 = R::store($book9);
     $book9 = R::load("book", $bk9);
     $author = R::load("author", $book9->author_id);
     asrt($author->name, "mr Nine");
     R::trash($author);
     R::trash($book9);
     pass();
     $book2 = R::dispense("book");
     $book2->title = "second";
     R::store($book2);
     $book3 = R::dispense("book");
     $book3->title = "third";
     R::store($book3);
     asrt(count(R::find("book")), 3);
     asrt(count(R::findAll("book")), 3);
     asrt(count(R::findAll("book", " LIMIT 2")), 2);
     asrt(count(R::find("book", " id=id ")), 3);
     asrt(count(R::find("book", " title LIKE ?", array("third"))), 1);
     asrt(count(R::find("book", " title LIKE ?", array("%d%"))), 2);
     // Find without where clause
     asrt(count(R::findAll('book', ' order by id')), 3);
     R::trash($book3);
     R::trash($book2);
     asrt(count(R::getAll("SELECT * FROM book ")), 1);
     asrt(count(R::getCol("SELECT title FROM book ")), 1);
     asrt((int) R::getCell("SELECT 123 "), 123);
     $book = R::dispense("book");
     $book->title = "not so original title";
     $author = R::dispense("author");
     $author->name = "Bobby";
     R::store($book);
     $aid = R::store($author);
     $author = R::findOne("author", " name = ? ", array("Bobby"));
 }
开发者ID:cesium147,项目名称:redbean,代码行数:75,代码来源:Facade.php

示例9: testChillTest

 /**
  * Test whether we can set and reset the chill list and check the contents
  * of the chill list.
  *
  * @return void
  */
 public function testChillTest()
 {
     R::freeze(array('beer'));
     $oodb = R::getRedBean();
     asrt($oodb->isChilled('beer'), TRUE);
     asrt($oodb->isChilled('wine'), FALSE);
     R::freeze(FALSE);
     $oodb = R::getRedBean();
     asrt($oodb->isChilled('beer'), TRUE);
     asrt($oodb->isChilled('wine'), FALSE);
     R::freeze(TRUE);
     $oodb = R::getRedBean();
     asrt($oodb->isChilled('beer'), TRUE);
     asrt($oodb->isChilled('wine'), FALSE);
     R::freeze(array());
     $oodb = R::getRedBean();
     asrt($oodb->isChilled('beer'), FALSE);
     asrt($oodb->isChilled('wine'), FALSE);
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:25,代码来源:Chill.php

示例10: testRepoSwitching

 /**
  * Tests whether freeze() switches the repository object
  * as it is supposed to do.
  *
  * @return void
  */
 public function testRepoSwitching()
 {
     asrt(class_exists('RedBeanPHP\\Repository'), TRUE);
     asrt(class_exists('RedBeanPHP\\Repository\\Fluid'), TRUE);
     asrt(class_exists('RedBeanPHP\\Repository\\Frozen'), TRUE);
     R::freeze(FALSE);
     $redbean = R::getRedBean();
     $repo = $redbean->getCurrentRepository();
     asrt(is_object($repo), TRUE);
     asrt($repo instanceof Repository, TRUE);
     asrt($repo instanceof FluidRepo, TRUE);
     R::freeze(TRUE);
     $fluid = $repo;
     $repo = $redbean->getCurrentRepository();
     asrt(is_object($repo), TRUE);
     asrt($repo instanceof Repository, TRUE);
     asrt($repo instanceof FrozenRepo, TRUE);
     $frozen = $repo;
     R::freeze(FALSE);
     $redbean = R::getRedBean();
     $repo = $redbean->getCurrentRepository();
     asrt(is_object($repo), TRUE);
     asrt($repo instanceof Repository, TRUE);
     asrt($repo instanceof FluidRepo, TRUE);
     asrt($repo, $fluid);
     R::freeze(TRUE);
     $fluid = $repo;
     $repo = $redbean->getCurrentRepository();
     asrt(is_object($repo), TRUE);
     asrt($repo instanceof Repository, TRUE);
     asrt($repo instanceof FrozenRepo, TRUE);
     asrt($repo, $frozen);
     R::freeze(FALSE);
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:40,代码来源:Toolbox.php

示例11: testExportAll

 /**
  * ExportAll.
  *
  * @return void
  */
 public function testExportAll()
 {
     testpack('Test exportAll');
     $redbean = R::getRedBean();
     $bean = new OODBBean();
     $bean->import(array("a" => 1, "b" => 2));
     $bean->setMeta("justametaproperty", "hellothere");
     $arr = $bean->export();
     asrt(is_array($arr), TRUE);
     asrt(isset($arr["a"]), TRUE);
     asrt(isset($arr["b"]), TRUE);
     asrt($arr["a"], 1);
     asrt($arr["b"], 2);
     asrt(isset($arr["__info"]), FALSE);
     $arr = $bean->export(TRUE);
     asrt(isset($arr["__info"]), TRUE);
     asrt($arr["a"], 1);
     asrt($arr["b"], 2);
     $exportBean = $redbean->dispense("abean");
     $exportBean->setMeta("metaitem.bla", 1);
     $exportedBean = $exportBean->export(TRUE);
     asrt($exportedBean["__info"]["metaitem.bla"], 1);
     asrt($exportedBean["__info"]["type"], "abean");
     // Can we determine whether a bean is empty?
     testpack('test $bean->isEmpty() function');
     $bean = R::dispense('bean');
     asrt($bean->isEmpty(), TRUE);
     asrt(count($bean) > 0, TRUE);
     $bean->property = 1;
     asrt($bean->isEmpty(), FALSE);
     asrt(count($bean) > 0, TRUE);
     $bean->property = 0;
     asrt($bean->isEmpty(), TRUE);
     asrt(count($bean) > 0, TRUE);
     $bean->property = FALSE;
     asrt($bean->isEmpty(), TRUE);
     asrt(count($bean) > 0, TRUE);
     $bean->property = NULL;
     asrt($bean->isEmpty(), TRUE);
     asrt(count($bean) > 0, TRUE);
     unset($bean->property);
     asrt($bean->isEmpty(), TRUE);
     asrt(count($bean) > 0, TRUE);
     // Export bug I found
     $bandmember = R::dispense('bandmember');
     $bandmember->name = 'Duke';
     $instrument = R::dispense('instrument');
     $instrument->name = 'Piano';
     $bandmember->ownInstrument[] = $instrument;
     $a = R::exportAll($bandmember);
     pass();
     asrt(isset($a[0]), TRUE);
     asrt((int) $a[0]['id'], 0);
     asrt($a[0]['name'], 'Duke');
     asrt($a[0]['ownInstrument'][0]['name'], 'Piano');
     R::nuke();
     $v = R::dispense('village');
     $b = R::dispense('building');
     $v->name = 'a';
     $b->name = 'b';
     $v->ownBuilding[] = $b;
     $id = R::store($v);
     $a = R::exportAll($v);
     asrt($a[0]['name'], 'a');
     asrt($a[0]['ownBuilding'][0]['name'], 'b');
     $v = R::load('village', $id);
     $b2 = R::dispense('building');
     $b2->name = 'c';
     $v->ownBuilding[] = $b2;
     $a = R::exportAll($v);
     asrt($a[0]['name'], 'a');
     asrt($a[0]['ownBuilding'][0]['name'], 'b');
     asrt(count($a[0]['ownBuilding']), 2);
     list($r1, $r2) = R::dispense('army', 2);
     $r1->name = '1';
     $r2->name = '2';
     $v->sharedArmy[] = $r2;
     $a = R::exportAll($v);
     asrt(count($a[0]['sharedArmy']), 1);
     R::store($v);
     $v = R::load('village', $id);
     $a = R::exportAll($v);
     asrt(count($a[0]['sharedArmy']), 1);
     asrt($a[0]['name'], 'a');
     asrt($a[0]['ownBuilding'][0]['name'], 'b');
     asrt(count($a[0]['ownBuilding']), 2);
     $v->sharedArmy[] = $r1;
     $a = R::exportAll($v);
     asrt(count($a[0]['sharedArmy']), 2);
     $v = R::load('village', $id);
     $a = R::exportAll($v);
     asrt(count($a[0]['sharedArmy']), 1);
     $v->sharedArmy[] = $r1;
     R::store($v);
     $v = R::load('village', $id);
//.........这里部分代码省略.........
开发者ID:diego-vieira,项目名称:redbean,代码行数:101,代码来源:Export.php

示例12: testBeanTypeChecking

 /**
  * Test bean type checking.
  * 
  * @return void
  */
 public function testBeanTypeChecking()
 {
     $redbean = R::getRedBean();
     $bean = $redbean->dispense("page");
     // Set some illegal values in the bean; this should trigger Security exceptions.
     // Arrays are not allowed.
     $bean->name = array("1");
     try {
         $redbean->store($bean);
         fail();
     } catch (RedException $e) {
         pass();
     }
     try {
         $redbean->check($bean);
         fail();
     } catch (RedException $e) {
         pass();
     }
     $bean->name = new OODBBean();
     try {
         $redbean->check($bean);
         fail();
     } catch (RedException $e) {
         pass();
     }
     // Property names should be alphanumeric
     $prop = ".";
     $bean->{$prop} = 1;
     try {
         $redbean->store($bean);
         fail();
     } catch (RedException $e) {
         pass();
     }
     try {
         $redbean->check($bean);
         fail();
     } catch (RedException $e) {
         pass();
     }
     // Really...
     $prop = "-";
     $bean->{$prop} = 1;
     try {
         $redbean->store($bean);
         fail();
     } catch (RedException $e) {
         pass();
     }
     try {
         $redbean->check($bean);
         fail();
     } catch (RedException $e) {
         pass();
     }
 }
开发者ID:skullyframework,项目名称:skully,代码行数:62,代码来源:Typechecking.php

示例13: testTransactionInFacade


//.........这里部分代码省略.........
         fail();
     } catch (\Exception $e) {
         pass();
     }
     testpack('Test Camelcase 2 underscore');
     $names = array('oneACLRoute' => 'one_acl_route', 'ALLUPPERCASE' => 'alluppercase', 'clientServerArchitecture' => 'client_server_architecture', 'camelCase' => 'camel_case', 'peer2peer' => 'peer2peer', 'fromUs4You' => 'from_us4_you', 'lowercase' => 'lowercase', 'a1A2b' => 'a1a2b');
     $bean = R::dispense('bean');
     foreach ($names as $name => $becomes) {
         $bean->{$name} = 1;
         asrt(isset($bean->{$becomes}), TRUE);
     }
     testpack('Misc Tests');
     R::debug(1);
     flush();
     ob_start();
     R::exec('SELECT 123');
     $out = ob_get_contents();
     ob_end_clean();
     flush();
     pass();
     asrt(strpos($out, 'SELECT 123') !== FALSE, TRUE);
     R::debug(0);
     flush();
     ob_start();
     R::exec('SELECT 123');
     $out = ob_get_contents();
     ob_end_clean();
     flush();
     pass();
     asrt($out, '');
     R::debug(0);
     pass();
     testpack('test to string override');
     $band = R::dispense('band');
     $str = strval($band);
     asrt($str, 'bigband');
     testpack('test whether we can use isset/set in model');
     $band->setProperty('property1', 123);
     asrt($band->property1, 123);
     asrt($band->checkProperty('property1'), TRUE);
     asrt($band->checkProperty('property2'), FALSE);
     $band = new \Model_Band();
     $bean = R::dispense('band');
     $bean->property3 = 123;
     $band->loadBean($bean);
     $bean->property4 = 345;
     $band->setProperty('property1', 123);
     asrt($band->property1, 123);
     asrt($band->checkProperty('property1'), TRUE);
     asrt($band->checkProperty('property2'), FALSE);
     asrt($band->property3, 123);
     asrt($band->property4, 345);
     testpack('Can we pass a\\PDO object to Setup?');
     $pdo = new \PDO('sqlite:test.db');
     R::addDatabase('pdo', $pdo);
     R::selectDatabase('pdo');
     R::getCell('SELECT 123;');
     testpack('Test array interface of beans');
     $bean = R::dispense('bean');
     $bean->hello = 'hi';
     $bean->world = 'planet';
     asrt($bean['hello'], 'hi');
     asrt(isset($bean['hello']), TRUE);
     asrt(isset($bean['bye']), FALSE);
     $bean['world'] = 'sphere';
     asrt($bean->world, 'sphere');
     foreach ($bean as $key => $el) {
         if ($el == 'sphere' || $el == 'hi' || $el == 0) {
             pass();
         } else {
             fail();
         }
         if ($key == 'hello' || $key == 'world' || $key == 'id') {
             pass();
         } else {
             fail();
         }
     }
     asrt(count($bean), 3);
     unset($bean['hello']);
     asrt(count($bean), 2);
     asrt(count(R::dispense('countable')), 1);
     // Otherwise untestable...
     $bean->setBeanHelper(new SimpleFacadeBeanHelper());
     R::getRedBean()->setBeanHelper(new SimpleFacadeBeanHelper());
     pass();
     // Test whether properties like owner and shareditem are still possible
     testpack('Test Bean Interface for Lists');
     $bean = R::dispense('bean');
     // Must not be list, because first char after own is lowercase
     asrt(is_array($bean->owner), FALSE);
     // Must not be list, because first char after shared is lowercase
     asrt(is_array($bean->shareditem), FALSE);
     asrt(is_array($bean->own), FALSE);
     asrt(is_array($bean->shared), FALSE);
     asrt(is_array($bean->own_item), FALSE);
     asrt(is_array($bean->shared_item), FALSE);
     asrt(is_array($bean->{'own item'}), FALSE);
     asrt(is_array($bean->{'shared Item'}), FALSE);
 }
开发者ID:skullyframework,项目名称:skully,代码行数:101,代码来源:Misc.php

示例14: testCountShared

 public function testCountShared()
 {
     R::nuke();
     $book = R::dispense('book');
     $book->sharedPageList = R::dispense('page', 5);
     R::store($book);
     asrt($book->countShared('page'), 5);
     asrt($book->countShared('leaflet'), 0);
     asrt(R::dispense('book')->countShared('page'), 0);
     $am = R::getRedBean()->getAssociationManager();
     asrt($am->relatedCount(R::dispense('book'), 'page'), 0);
     try {
         $am->relatedCount('not a bean', 'type');
         fail();
     } catch (RedException $e) {
         pass();
     }
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:18,代码来源:Count.php

示例15: testListBeautifications

 /**
  * Test list beautifications.
  *
  * @return void
  */
 public function testListBeautifications()
 {
     testpack('Test list beautifications');
     $book = R::dispense('book');
     $page = R::dispense('page')->setAttr('name', 'a');
     $book->sharedPage[] = $page;
     $id = R::store($book);
     $book = R::load('book', $id);
     $p = reset($book->ownBookPage);
     asrt($p->page->name, 'a');
     $bean = R::dispense('bean');
     $bean->sharedAclRole[] = R::dispense('role')->setAttr('name', 'x');
     R::store($bean);
     asrt(R::count('role'), 1);
     $aclrole = R::getRedBean()->dispense('acl_role');
     $aclrole->name = 'role';
     $bean = R::dispense('bean');
     $bean->sharedAclRole[] = $aclrole;
     R::store($bean);
     asrt(count($bean->sharedAclRole), 1);
 }
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:26,代码来源:Relations.php


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