/** * @group DataModel * @group CollectionFind * @covers FOF30\Model\DataModel\Collection::find * @dataProvider CollectionDataprovider::getTestFind */ public function testFind($test, $check) { $msg = 'Collection::find %s - Case: ' . $check['case']; $items = $this->buildCollection(); $collection = new Collection($items); $key = $test['key'] == 'object' ? $items[2] : $test['key']; $result = $collection->find($key, $test['default']); if ($check['type'] == 'object') { $this->assertInstanceOf('FOF30\\Model\\DataModel', $result, sprintf($msg, 'Should return an instance of DataModel')); $this->assertEquals($check['result'], $result->getId(), sprintf($msg, 'Failed to return the correct item')); } else { $this->assertSame($check['result'], $result, sprintf($msg, 'Failed to return the correct item')); } }