public function getFile() { if (!$this->_file && $this->_value) { $this->_file = $this->_loader->getByID((int) $this->_value); } return $this->_file; }
public function testGetByID() { $file = $this->_loader->includeDeleted(true)->getByID(1); $this->assertTrue($file instanceof File); $this->assertTrue($file->id == 1); $ids = array(1, 2, 3, 4); $files = $this->_loader->includeDeleted(true)->getByID($ids); $this->assertTrue(is_array($files)); foreach ($files as $file) { $this->assertTrue($file instanceof File); } $connection = new FauxConnection(); $connection->setPattern('/file_id([\\s]+?)= [0-9]/us', array(array('id' => 1, 'name' => 'test', 'extension' => 'jpg', 'fileSize' => 12344, 'createdAt' => strtotime('+2 day'), 'createdBy' => 1, 'updatedAt' => strtotime('+1 day'), 'updatedBy' => 1, 'deletedAt' => time(), 'deletedBy' => 1))); $loader = new Loader('gb', new Query($connection)); $page = $loader->getByID(1); $this->assertFalse($page); $connection = new FauxConnection(); $connection->setPattern('/file_id([\\s]+?)= [0-9]/us', array()); $loader = new Loader('gb', new Query($connection)); $page = $loader->getByID(1); $this->assertFalse($page); }