public function setUp() { $this->project = Project::fetch(self::$conn, 1); $this->status = AreaStatus::fetchByProject(self::$conn, 1, $this->project); $this->territory = Territory::fetchByProject(self::$conn, 1, $this->project); $this->area = Area::newArea($this->project, $this->territory, $this->status, 'Area1'); $this->area->insert(self::$conn); $pp = new CourseProgress($this->area); $pp->insert(self::$conn); }
public static function fetchById(Connection $conn, $id) { $data = $conn->fetchAssoc('SELECT * FROM `' . ExportTables::DATA_EXPORT_TBL . '` WHERE `id` = :id', [':id' => $id]); if (false === $data) { return false; } $item = self::fromArray($data); $item->project = Project::fetch($conn, $data['projectId']); $item->areaStatus = AreaStatus::fetchByProject($conn, $data['areaStatusId'], $item->project); return $item; }
public static function fetchByRequestor(Connection $conn, $id, User $requestor) { $data = $conn->fetchAssoc('SELECT r.*, v.id AS `verifier_id`, v.`name` AS `verifier_name`, ' . 't.`id` AS `territory_id`, t.`name` AS `territory_name`, t.`areaNum` AS `territory_areaNum`, t.`requestNum` as `territory_requestNum` ' . 'FROM `' . CoreTables::AREA_REQUEST_TBL . '` r ' . 'INNER JOIN `' . CoreTables::TERRITORY_TBL . '` t ON t.`id` = r.`territoryId` ' . 'LEFT JOIN `' . CoreTables::USER_TBL . '` v ON v.`id` = r.`verifierId` ' . 'WHERE r.`id` = :id AND r.`requestorId` = :requestorId', [':id' => $id, ':requestorId' => $requestor->getId()]); if (null === $data) { return false; } $project = Project::fetch($conn, $data['projectId']); $item = self::fromArray($data); $item->setProject($project); $item->setRequestor($requestor); if (!empty($data['verifier_id'])) { $item->verifier = new Verifier($data['verifier_id'], $data['verifier_name']); } $item->setTerritory($item->oldTerritory = Territory::fromArray($data, 'territory')); return $item; }
public function setUp() { $this->project = Project::fetch(self::$conn, 1); $this->status = AreaStatus::fetchByProject(self::$conn, 1, $this->project); $this->territory = Territory::fetchByProject(self::$conn, 1, $this->project); $this->area = Area::newArea($this->project, $this->territory, $this->status, 'Area1'); $this->area->insert(self::$conn); $this->area2 = Area::newArea($this->project, $this->territory, $this->status, 'Area2'); $lang = new Language(); $lang->setId(1); $this->user = User::newUser('login', 'Some user', $lang); $this->user->insert(self::$conn); $this->user2 = User::newUser('login2', 'Another user', $lang); $this->user2->insert(self::$conn); $tpa1 = new CourseProgress($this->area); $tpa1->insert(self::$conn); }
public function setUp() { $this->project = Project::fetch(self::$conn, 1); $this->status = AreaStatus::fetchByProject(self::$conn, 1, $this->project); $this->territory = Territory::fetchByProject(self::$conn, 1, $this->project); $this->area = Area::newArea($this->project, $this->territory, $this->status, 'Area1'); $this->area->insert(self::$conn); $this->course = new Course(); $this->course->setProject($this->project); $this->course->setName('Foo'); $this->course->setAuthorName('Foo'); $this->course->setAuthorEmail('*****@*****.**'); $this->course->setPresentationLink('http://www.example.com/'); $this->course->setIsPublished(true); $this->course->insert(self::$conn); $lang = new Language(); $lang->setId(1); $this->user = User::newUser('login', 'Some user', $lang); $this->user->insert(self::$conn); $this->anotherUser = User::newUser('login2', 'Another user', $lang); $this->anotherUser->insert(self::$conn); $pp = new CourseProgress($this->area); $pp->insert(self::$conn); }