count() public static method

This method accepts a second argument to modify the count-query. A third argument can be used to provide bindings for the SQL snippet.
public static count ( string $type, string $addSQL = '', array $bindings = [] ) : integer
$type string type of bean we are looking for
$addSQL string additional SQL snippet
$bindings array parameters to bind to SQL
return integer
Esempio n. 1
0
 /**
  * Tests basic traversal.
  *
  * @return void
  */
 public function testBasicTraversal()
 {
     R::nuke();
     $pageA = R::dispense('page')->setAttr('title', 'a');
     $pageB = R::dispense('page')->setAttr('title', 'b');
     $pageC = R::dispense('page')->setAttr('title', 'c');
     $pageD = R::dispense('page')->setAttr('title', 'd');
     $pageE = R::dispense('page')->setAttr('title', 'e');
     $pageF = R::dispense('page')->setAttr('title', 'f');
     $pageG = R::dispense('page')->setAttr('title', 'g');
     $pageH = R::dispense('page')->setAttr('title', 'h');
     $pageA->ownPage = array($pageB, $pageC);
     $pageB->ownPage = array($pageD);
     $pageC->ownPage = array($pageE, $pageF);
     $pageD->ownPage = array($pageG);
     $pageF->ownPage = array($pageH);
     R::store($pageA);
     $pageA = $pageA->fresh();
     //also tests non-existant column handling by count().
     asrt(R::count('page', ' price = ? ', array('5')), 0);
     asrt(R::count('tag', ' title = ? ', array('new')), 0);
     $pageA->traverse('ownPageList', function ($bean) {
         $bean->price = 5;
     });
     R::store($pageA);
     asrt(R::count('page', ' price = ? ', array('5')), 7);
 }
Esempio n. 2
0
 /**
  * Tests the handling of trashed beans in frozen mode.
  * Are the lists unset etc?
  *
  * @return void
  */
 public function testTrash()
 {
     R::nuke();
     $book = R::dispense('book');
     $book->xownPageList[] = R::dispense('page');
     $book->sharedTagList[] = R::dispense('tag');
     R::store($book);
     $book = $book->fresh();
     R::freeze(TRUE);
     $book->xownPageList = array();
     R::store($book);
     $book = $book->fresh();
     asrt(R::count('page'), 0);
     $book->xownPageList[] = R::dispense('page');
     R::store($book);
     $book = $book->fresh();
     asrt(R::count('page'), 1);
     $book->xownPageList;
     $book->sharedTagList;
     R::trash($book);
     asrt(R::count('book'), 0);
     asrt(R::count('page'), 0);
     asrt(R::count('tag'), 1);
     asrt(R::count('book_tag'), 0);
     R::freeze(FALSE);
 }
 /**
  * @param string $DBTable
  * @param int $startPage
  * @param int $maxResults
  */
 public function setParams($DBTable, $maxResults, $startPage)
 {
     $this->DBTable = $DBTable;
     $this->maxResults = $maxResults;
     $this->startPage = $startPage;
     $this->storedNumber = Facade::count($this->DBTable);
 }
Esempio n. 4
0
 /**
  * Tests quick trash method: R::trash( type, id ).
  *
  * @return void
  */
 public function testQuickTrash()
 {
     R::nuke();
     $bean = R::dispense('bean');
     $id = R::store($bean);
     asrt(R::count('bean'), 1);
     R::trash('bean', $id);
     asrt(R::count('bean'), 0);
 }
Esempio n. 5
0
 public function testCategoryDeletion()
 {
     Scripts::CreateCategory('Berlin');
     $this->byLinkText('System Settings')->click();
     $this->byLinkText('Categories')->click();
     $this->byName('delete-ideas')->click();
     $this->byName('delete-category')->click();
     $numberOfCategories = RedBean::count('categories');
     $this->assertEquals($numberOfCategories, 1);
 }
Esempio n. 6
0
 /**
  * Test whether we can use foreign keys with keywords.
  *
  * @return void
  */
 public function testKWConflicts()
 {
     R::nuke();
     $metrics = R::dispense('metrics');
     $constraint = R::dispense('constraint');
     $constraint->xownMetrics[] = $metrics;
     R::store($constraint);
     asrt(1, R::count('metrics'));
     R::trash($constraint);
     asrt(0, R::count('metrics'));
 }
Esempio n. 7
0
 /**
  * @brief inits the class
  */
 public static function init()
 {
     session_start();
     if (R::count("user") < 1) {
         self::register(["username" => "admin", "password" => "admin"]);
     }
     if ($_SESSION["is_loggedin"]) {
         self::$is_loggedin = true;
         self::$user = $_SESSION["user"];
     }
 }
