當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PropelCollection::setData方法代碼示例

本文整理匯總了PHP中PropelCollection::setData方法的典型用法代碼示例。如果您正苦於以下問題:PHP PropelCollection::setData方法的具體用法?PHP PropelCollection::setData怎麽用?PHP PropelCollection::setData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PropelCollection的用法示例。


在下文中一共展示了PropelCollection::setData方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetDataSourceIterator

 public function testGetDataSourceIterator()
 {
     $fields = array('title' => '[title]');
     $firstResult = 10;
     $maxResults = 25;
     $data = array(array('id' => 42, 'title' => 'Super!'), array('id' => 24, 'title' => 'Foo'));
     $results = new \PropelCollection();
     $results->setData($data);
     // configure the query mock
     $query = $this->getMock('Sonata\\AdminBundle\\Datagrid\\ProxyQueryInterface');
     $query->expects($this->once())->method('setFirstResult')->with($this->equalTo($firstResult));
     $query->expects($this->once())->method('setMaxResults')->with($this->equalTo($maxResults));
     $query->expects($this->once())->method('execute')->will($this->returnValue($results));
     // configure the datagrid mock
     $datagrid = $this->getMockBuilder('Sonata\\PropelAdminBundle\\Datagrid\\Datagrid')->disableOriginalConstructor()->setMethods(array('buildPager', 'getQuery'))->getMock();
     $datagrid->expects($this->once())->method('buildPager');
     $datagrid->expects($this->once())->method('getQuery')->will($this->returnValue($query));
     // create the manager
     $manager = new ModelManager();
     // and finally test it!
     $collectionIterator = $manager->getDataSourceIterator($datagrid, $fields, $firstResult, $maxResults);
     $this->assertInstanceOf('\\Exporter\\Source\\PropelCollectionSourceIterator', $collectionIterator);
     $this->assertSame(array(array('title' => 'Super!'), array('title' => 'Foo')), iterator_to_array($collectionIterator));
 }
開發者ID:kosolapovvp,項目名稱:SonataPropelAdminBundle,代碼行數:24,代碼來源:ModelManagerTest.php

示例2: testIsEven

 public function testIsEven()
 {
     $col = new PropelCollection();
     $this->assertTrue($col->isEven(), 'isEven() returns true on an empty collection');
     $data = array('bar1', 'bar2', 'bar3');
     $col = new PropelCollection();
     $col->setData($data);
     foreach ($col as $key => $value) {
         $this->assertEquals(!(bool) ($key % 2), $col->isEven(), 'isEven() returns true only when the key is even');
     }
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:11,代碼來源:PropelCollectionTest.php

示例3: deserializeCollection

 public function deserializeCollection(VisitorInterface $visitor, $data, Type $type, Context $context)
 {
     $collection = new \PropelCollection();
     $collection->setData($visitor->visitArray($data, $type, $context));
     return $collection;
 }
開發者ID:alekitto,項目名稱:serializer,代碼行數:6,代碼來源:PropelCollectionHandler.php


注:本文中的PropelCollection::setData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。