private function loadBooks() { $categoryId = 1; // load testing books for ($i = 0; $i < 50; $i++) { $book = Books::fetchNew(); $bookId = $book->set('name', 'book' . $i)->set('release_date', '2016-06-24')->save(); $booksCategories = BooksCategories::fetchNew(); $booksCategories->set('book_id', $bookId)->set('category_id', $categoryId++); $booksCategories->save(); if ($categoryId == 4) { $categoryId = 1; } } }
public function testIsNull() { $this->initConnection(); $select = Books::select()->isNull('release_date'); $result = $select->fetchAll(); $result = $this->inline($result); $expected = "array(0=>array('book_id'=>'1','name'=>'LearningPHP,MySQL&JavaScript:WithjQuery,CSS&HTML5','release_date'=>NULL,'format_id'=>NULL,),1=>array('book_id'=>'2','name'=>'We\\'reAllDamaged','release_date'=>NULL,'format_id'=>NULL,),)"; $this->assertEquals($expected, $result); $select = Books::select()->isNotNull('release_date'); $result = $select->fetchAll(); $result = $this->inline($result); $expected = "array(0=>array('book_id'=>'3','name'=>'JavaScriptandJQuery:InteractiveFront-EndWebDevelopment','release_date'=>'2016-06-06','format_id'=>NULL,),)"; $this->assertEquals($expected, $result); }