Esempio n. 8
0
 /**
  * In the past it was not possible to export beans
  * like 'feed' (Model_Feed).
  *
  * @return void
  */
 public function testExportIssue()
 {
     R::nuke();
     $feed = R::dispense('feed');
     $feed->post = array('first', 'second');
     R::store($feed);
     $rows = R::getAll('SELECT * FROM feed');
     asrt($rows[0]['post'], '["first","second"]');
     $feed = $feed->fresh();
     asrt(is_array($feed->post), TRUE);
     asrt($feed->post[0], 'first');
     asrt($feed->post[1], 'second');
     R::store($feed);
     $rows = R::getAll('SELECT * FROM feed');
     asrt($rows[0]['post'], '["first","second"]');
     $feed = R::load('feed', $feed->id);
     $feed->post[] = 'third';
     R::store($feed);
     $rows = R::getAll('SELECT * FROM feed');
     asrt($rows[0]['post'], '["first","second","third"]');
     $feed = $feed->fresh();
     asrt(is_array($feed->post), TRUE);
     asrt($feed->post[0], 'first');
     asrt($feed->post[1], 'second');
     asrt($feed->post[2], 'third');
     //now the catch: can we use export?
     //PHP Fatal error:  Call to a member function export() on a non-object
     $feeds = R::exportAll(R::find('feed'));
     asrt(is_array($feeds), TRUE);
     $feed = reset($feeds);
     asrt($feed['post'][0], 'first');
     asrt($feed['post'][1], 'second');
     asrt($feed['post'][2], 'third');
     //can we also dup()?
     $feedOne = R::findOne('feed');
     R::store(R::dup($feedOne));
     asrt(R::count('feed'), 2);
     //can we delete?
     R::trash($feedOne);
     asrt(R::count('feed'), 1);
     $feedTwo = R::findOne('feed');
     $feed = $feedTwo->export();
     asrt($feed['post'][0], 'first');
     asrt($feed['post'][1], 'second');
     asrt($feed['post'][2], 'third');
 }
Esempio n. 9
0
 /**
  * Tests no-load modifier for lists.
  * 
  * @return void
  */
 public function testNoLoad()
 {
     $book = R::dispense(array('_type' => 'book', 'title' => 'Book of Lorem Ipsum', 'ownPage' => array(array('_type' => 'page', 'content' => 'Lorem Ipsum')), 'sharedTag' => array(array('_type' => 'tag', 'label' => 'testing'))));
     R::store($book);
     $book = $book->fresh();
     asrt(R::count('book'), 1);
     asrt(count($book->ownPage), 1);
     //now try with no-load
     $book = $book->fresh();
     asrt(count($book->noLoad()->ownPage), 0);
     asrt(count($book->noLoad()->sharedTag), 0);
     //now try to add with no-load
     $book = $book->fresh();
     $book->noLoad()->xownPageList[] = R::dispense('page');
     $book->noLoad()->sharedTagList[] = R::dispense('tag');
     R::store($book);
     $book = $book->fresh();
     asrt(count($book->ownPage), 2);
     asrt(count($book->sharedTagList), 2);
     //no-load overrides with and withCondition
     $book = $book->fresh();
     asrt(count($book->with(' invalid sql ')->noLoad()->ownPage), 0);
     asrt(count($book->withCondition(' invalid sql ')->noLoad()->sharedTag), 0);
     //no-load overrides all and alias
     $book = $book->fresh();
     asrt(count($book->all()->noLoad()->ownPage), 0);
     asrt(count($book->alias('nothing')->noLoad()->sharedTag), 0);
     //no-load gets cleared
     $book = $book->fresh();
     asrt(count($book->ownPage), 2);
     asrt(count($book->sharedTagList), 2);
     //We cant clear with no-load accidentally?
     $book = $book->fresh();
     $book->noLoad()->ownPage = array();
     $book->noLoad()->sharedTagList = array();
     R::store($book);
     asrt(count($book->ownPage), 2);
     asrt(count($book->sharedTagList), 2);
     //No-load does not have effect if list is already cached
     $book = $book->fresh();
     $book->ownPage;
     $book->sharedTag;
     asrt(count($book->ownPage), 2);
     asrt(count($book->sharedTagList), 2);
 }
Esempio n. 10
0
 /**
  * Test whether we can duplicate part of a tree
  * without infinite loops.
  *
  * @return void
  */
 public function testDupPortionOfATree()
 {
     R::nuke();
     $article = R::dispense('article');
     $article->name = 'article 1';
     list($article2, $article3) = R::dispense('article', 2);
     $article2->name = 'article 2';
     $article3->name = 'article 3';
     list($article4, $article5) = R::dispense('article', 2);
     $article4->name = 'article 4';
     $article5->name = 'article 5';
     list($article6, $article7) = R::dispense('article', 2);
     $article6->name = 'article 6';
     $article7->name = 'article 7';
     $article3->xownArticleList[] = $article7;
     $article4->xownArticleList[] = $article6;
     $article2->xownArticleList = array($article5, $article4);
     $article->xownArticleList = array($article2, $article3);
     R::store($article);
     asrt(R::count('article'), 7);
     $article2 = $article2->fresh();
     $dupArticle2 = R::duplicate($article2);
     $dupArticle2->name = 'article 2b';
     $dupBeans = $dupArticle2->xownArticleList;
     foreach ($dupBeans as $dupBean) {
         $list[] = $dupBean->name;
     }
     sort($list);
     $listStr = implode(',', $list);
     asrt($listStr, 'article 4,article 5');
     foreach ($dupBeans as $dupBean) {
         if ($dupBean->name === 'article 4') {
             $dup4 = $dupBean;
         }
     }
     asrt(isset($dup4), TRUE);
     $dupBeans = $dup4->xownArticleList;
     foreach ($dupBeans as $dupBean) {
         asrt($dupBean->name, 'article 6');
     }
     //so we have extracted part of the tree, can we store it?
     $id = R::store($dupArticle2);
     asrt($id > 0, TRUE);
     asrt(R::count('article'), 11);
     $originalArticle = $article->fresh();
     asrt($originalArticle->name, 'article 1');
     $subArticles = $originalArticle->xownArticleList;
     $list = array();
     foreach ($subArticles as $subArticle) {
         $list[] = $subArticle->name;
     }
     sort($list);
     $listStr = implode(',', $list);
     asrt($listStr, 'article 2,article 2b,article 3');
     foreach ($subArticles as $subArticle) {
         if ($subArticle->name === 'article 2') {
             $sub2 = $subArticle;
         }
         if ($subArticle->name === 'article 3') {
             $sub3 = $subArticle;
         }
     }
     $subArticles = $sub2->xownArticleList;
     $list = array();
     foreach ($subArticles as $subArticle) {
         $list[] = $subArticle->name;
     }
     sort($list);
     $listStr = implode(',', $list);
     asrt($listStr, 'article 4,article 5');
     $subArticles = $sub3->xownArticleList;
     $list = array();
     foreach ($subArticles as $subArticle) {
         $list[] = $subArticle->name;
     }
     sort($list);
     $listStr = implode(',', $list);
     asrt($listStr, 'article 7');
     $subArticles = $sub2->xownArticleList;
     foreach ($subArticles as $subArticle) {
         if ($subArticle->name === 'article 4') {
             $sub4 = $subArticle;
         }
         if ($subArticle->name === 'article 5') {
             $sub5 = $subArticle;
         }
     }
     asrt(count($sub4->xownArticleList), 1);
     $subBeans = $sub4->xownArticleList;
     $subBean = reset($subBeans);
     asrt($subBean->name, 'article 6');
     asrt(count($sub5->xownArticleList), 0);
     $dupArticle2 = $dupArticle2->fresh();
     $subArticles = $dupArticle2->xownArticleList;
     $list = array();
     foreach ($subArticles as $subArticle) {
         $list[] = $subArticle->name;
     }
     sort($list);
     $listStr = implode(',', $list);
     asrt($listStr, 'article 4,article 5');
     foreach ($subArticles as $subArticle) {
         if ($subArticle->name === 'article 4') {
             $sub4 = $subArticle;
         }
         if ($subArticle->name === 'article 5') {
             $sub5 = $subArticle;
         }
     }
     asrt(count($sub4->xownArticleList), 1);
     $subBeans = $sub4->xownArticleList;
     $subBean = reset($subBeans);
     asrt($subBean->name, 'article 6');
     asrt(count($sub5->xownArticleList), 0);
 }
