public function testCollectionGroupBy() { $name = new Name(); for ($i = 0; $i < 5; $i++) { $ret = $name->create(array('name' => 'Foo', 'address' => 'Addr1', 'country' => 'Taiwan')); $this->assertResultSuccess($ret); } $names = new NameCollection(); $names->setSelect('name')->where()->equal('name', 'Foo'); $names->groupBy(['name', 'address']); $this->assertCollectionSize(1, $names); $items = $names->items(); $this->assertNotEmpty($items); is('Foo', $items[0]->name); }
/** * @dataProvider nameDataProvider * @rebuild false */ public function testFromArray($args) { $instance = \TestApp\Model\Name::fromArray(array($args)); ok($instance); isa_ok('TestApp\\Model\\Name', $instance); $collection = \TestApp\Model\NameCollection::fromArray(array($args, $args)); isa_ok('TestApp\\Model\\NameCollection', $collection); }
/** * @dataProvider nameDataProvider * @rebuild false */ public function testFromArray($args) { $instance = \TestApp\Model\Name::fromArray(array($args)); $this->assertInstanceOf('TestApp\\Model\\Name', $instance); $collection = \TestApp\Model\NameCollection::fromArray(array($args, $args)); $this->assertInstanceOf('TestApp\\Model\\NameCollection', $collection); }