public function testGetAll() { $connection = new FauxConnection(); // For testDuplicateFieldNameException $connection->setPattern('/SELECT file_id FROM file/us', array(array('file_id' => 1), array('file_id' => 2))); $connection->setPattern('/file_id([\\s]+?)= [0-9]/us', array(array('id' => 1, 'name' => 'test', 'extension' => 'jpg', 'fileSize' => 12344, 'createdAt' => strtotime('+1 day'), 'createdBy' => 1, 'updatedAt' => null, 'updatedBy' => null, 'deletedAt' => null, 'deletedBy' => null), array('id' => 2, 'name' => 'test', 'extension' => 'jpg', 'fileSize' => 12344, 'createdAt' => strtotime('+1 day'), 'createdBy' => 1, 'updatedAt' => null, 'updatedBy' => null, 'deletedAt' => null, 'deletedBy' => null))); $loader = new Loader('gb', new Query($connection)); $all = $loader->getAll(); $this->assertTrue(is_array($all)); $this->assertEquals(count($all), 2); foreach ($all as $file) { $this->assertTrue($file instanceof File); } }
protected function _getChoices() { static $files; if (null === $files) { $files = $this->_loader->getAll(); } if (!$files) { $files = []; return $files; } $choices = []; foreach ($files as $file) { if ($this->_allowedTypes) { if (!in_array($file->typeID, $this->_allowedTypes)) { continue; } } $choices[$file->id] = $file->name; } asort($choices); return $choices; }