Esempio n. 11
0
 /**
  * Test conditions and aliases.
  */
 public function testConditionsAndAliases()
 {
     R::nuke();
     $author = R::xdispense(AUTHOR);
     $author->name = 'Mr. Quill';
     $book = R::xdispense(BOOK);
     $book->title = 'Good Stories';
     $book2 = R::xdispense(BOOK);
     $book2->title = 'Good Stories 2';
     $friend = R::xdispense(FRIEND);
     $friend->name = 'Muse';
     $publisher = R::xdispense(PUBLISHER);
     $publisher->name = 'Good Books';
     $author->{BOOKLIST} = array($book, $book2);
     $author->{FRIENDLIST}[] = $friend;
     $author->{PUBLISHER} = $publisher;
     $coAuthor = R::xdispense(AUTHOR);
     $coAuthor->name = 'Xavier';
     $book2->{COAUTHOR} = $coAuthor;
     R::store($author);
     $author = $author->fresh();
     asrt(R::count(AUTHOR), 2);
     //Can we use with and withCondition?
     asrt(count($author->{BOOKLIST}), 2);
     asrt(count($author->with(' LIMIT 1 ')->{BOOKLIST}), 1);
     asrt(count($author->withCondition(' title LIKE ? ', array('%2%'))->{BOOKLIST}), 1);
     //Can we use an alias?
     $book2 = $book2->fresh();
     asrt($book2->fetchAs(AUTHOR)->{COAUTHOR}->name, 'Xavier');
     $coAuthor = $book2->fetchAs(AUTHOR)->{COAUTHOR}->fresh();
     asrt(count($coAuthor->alias(COAUTHOR)->{BOOKLIST}), 1);
 }
Esempio n. 12
0
 /**
  * Tests dependencies (variation).
  *
  * @return void
  */
 public function testDependency4()
 {
     R::nuke();
     $can = $this->createBeanInCan(TRUE);
     R::store($can);
     R::trash($can);
     $can = $this->createCanForBean();
     asrt(R::count('bean'), 1);
     R::trash($can);
     asrt(R::count('bean'), 0);
     $can = $this->createBeanInCan(TRUE);
     R::store($can);
     R::trash($can);
     $can = $this->createCanForBean();
     asrt(R::count('bean'), 1);
     R::trash($can);
     asrt(R::count('bean'), 0);
 }
Esempio n. 13
0
 /**
  * Test trashAll().
  */
 public function testMultiDeleteUpdate()
 {
     testpack('test multi delete and multi update');
     $beans = R::dispenseLabels('bean', array('a', 'b'));
     $ids = R::storeAll($beans);
     asrt((int) R::count('bean'), 2);
     R::trashAll(R::batch('bean', $ids));
     asrt((int) R::count('bean'), 0);
     testpack('test assocManager check');
     $rb = new OODB(R::getWriter());
     try {
         $rb->getAssociationManager();
         fail();
     } catch (RedException $e) {
         pass();
     }
 }
Esempio n. 14
0
 /**
  * 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);
 }
Esempio n. 15
0
 /**
  * Test whether we cannot add unique constraints on chilled tables,
  * otherwise you cannot avoid this from happening when adding beans to the
  * shared list :) -- this is almost a theoretical issue however we want it
  * to work according to specifications!
  *
  * @return void
  */
 public function testDontAddUniqueConstraintForChilledBeanTypes()
 {
     R::nuke();
     $person = R::dispense('person');
     $role = R::dispense('role');
     $person->sharedRole[] = $role;
     R::store($person);
     $person->sharedRole[] = R::dispense('role');
     R::store($person);
     $bean = R::getRedBean()->dispense('person_role');
     $bean->personId = $person->id;
     $bean->roleId = $role->id;
     try {
         R::store($bean);
         fail();
     } catch (\Exception $e) {
         pass();
     }
     asrt(R::count('person_role'), 2);
     R::nuke();
     $link = R::getRedBean()->dispense('person_role');
     $person = R::dispense('person');
     $role = R::dispense('role');
     $link->person = $person;
     $link->role = $role;
     R::store($link);
     R::freeze(array('person_role'));
     $person->sharedRole[] = R::dispense('role');
     R::store($person);
     $bean = R::getRedBean()->dispense('person_role');
     $bean->personId = $person->id;
     $bean->roleId = $role->id;
     try {
         R::store($bean);
         pass();
     } catch (\Exception $e) {
         fail();
     }
     asrt(R::count('person_role'), 3);
     R::freeze(array());
     //set freeze to FALSE and clear CHILL LIST!
 }
