本文整理汇总了PHP中R::dependencies方法的典型用法代码示例。如果您正苦于以下问题:PHP R::dependencies方法的具体用法?PHP R::dependencies怎么用?PHP R::dependencies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类R
的用法示例。
在下文中一共展示了R::dependencies方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRebuilder
/**
* Test SQLite table rebuilding.
*
* @return void
*/
public function testRebuilder()
{
$toolbox = R::$toolbox;
$adapter = $toolbox->getDatabaseAdapter();
$writer = $toolbox->getWriter();
$redbean = $toolbox->getRedBean();
$pdo = $adapter->getDatabase();
R::dependencies(array('page' => array('book')));
$book = R::dispense('book');
$page = R::dispense('page');
$book->ownPage[] = $page;
$id = R::store($book);
$book = R::load('book', $id);
asrt(count($book->ownPage), 1);
asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 1);
R::trash($book);
asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 0);
$book = R::dispense('book');
$page = R::dispense('page');
$book->ownPage[] = $page;
$id = R::store($book);
$book = R::load('book', $id);
asrt(count($book->ownPage), 1);
asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 1);
$book->added = 2;
R::store($book);
$book->added = 'added';
R::store($book);
R::trash($book);
asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 0);
}
示例2: testDependency4
/**
* Tests dependencies (variation).
*
* @return void
*/
public function testDependency4()
{
R::dependencies(array('bean' => array('can')));
$can = $this->createCanForBean();
asrt(R::count('bean'), 1);
R::trash($can);
asrt(R::count('bean'), 0);
R::dependencies(array());
$can = $this->createCanForBean();
asrt(R::count('bean'), 1);
R::trash($can);
asrt(R::count('bean'), 1);
}
示例3: testGraph
/**
* Test graph() method.
*
* @return void
*/
public function testGraph()
{
RedBean_Plugin_Cooker::enableBeanLoading(TRUE);
R::dependencies(array());
$currentDriver = $this->currentlyActiveDriverID;
global $lifeCycle;
$toolbox = R::$toolbox;
$adapter = $toolbox->getDatabaseAdapter();
$writer = $toolbox->getWriter();
$redbean = $toolbox->getRedBean();
try {
R::graph(array(array(array('a' => 'b'))));
fail();
} catch (RedBean_Exception_Security $e) {
pass();
}
try {
R::graph('ABC');
fail();
} catch (RedBean_Exception_Security $e) {
pass();
}
try {
R::graph(123);
fail();
} catch (RedBean_Exception_Security $e) {
pass();
}
try {
R::graph(array(new stdClass()));
fail();
} catch (RedBean_Exception_Security $e) {
pass();
}
list($v1, $v2, $v3) = R::dispense('village', 3);
list($b1, $b2, $b3, $b4, $b5, $b6) = R::dispense('building', 6);
list($f1, $f2, $f3, $f4, $f5, $f6) = R::dispense('farmer', 6);
list($u1, $u2, $u3, $u4, $u5, $u6) = R::dispense('furniture', 6);
list($a1, $a2) = R::dispense('army', 2);
$a1->strength = 100;
$a2->strength = 200;
$v1->name = 'v1';
$v2->name = 'v2';
$v3->name = 'v3';
$v1->ownBuilding = array($b4, $b6);
$v2->ownBuilding = array($b1);
$v3->ownBuilding = array($b5);
$b1->ownFarmer = array($f1, $f2);
$b6->ownFarmer = array($f3);
$b5->ownFarmer = array($f4);
$b5->ownFurniture = array($u6, $u5, $u4);
$v2->sharedArmy[] = $a2;
$v3->sharedArmy = array($a2, $a1);
$i2 = R::store($v2);
$i1 = R::store($v1);
$i3 = R::store($v3);
$v1 = R::load('village', $i1);
$v2 = R::load('village', $i2);
$v3 = R::load('village', $i3);
asrt(count($v3->ownBuilding), 1);
asrt(count(reset($v3->ownBuilding)->ownFarmer), 1);
asrt(count(reset($v3->ownBuilding)->ownFurniture), 3);
asrt(count($v3->sharedArmy), 2);
asrt(count($v1->sharedArmy), 0);
asrt(count($v2->sharedArmy), 1);
asrt(count($v2->ownBuilding), 1);
asrt(count($v1->ownBuilding), 2);
asrt(count(reset($v1->ownBuilding)->ownFarmer), 0);
asrt(count(end($v1->ownBuilding)->ownFarmer), 1);
asrt(count($v3->ownTapestry), 0);
// Change the names and add the same building should not change the graph
$v1->name = 'village I';
$v2->name = 'village II';
$v3->name = 'village III';
$v1->ownBuilding[] = $b4;
$i2 = R::store($v2);
$i1 = R::store($v1);
$i3 = R::store($v3);
$v1 = R::load('village', $i1);
$v2 = R::load('village', $i2);
$v3 = R::load('village', $i3);
asrt(count($v3->ownBuilding), 1);
asrt(count(reset($v3->ownBuilding)->ownFarmer), 1);
asrt(count(reset($v3->ownBuilding)->ownFurniture), 3);
asrt(count($v3->sharedArmy), 2);
asrt(count($v1->sharedArmy), 0);
asrt(count($v2->sharedArmy), 1);
asrt(count($v2->ownBuilding), 1);
asrt(count($v1->ownBuilding), 2);
asrt(count(reset($v1->ownBuilding)->ownFarmer), 0);
asrt(count(end($v1->ownBuilding)->ownFarmer), 1);
asrt(count($v3->ownTapestry), 0);
$b = reset($v1->ownBuilding);
R::trash($b);
$n = R::count('village');
//.........这里部分代码省略.........
示例4: testListAddDelete
/**
* Test list add and delete.
*
* @return void
*/
public function testListAddDelete()
{
testpack('Test list add/delete scenarios.');
R::dependencies(array('page' => array('book', 'paper')));
$b = R::dispense('book');
$p = R::dispense('page');
$b->title = 'a';
$p->name = 'b';
$b->ownPage[] = $p;
R::store($b);
$b->ownPage = array();
R::store($b);
asrt(R::count('page'), 0);
$p = R::dispense('page');
$z = R::dispense('paper');
$z->ownPage[] = $p;
R::store($z);
asrt(R::count('page'), 1);
$z->ownPage = array();
R::store($z);
asrt(R::count('page'), 0);
$i = R::dispense('magazine');
$i->ownPage[] = R::dispense('page');
R::store($i);
asrt(R::count('page'), 1);
$i->ownPage = array();
R::store($i);
asrt(R::count('page'), 1);
R::dependencies(array());
}