public function testWhenNotFound() { $resourceId = 8282; $this->repository->expects($this->once())->method('LoadById')->with($this->equalTo($resourceId))->will($this->returnValue(BookableResource::Null())); $this->service->GetResource($resourceId); $this->assertEquals(RestResponse::NotFound(), $this->server->_LastResponse); }
/** * @param $command SqlCommand * @return BookableResource */ private function LoadResource($command) { $reader = ServiceLocator::GetDatabase()->Query($command); $resource = BookableResource::Null(); if ($row = $reader->GetRow()) { $resource = BookableResource::Create($row); $getAttributes = new GetAttributeValuesCommand($resource->GetId(), CustomAttributeCategory::RESOURCE); $attributeReader = ServiceLocator::GetDatabase()->Query($getAttributes); while ($attributeRow = $attributeReader->GetRow()) { $resource->WithAttribute(new AttributeValue($attributeRow[ColumnNames::ATTRIBUTE_ID], $attributeRow[ColumnNames::ATTRIBUTE_VALUE])); } $attributeReader->Free(); } $reader->Free(); return $resource; }