Esempio n. 16
0
 /**
  * Test Full fluid UUID support.
  *
  */
 public function testFullSupport()
 {
     //Rewire objects to support UUIDs.
     $oldToolBox = R::getToolBox();
     $oldAdapter = $oldToolBox->getDatabaseAdapter();
     $uuidWriter = new \UUIDWriterPostgres($oldAdapter);
     $newRedBean = new OODB($uuidWriter);
     $newToolBox = new ToolBox($newRedBean, $oldAdapter, $uuidWriter);
     R::configureFacadeWithToolbox($newToolBox);
     list($mansion, $rooms, $ghosts, $key) = R::dispenseAll('mansion,room*3,ghost*4,key');
     $mansion->name = 'Haunted Mansion';
     $mansion->xownRoomList = $rooms;
     $rooms[0]->name = 'Green Room';
     $rooms[1]->name = 'Red Room';
     $rooms[2]->name = 'Blue Room';
     $ghosts[0]->name = 'zero';
     $ghosts[1]->name = 'one';
     $ghosts[2]->name = 'two';
     $ghosts[3]->name = 'three';
     $rooms[0]->noLoad()->sharedGhostList = array($ghosts[0], $ghosts[1]);
     $rooms[1]->noLoad()->sharedGhostList = array($ghosts[0], $ghosts[2]);
     $rooms[2]->noLoad()->sharedGhostList = array($ghosts[1], $ghosts[3], $ghosts[2]);
     $rooms[2]->xownKey = array($key);
     //Can we store a bean hierachy with UUIDs?
     R::debug(1);
     $id = R::store($mansion);
     //exit;
     asrt(is_string($id), TRUE);
     asrt(strlen($id), 36);
     $haunted = R::load('mansion', $id);
     asrt($haunted->name, 'Haunted Mansion');
     asrt(is_string($haunted->id), TRUE);
     asrt(strlen($haunted->id), 36);
     asrt(is_array($haunted->xownRoomList), TRUE);
     asrt(count($haunted->ownRoom), 3);
     $rooms = $haunted->xownRoomList;
     //Do some counting...
     $greenRoom = NULL;
     foreach ($rooms as $room) {
         if ($room->name === 'Green Room') {
             $greenRoom = $room;
             break;
         }
     }
     asrt(!is_null($greenRoom), TRUE);
     asrt(is_array($greenRoom->with(' ORDER BY id ')->sharedGhostList), TRUE);
     asrt(count($greenRoom->sharedGhostList), 2);
     $names = array();
     foreach ($greenRoom->sharedGhost as $ghost) {
         $names[] = $ghost->name;
     }
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'one,zero');
     $rooms = $haunted->xownRoomList;
     $blueRoom = NULL;
     foreach ($rooms as $room) {
         if ($room->name === 'Blue Room') {
             $blueRoom = $room;
             break;
         }
     }
     asrt(!is_null($blueRoom), TRUE);
     asrt(is_array($blueRoom->sharedGhostList), TRUE);
     asrt(count($blueRoom->sharedGhostList), 3);
     $names = array();
     foreach ($blueRoom->sharedGhost as $ghost) {
         $names[] = $ghost->name;
     }
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'one,three,two');
     $rooms = $haunted->xownRoomList;
     $redRoom = NULL;
     foreach ($rooms as $room) {
         if ($room->name === 'Red Room') {
             $redRoom = $room;
             break;
         }
     }
     $names = array();
     foreach ($redRoom->sharedGhost as $ghost) {
         $names[] = $ghost->name;
     }
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'two,zero');
     asrt(!is_null($redRoom), TRUE);
     asrt(is_array($redRoom->sharedGhostList), TRUE);
     asrt(count($redRoom->sharedGhostList), 2);
     //Can we repaint a room?
     $redRoom->name = 'Yellow Room';
     $id = R::store($redRoom);
     $yellowRoom = R::load('room', $id);
     asrt($yellowRoom->name, 'Yellow Room');
     asrt(!is_null($yellowRoom), TRUE);
     asrt(is_array($yellowRoom->sharedGhostList), TRUE);
     asrt(count($yellowRoom->sharedGhostList), 2);
     //Can we throw one ghost out?
     array_pop($yellowRoom->sharedGhost);
     R::store($yellowRoom);
     $yellowRoom = $yellowRoom->fresh();
     asrt($yellowRoom->name, 'Yellow Room');
     asrt(!is_null($yellowRoom), TRUE);
     asrt(is_array($yellowRoom->sharedGhostList), TRUE);
     asrt(count($yellowRoom->sharedGhostList), 1);
     //can we remove one of the rooms?
     asrt(R::count('key'), 1);
     $list = $mansion->withCondition(' "name" = ? ', array('Blue Room'))->xownRoomList;
     $room = reset($list);
     unset($mansion->xownRoomList[$room->id]);
     R::store($mansion);
     asrt(R::count('room'), 2);
     //and what about its dependent beans?
     asrt(R::count('key'), 0);
     asrt(R::count('ghost_room'), 3);
     //and can we find ghosts?
     $ghosts = R::find('ghost');
     asrt(count($ghosts), 4);
     $ghosts = R::findAll('ghost', 'ORDER BY id');
     asrt(count($ghosts), 4);
     $ghosts = R::findAll('ghost', 'ORDER BY id LIMIT 2');
     asrt(count($ghosts), 2);
     $ghostZero = R::findOne('ghost', ' "name" = ? ', array('zero'));
     asrt($ghostZero instanceof OODBBean, TRUE);
     //can we create link properties on existing tables?
     $blackRoom = R::dispense('room');
     $blackRoom->name = 'Black Room';
     $ghostZero->link('ghost_room', array('mood' => 'grumpy'))->room = $blackRoom;
     R::store($ghostZero);
     $ghostZero = $ghostZero->fresh();
     $list = $ghostZero->sharedRoomList;
     asrt(count($list), 3);
     $ghostZero = $ghostZero->fresh();
     $list = $ghostZero->withCondition(' ghost_room.mood = ? ', array('grumpy'))->sharedRoomList;
     asrt(count($list), 1);
     //can we load a batch?
     $ids = R::getCol('SELECT id FROM ghost');
     $ghosts = R::batch('ghost', $ids);
     asrt(count($ghosts), 4);
     //can we do an aggregation?
     $ghosts = $greenRoom->aggr('ownGhostRoom', 'ghost', 'ghost');
     asrt(count($ghosts), 2);
     //can we duplicate the mansion?
     asrt(R::count('mansion'), 1);
     asrt(R::count('room'), 3);
     asrt(R::count('ghost'), 4);
     $copy = R::dup($mansion);
     R::store($copy);
     asrt(R::count('mansion'), 2);
     asrt(R::count('room'), 5);
     //black room does not belong to mansion 1
     asrt(R::count('ghost'), 4);
     //can we do some counting using the list?
     asrt($copy->countOwn('room'), 2);
     $rooms = $copy->withCondition(' "name" = ? ', array('Green Room'))->xownRoomList;
     $room = reset($rooms);
     asrt($room->countShared('ghost'), 2);
     //Finally restore old toolbox
     R::configureFacadeWithToolbox($oldToolBox);
 }
