本文整理汇总了PHP中Collection::getItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::getItems方法的具体用法?PHP Collection::getItems怎么用?PHP Collection::getItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection::getItems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCollectionSetContent
public function testCollectionSetContent()
{
$obj = new Collection();
$subject = <<<EOD
{"collection":{"version":"1.0","href":"http:\\/\\/www.ovagraph.com\\/api\\/3\\/cycles","links":[{"href":"http:\\/\\/www.ovagraph.com\\/cycles\\/1","rel":"alternate","name":"ovagraph_cycles_table","render":"link","prompt":"View on OvaGraph.com"}],"items":[{"href":"http:\\/\\/www.ovagraph.com\\/api\\/3\\/cycles\\/589161","data":[{"name":"title","prompt":"Title","value":"Cycle #13 (Starting 1\\/7\\/14)"},{"name":"ce","prompt":"Cycle end date","value":""},{"name":"cn","prompt":"Cycle number","value":13},{"name":"cl","prompt":"Cycle length","value":0},{"name":"cs","prompt":"Cycle start date","value":"2014-01-07"},{"name":"ic","prompt":"Cycle UUID","value":589161},{"name":"ms","prompt":"Fertility meds start day","value":5},{"name":"ul","prompt":"Average Cycle Length (in OvaCue)","value":31},{"name":"uo","prompt":"\\"My\\" Revised Ovulation Day","value":17},{"name":"xa","prompt":"Exclude from the All Cycles Average?","value":0},{"name":"cn","prompt":"Notes","value":"This was the cycle where we went to Disneyland."},{"name":"days(1)","prompt":"Days","value":[689582,689583,689584,689585,689586,689587,689588,689589,689590]},{"name":"days(2)","prompt":"Days","value":[{"bf":96,"d":"2014-01-07","id":689582,"or":200,"ot":"07:31-08:00","vr":100},{"bf":99,"d":"2014-01-08","id":689583,"or":210,"ot":"07:313-08:00","vr":160},{"bf":95,"d":"2014-01-09","id":689584,"or":190,"ot":"07:31-08:00","vr":140},{"bf":100,"d":"2014-01-10","id":689585,"or":200,"ot":"07:32-08:00","vr":150},{"d":"2014-01-11","id":689586,"or":200,"ot":"07:31-08:00","vr":55},{"d":"2014-01-12","id":689587,"or":200,"ot":"07:36-08:00","vr":21},{"d":"2014-01-13","id":689588,"or":100,"ot":"07:31-08:00"},{"d":"2014-01-14","id":689589,"vr":397},{"d":"2014-01-15","id":689590,"vr":1}]}],"links":[{"href":"http:\\/\\/www.ovagraph.com\\/records\\/1\\/cycles\\/589161","rel":"alternate","name":"ovagraph_node_view","render":"link","prompt":"View on OvaGraph.com"},{"href":"http:\\/\\/www.ovagraph.com\\/cycles\\/1\\/589161\\/chart","rel":"alternate","name":"ovagraph_cycle_chart","render":"link","prompt":"View chart"},{"href":"http:\\/\\/www.ovagraph.com\\/cycles\\/1\\/589161\\/calendar","rel":"alternate","name":"ovagraph_cycle_calendar","render":"link","prompt":"View calendar"},{"href":"http:\\/\\/www.ovagraph.com\\/cycles\\/1\\/589161\\/days","rel":"alternate","name":"ovagraph_cycle_table","render":"link","prompt":"View table"},{"href":"http:\\/\\/www.ovagraph.com\\/sites\\/ovagraph.com\\/files\\/tickers\\/1\\/ovagraph-ticker-small.png","rel":"icon","name":"small_ticker","render":"image","prompt":"Small ticker image for Cycle #13 (Starting 1\\/7\\/14)"},{"href":"http:\\/\\/www.ovagraph.com\\/sites\\/ovagraph.com\\/files\\/tickers\\/1\\/ovagraph-ticker-large.png","rel":"icon","name":"large_ticker","render":"image","prompt":"Large ticker image for Cycle #13 (Starting 1\\/7\\/14)"}]}],"queries":[{"href":"http:\\/\\/www.ovagraph.com\\/api\\/3\\/cycles","rel":"subsection","prompt":"Alter the results","data":[{"name":"max","prompt":"Max cycles","value":5},{"name":"order_by","prompt":"Sort order (desc, asc)","value":"desc"},{"name":"cn","prompt":"By cycle number","value":1},{"name":"cs_from","prompt":"Minimum start date","value":""},{"name":"cs_to","prompt":"Maximum start date","value":""},{"name":"days","prompt":"Include day objects (0=none, 1=ids only, 2=full objects)","value":0},{"name":"html","prompt":"Type of html markup (0=none, 1=adaptive or fixed, 2=fixed only)?","value":1},{"name":"view","prompt":"For which view to build html? (calendar, days, chart)?","value":"chart"}]}],"template":{"data":[{"name":"cs","prompt":"Cycle start date","value":"2014-01-07"},{"name":"ms","prompt":"Fertility meds start day","value":5},{"name":"ul","prompt":"Average Cycle Length (in OvaCue)","value":31},{"name":"uo","prompt":"\\"My\\" Revised Ovulation Day","value":17},{"name":"xa","prompt":"Exclude from the All Cycles Average?","value":0},{"name":"cn","prompt":"Notes","value":"This was the cycle where we went to Disneyland."},{"name":"days","prompt":"Days","value":[{"bf":96,"d":"2014-01-07","id":689582,"or":200,"ot":"07:31-08:00","vr":100},{"bf":99,"d":"2014-01-08","or":210,"ot":"07:313-08:00","vr":160},{"bf":95,"d":"2014-01-09","or":190,"ot":"07:31-08:00","vr":140},{"bf":100,"d":"2014-01-10","or":200,"ot":"07:32-08:00","vr":150},{"d":"2014-01-11","or":200,"ot":"07:31-08:00","vr":55},{"d":"2014-01-12","or":200,"ot":"07:36-08:00","vr":21},{"d":"2014-01-13","or":100,"ot":"07:31-08:00"},{"d":"2014-01-14","vr":397},{"d":"2014-01-15","vr":1}]}]}}}
EOD;
$return = $obj->setContent($subject);
$this->assertInstanceOf('\\AKlump\\Http\\CollectionJson\\Collection', $return);
$items = $obj->getItems();
$this->assertCount(1, $items);
$links = $obj->getLinks();
$this->assertCount(1, $links);
$this->assertCount(7, $obj->getTemplate()->getDataArray());
$this->assertSame($subject, (string) $obj);
}
示例2: testDelete
function testDelete()
{
// Arrange
$collection_name = "Star Wars cards";
$test_collection = new Collection($collection_name);
$test_collection->save();
$test_collection_id = $test_collection->getId();
$name = "Darth Vader Black Border Premier";
$test_item = new Item($name, $test_collection_id);
$test_item->save();
// Act
$test_item->delete();
$collection_items = $test_collection->getItems();
// Assert
$this->assertEquals([], $collection_items);
}
示例3: Collection
function test_getItems()
{
// Arrange
$collection_name = "Star Wars Cards";
$test_collection = new Collection($collection_name);
$test_collection->save();
$collection_id = $test_collection->getId();
$item_name = "Boba Fett";
$test_item = new Item($item_name, $collection_id);
$test_item->save();
$item_name2 = "Slave 1";
$test_item2 = new Item($item_name2, $collection_id);
$test_item2->save();
// Act
$items = array();
$collection_items = $test_collection->getItems();
// Assert
$this->assertEquals([$test_item, $test_item2], $collection_items);
}