/**
  * @covers phpDocumentor\Descriptor\DescriptorAbstract::setLocation
  * @covers phpDocumentor\Descriptor\DescriptorAbstract::getFile
  * @covers phpDocumentor\Descriptor\DescriptorAbstract::getLine
  */
 public function testSettingAndGettingLocation()
 {
     $this->assertNull($this->fixture->getFile());
     $this->assertSame(0, $this->fixture->getLine());
     $this->fixture->setLocation(m::mock('phpDocumentor\\Descriptor\\FileDescriptor'), 5);
     $this->assertInstanceOf('phpDocumentor\\Descriptor\\FileDescriptor', $this->fixture->getFile());
     $this->assertSame(5, $this->fixture->getLine());
 }
 /**
  * Retrieves the File Descriptor from the given element.
  *
  * @param DescriptorAbstract $element
  *
  * @throws \UnexpectedValueException if the provided element does not have a file associated with it.
  *
  * @return FileDescriptor
  */
 protected function getFileDescriptor($element)
 {
     $fileDescriptor = $element instanceof FileDescriptor ? $element : $element->getFile();
     if (!$fileDescriptor instanceof FileDescriptor) {
         throw new \UnexpectedValueException('An element should always have a file associated with it');
     }
     return $fileDescriptor;
 }
 /**
  * Returns the file associated with the parent class, interface or trait when inside a container.
  *
  * @return FileDescriptor
  */
 public function getFile()
 {
     return parent::getFile() ?: $this->getParent()->getFile();
 }
 /**
  * Creates a DocBlock context containing the namespace and aliases for the current descriptor.
  *
  * @return Context
  */
 private function createDocBlockContext()
 {
     $file = $this->descriptor->getFile();
     $namespaceAliases = $file ? $file->getNamespaceAliases()->getAll() : array();
     return new Context($this->descriptor->getNamespace(), $namespaceAliases);
 }