Esempio n. 17
0
 /**
  * Test whether a duplicate bean in the list isnt saved.
  * This was an issue with Postgres while testing the threeway tables.
  * Postgres returned the ID as a string while other drivers returned
  * a numeric value causing different outcome in array_diff when
  * calculating the shared additions.
  * 
  * @return void
  */
 public function testIssueWithDriverReturnID()
 {
     AQueryWriter::clearRenames();
     R::nuke();
     $book = R::dispense('book');
     $page = R::dispense('page');
     $book->sharedPageList[] = $page;
     R::store($book);
     asrt(R::count('page'), 1);
     $book = $book->fresh();
     $book->sharedPageList[] = $page;
     R::store($book);
     //don't save the duplicate bean!
     asrt(R::count('page'), 1);
     $book = $book->fresh();
     $page->item = 2;
     //even if we change a property ?
     $book->sharedPageList[] = $page;
     R::store($book);
     foreach ($book->sharedPageList as $listItem) {
         asrt(is_string($listItem->id), TRUE);
     }
     //same test but for own-list
     R::nuke();
     $book = R::dispense('book');
     $page = R::dispense('page');
     $book->ownPageList[] = $page;
     R::store($book);
     asrt(R::count('page'), 1);
     $book = $book->fresh();
     $book->ownPageList[] = $page;
     R::store($book);
     //don't save the duplicate bean!
     asrt(R::count('page'), 1);
     $book = $book->fresh();
     $book->ownPageList[] = $page;
     $page->item = 3;
     R::store($book);
     //don't save the duplicate bean!
     asrt(R::count('page'), 1);
     foreach ($book->ownPageList as $listItem) {
         asrt(is_string($listItem->id), TRUE);
     }
     AQueryWriter::clearRenames();
 }
Esempio n. 18
0
    /**
     * Tests the complex use case for findMulti().
     *
     * @return void
     */
    public function testMultiAdvanced()
    {
        $this->insertBookData();
        $collection = R::findMulti('book,page,text,category', '
			SELECT book.*, page.*, text.*, category.*
			FROM book
			LEFT JOIN page ON page.book_id = book.id
			LEFT JOIN text ON text.page_id = page.id
			LEFT JOIN book_category ON book_category.book_id = book.id
			LEFT JOIN category ON book_category.category_id = category.id
		');
        asrt(count($collection), 4);
        asrt(isset($collection['book']), TRUE);
        asrt(isset($collection['page']), TRUE);
        asrt(isset($collection['text']), TRUE);
        asrt(isset($collection['category']), TRUE);
        asrt(count($collection['book']), 5);
        asrt(count($collection['page']), 9);
        asrt(count($collection['text']), 11);
        asrt(count($collection['category']), 3);
        foreach ($collection['book'] as $bean) {
            asrt($bean instanceof OODBBean, TRUE);
        }
        foreach ($collection['page'] as $bean) {
            asrt($bean instanceof OODBBean, TRUE);
        }
        foreach ($collection['text'] as $bean) {
            asrt($bean instanceof OODBBean, TRUE);
        }
        foreach ($collection['category'] as $bean) {
            asrt($bean instanceof OODBBean, TRUE);
        }
        foreach ($collection['book'] as $book) {
            $titles[] = $book->title;
        }
        asrt(in_array('Diehard C', $titles), TRUE);
        asrt(in_array('Adventures in JavaScript', $titles), TRUE);
        asrt(in_array('CSS ala Picasso', $titles), TRUE);
        asrt(in_array('PHP Tips and Tricks', $titles), TRUE);
        asrt(in_array('Secrets of SQL', $titles), TRUE);
        $collection = R::findMulti('book,page,text,category,book_category', '
			SELECT book.*, page.*, text.*, category.*, book_category.*
			FROM book
			LEFT JOIN page ON page.book_id = book.id
			LEFT JOIN text ON text.page_id = page.id
			LEFT JOIN book_category ON book_category.book_id = book.id
			LEFT JOIN category ON book_category.category_id = category.id
			WHERE category_id > ?
			ORDER BY book.title ASC
		', array(0), array(array('b' => 'page', 'a' => 'text', 'do' => function ($a, $b) {
            $b->noLoad()->ownTextList[] = $a;
            $b->clearHistory();
        }, 'matcher' => function ($a, $b) {
            return $a->page_id == $b->id;
        }), array('b' => 'book', 'a' => 'page', 'do' => function ($a, $b) {
            $b->noLoad()->ownPageList[] = $a;
            $b->clearHistory();
        }, 'matcher' => function ($a, $b) {
            return $a->book_id == $b->id;
        }), array('b' => 'category', 'a' => 'book', 'do' => function ($a, $b) {
            $a->noLoad()->sharedCategoryList[] = $b;
            $a->clearHistory();
        }, 'matcher' => function ($a, $b, $beans) {
            foreach ($beans['book_category'] as $bean) {
                if ($bean->book_id == $a->id && $bean->category_id == $b->id) {
                    return TRUE;
                }
            }
            return FALSE;
        })));
        $books = $collection['book'];
        $book = reset($books);
        asrt($book->title, 'Adventures in JavaScript');
        R::nuke();
        asrt(count($book->ownPageList), 3);
        $page = reset($book->ownPageList);
        asrt(count($page->ownTextList), 1);
        asrt(count($book->sharedCategoryList), 2);
        $categories = array();
        foreach ($book->sharedCategoryList as $category) {
            $categories[] = $category->name;
        }
        sort($categories);
        asrt(implode(',', $categories), 'Programming,Web Development');
        $book = next($books);
        asrt($book->title, 'CSS ala Picasso');
        asrt(count($book->ownPage), 1);
        $page = reset($book->ownPage);
        asrt(count($page->ownTextList), 2);
        $texts = array();
        foreach ($page->ownTextList as $text) {
            $texts[] = $text->content;
        }
        asrt(in_array('Now we use it for applications...', $texts), TRUE);
        $categories = array();
        foreach ($book->sharedCategoryList as $category) {
            $categories[] = $category->name;
        }
        sort($categories);
        asrt(implode(',', $categories), 'Design,Programming,Web Development');
        $book = next($books);
        asrt($book->title, 'Diehard C');
        asrt(count($book->ownPageList), 2);
        $page = reset($book->ownPageList);
        asrt(count($page->ownTextList), 2);
        $page = next($book->ownPageList);
        asrt(count($page->ownTextList), 1);
        $categories = array();
        foreach ($book->sharedCategoryList as $category) {
            $categories[] = $category->name;
        }
        sort($categories);
        asrt(implode(',', $categories), 'Programming');
        //should have no effect, nothing should have changed
        R::storeAll($books);
        asrt(R::count('book'), 0);
        asrt(R::count('page'), 0);
        asrt(R::count('text'), 0);
    }
Esempio n. 19
0
 /**
  * Test Recursion
  */
 public function testRecursion()
 {
     list($d1, $d2) = R::dispense('document', 2);
     $page = R::dispense('page');
     list($p1, $p2) = R::dispense('paragraph', 2);
     list($e1, $e2) = R::dispense('excerpt', 2);
     $id2 = R::store($d2);
     $p1->name = 'a';
     $p2->name = 'b';
     $page->title = 'my page';
     $page->ownParagraph = array($p1, $p2);
     $p1->ownExcerpt[] = $e1;
     $p2->ownExcerpt[] = $e2;
     $e1->ownDocument[] = $d2;
     $e2->ownDocument[] = $d1;
     $d1->ownPage[] = $page;
     $id1 = R::store($d1);
     $d1 = R::load('document', $id1);
     $d = R::dup($d1);
     $ids = array();
     asrt($d instanceof OODBBean, TRUE);
     asrt(count($d->ownPage), 1);
     foreach (end($d->ownPage)->ownParagraph as $p) {
         foreach ($p->ownExcerpt as $e) {
             $ids[] = end($e->ownDocument)->id;
         }
     }
     sort($ids);
     asrt((int) $ids[0], 0);
     asrt((int) $ids[1], $id1);
     R::store($d);
     pass();
     $phillies = R::dispense('diner');
     list($lonelyman, $man, $woman) = R::dispense('guest', 3);
     $attendant = R::dispense('employee');
     $lonelyman->name = 'Bennie Moten';
     $man->name = 'Daddy Stovepipe';
     $woman->name = 'Mississippi Sarah';
     $attendant->name = 'Gus Cannon';
     $phillies->sharedGuest = array($lonelyman, $man, $woman);
     $phillies->ownEmployee[] = $attendant;
     $props = R::dispense('prop', 2);
     $props[0]->kind = 'cigarette';
     $props[1]->kind = 'coffee';
     $thought = R::dispense('thought');
     $thought->content = 'Blues';
     $thought2 = R::dispense('thought');
     $thought2->content = 'Jazz';
     $woman->ownProp[] = $props[0];
     $man->sharedProp[] = $props[1];
     $attendant->ownThought = array($thought, $thought2);
     R::store($phillies);
     $diner = R::findOne('diner');
     $diner2 = R::dup($diner);
     $id2 = R::store($diner2);
     $diner2 = R::load('diner', $id2);
     asrt(count($diner->ownEmployee), 1);
     asrt(count($diner2->ownEmployee), 1);
     asrt(count($diner->sharedGuest), 3);
     asrt(count($diner2->sharedGuest), 3);
     $employee = reset($diner->ownEmployee);
     asrt(count($employee->ownThought), 2);
     $employee = reset($diner2->ownEmployee);
     asrt(count($employee->ownThought), 2);
     // Can we change something in the duplicate without changing the original?
     $employee->name = 'Marvin';
     $thought = R::dispense('thought');
     $thought->content = 'depression';
     $employee->ownThought[] = $thought;
     array_pop($diner2->sharedGuest);
     $guest = reset($diner2->sharedGuest);
     $guest->name = 'Arthur Dent';
     $id2 = R::store($diner2);
     $diner2 = R::load('diner', $id2);
     asrt(count($diner->ownEmployee), 1);
     asrt(count($diner2->ownEmployee), 1);
     asrt(count($diner->sharedGuest), 3);
     asrt(count($diner2->sharedGuest), 2);
     $employeeOld = reset($diner->ownEmployee);
     asrt(count($employeeOld->ownThought), 2);
     $employee = reset($diner2->ownEmployee);
     asrt(count($employee->ownThought), 3);
     asrt($employee->name, 'Marvin');
     asrt($employeeOld->name, 'Gus Cannon');
     // However the shared beans must not be copied
     asrt(R::count('guest'), 3);
     asrt(R::count('guest_prop'), 1);
     $arthur = R::findOne('guest', ' ' . R::getWriter()->esc('name') . ' = ? ', array('Arthur Dent'));
     asrt($arthur->name, 'Arthur Dent');
 }
Esempio n. 20
0
 /**
  * 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();
         }
     }
 }
Esempio n. 21
0
 public function testWhetherWeCanAddToLists()
 {
     $book = $this->_createBook();
     $book->ownPage[] = R::dispense('page');
     R::store($book);
     asrt(R::count('page'), 3);
     $book = $this->_createBook();
     $book->ownPageList[] = R::dispense('page');
     R::store($book);
     asrt(R::count('page'), 3);
     $book = $this->_createBook();
     $book->xownPage[] = R::dispense('page');
     R::store($book);
     asrt(R::count('page'), 3);
     $book = $this->_createBook();
     $book->xownPageList[] = R::dispense('page');
     R::store($book);
     asrt(R::count('page'), 3);
     $ads = R::dispense('ad', 3);
     $book = $this->_createBook();
     $book->alias('magazine')->ownAd = $ads;
     $book->ownPage[] = R::dispense('page');
     R::store($book);
     asrt(R::count('ad'), 6);
     asrt(R::count('page'), 3);
     $ads = R::dispense('ad', 3);
     $book = $this->_createBook();
     $book->alias('magazine')->ownAdList = $ads;
     $book->ownPageList[] = R::dispense('page');
     R::store($book);
     asrt(R::count('ad'), 6);
     asrt(R::count('page'), 3);
     $ads = R::dispense('ad', 3);
     $book = $this->_createBook();
     $book->alias('magazine')->xownAd = $ads;
     $book->xownPage[] = R::dispense('page');
     R::store($book);
     asrt(R::count('ad'), 3);
     asrt(R::count('page'), 3);
     $ads = R::dispense('ad', 3);
     $book = $this->_createBook();
     $book->alias('magazine')->xownAdList = $ads;
     $book->xownPageList[] = R::dispense('page');
     R::store($book);
     asrt(R::count('ad'), 3);
     asrt(R::count('page'), 3);
     $book = $this->_createBook();
     $book->sharedTag[] = R::dispense('tag');
     R::store($book);
     asrt(R::count('tag'), 3);
     $book = $this->_createBook();
     $book->sharedTagList[] = R::dispense('tag');
     R::store($book);
     asrt(R::count('tag'), 3);
 }
Esempio n. 22
0
 /**
  * @return int
  */
 public function count($userid = NULL)
 {
     $count = R::count($this->tbname);
     return $count;
 }
Esempio n. 23
0
 /**
  * Test multiple assiociation.
  *
  * @return void
  */
 public function testMultiAssociationDissociation()
 {
     $wines = R::dispense('wine', 3);
     $cheese = R::dispense('cheese', 3);
     $olives = R::dispense('olive', 3);
     R::getRedBean()->getAssociationManager()->associate($wines, array_merge($cheese, $olives));
     asrt(R::count('cheese'), 3);
     asrt(R::count('olive'), 3);
     asrt(R::count('wine'), 3);
     asrt(count($wines[0]->sharedCheese), 3);
     asrt(count($wines[0]->sharedOlive), 3);
     asrt(count($wines[1]->sharedCheese), 3);
     asrt(count($wines[1]->sharedOlive), 3);
     asrt(count($wines[2]->sharedCheese), 3);
     asrt(count($wines[2]->sharedOlive), 3);
     R::getRedBean()->getAssociationManager()->unassociate($wines, $olives);
     asrt(count($wines[0]->sharedCheese), 3);
     asrt(count($wines[0]->sharedOlive), 0);
     asrt(count($wines[1]->sharedCheese), 3);
     asrt(count($wines[1]->sharedOlive), 0);
     asrt(count($wines[2]->sharedCheese), 3);
     asrt(count($wines[2]->sharedOlive), 0);
     R::getRedBean()->getAssociationManager()->unassociate(array($wines[1]), $cheese);
     asrt(count($wines[0]->sharedCheese), 3);
     asrt(count($wines[0]->sharedOlive), 0);
     asrt(count($wines[1]->sharedCheese), 0);
     asrt(count($wines[1]->sharedOlive), 0);
     asrt(count($wines[2]->sharedCheese), 3);
     asrt(count($wines[2]->sharedOlive), 0);
     R::getRedBean()->getAssociationManager()->unassociate(array($wines[2]), $cheese);
     asrt(count($wines[0]->sharedCheese), 3);
     asrt(count($wines[0]->sharedOlive), 0);
     asrt(count($wines[1]->sharedCheese), 0);
     asrt(count($wines[1]->sharedOlive), 0);
     asrt(count($wines[2]->sharedCheese), 0);
     asrt(count($wines[2]->sharedOlive), 0);
 }
Esempio n. 24
0
 /**
  * Test don't try to store other things in shared list.
  *
  * @return void
  */
 public function testDontTryToStoreOtherThingsInSharedList()
 {
     $book = R::dispense('book');
     $book->sharedPage[] = 'nonsense';
     try {
         R::store($book);
         fail();
     } catch (RedException $exception) {
         pass();
     }
     $book->sharedPageList = R::dispense('page', 2);
     R::store($book);
     $book->sharedPageList;
     R::trash($book);
     asrt(R::count('page'), 2);
 }
Esempio n. 25
0
 /**
  * Test effect of via on shared list removal of beans.
  *
  * @return void
  */
 public function testViaAndRemove()
 {
     R::nuke();
     $project = R::dispense('project');
     $employees = R::dispense('employee', 2);
     $project->via('partcipant')->sharedEmployeeList = $employees;
     R::store($project);
     asrt(R::count('employee'), 2);
     asrt(R::count('participant'), 2);
     $project = $project->fresh();
     $project->sharedEmployee = array();
     R::store($project);
     asrt(R::count('employee'), 2);
     asrt(R::count('participant'), 0);
 }
Esempio n. 26
0
 /**
  * Test aggr with basic aliasing.
  *
  * @return void
  */
 public function testAggrWithOnlyAlias()
 {
     R::nuke();
     $book = R::dispense('book');
     $page1 = R::dispense('page');
     $page1->name = 'Page 1';
     $text1 = R::dispense('text');
     $text1->content = 'Text 1';
     $page1->content = $text1;
     $book->xownPageList[] = $page1;
     $page2 = R::dispense('page');
     $page2->name = 'Page 2';
     $text2 = R::dispense('text');
     $text2->content = 'Text 2';
     $page2->content = $text2;
     $book->xownPageList[] = $page2;
     R::store($book);
     $book = $book->fresh();
     $texts = $book->aggr('ownPageList', 'content', 'text');
     R::nuke();
     asrt(count($texts), 2);
     foreach ($texts as $text) {
         asrt($text instanceof OODBBean, TRUE);
     }
     $pages = $book->ownPageList;
     asrt(count($pages), 2);
     asrt(R::count('page'), 0);
     foreach ($pages as $page) {
         asrt($page instanceof OODBBean, TRUE);
         $text = $page->content;
         asrt($text instanceof OODBBean, TRUE);
         $text->content = 'CHANGED';
     }
     foreach ($texts as $text) {
         asrt($text->content, 'CHANGED');
     }
 }
Esempio n. 27
0
 public static function count($tbname)
 {
     $count = R::count($tbname);
     return $count;
 }
Esempio n. 28
0
 /**
  * Test Facade transactions.
  * 
  * @return void
  * 
  * @throws\Exception
  */
 public function testTransactionInFacade()
 {
     testpack('Test transaction in facade');
     $bean = R::dispense('bean');
     $bean->name = 'a';
     R::store($bean);
     R::trash($bean);
     R::freeze(TRUE);
     $bean = R::dispense('bean');
     $bean->name = 'a';
     R::store($bean);
     asrt(R::count('bean'), 1);
     R::trash($bean);
     asrt(R::count('bean'), 0);
     $bean = R::dispense('bean');
     $bean->name = 'a';
     $id = R::transaction(function () use(&$bean) {
         return R::transaction(function () use(&$bean) {
             return R::store($bean);
         });
     });
     asrt((int) $id, (int) $bean->id);
     R::trash($bean);
     $bean = R::dispense('bean');
     $bean->name = 'a';
     $id = R::transaction(function () use(&$bean) {
         return R::store($bean);
     });
     asrt((int) $id, (int) $bean->id);
     R::trash($bean);
     $bean = R::dispense('bean');
     $bean->name = 'a';
     try {
         R::transaction(function () use($bean) {
             R::store($bean);
             R::transaction(function () {
                 throw new \Exception();
             });
         });
     } catch (\Exception $e) {
         pass();
     }
     asrt(R::count('bean'), 0);
     $bean = R::dispense('bean');
     $bean->name = 'a';
     try {
         R::transaction(function () use($bean) {
             R::transaction(function () use($bean) {
                 R::store($bean);
                 throw new \Exception();
             });
         });
     } catch (\Exception $e) {
         pass();
     }
     asrt(R::count('bean'), 0);
     $bean = R::dispense('bean');
     $bean->name = 'a';
     try {
         R::transaction(function () use($bean) {
             R::transaction(function () use($bean) {
                 R::store($bean);
             });
         });
     } catch (\Exception $e) {
         pass();
     }
     asrt(R::count('bean'), 1);
     R::freeze(FALSE);
     try {
         R::transaction('nope');
         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);
 }