promotion = new Promotion(); } #[\PHPUnit\Framework\Attributes\Group('module')] public function testDefault() : void { self::assertEquals(0, $this->promotion->id); self::assertInstanceOf('\Modules\Calendar\Models\Calendar', $this->promotion->calendar); self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->promotion->start->format('Y-m-d')); self::assertEquals((new \DateTime('now'))->modify('+1 month')->format('Y-m-d'), $this->promotion->end->format('Y-m-d')); self::assertEquals(0, $this->promotion->budgetCosts->getInt()); self::assertEquals(0, $this->promotion->budgetEarnings->getInt()); self::assertEquals(0, $this->promotion->actualCosts->getInt()); self::assertEquals(0, $this->promotion->actualEarnings->getInt()); self::assertEmpty($this->promotion->tasks); self::assertEmpty($this->promotion->files); self::assertEquals(0, $this->promotion->progress); self::assertEquals(ProgressType::MANUAL, $this->promotion->getProgressType()); } #[\PHPUnit\Framework\Attributes\Group('module')] public function testProgressInputOutput() : void { $this->promotion->progress = 10; self::assertEquals(10, $this->promotion->progress); } #[\PHPUnit\Framework\Attributes\Group('module')] public function testProgressTypeInputOutput() : void { $this->promotion->setProgressType(ProgressType::TASKS); self::assertEquals(ProgressType::TASKS, $this->promotion->getProgressType()); } #[\PHPUnit\Framework\Attributes\Group('module')] public function testSerialize() : void { $this->promotion->name = 'Name'; $this->promotion->description = 'Description'; $this->promotion->start = new \DateTime(); $this->promotion->end = new \DateTime(); $this->promotion->progress = 10; $this->promotion->setProgressType(ProgressType::TASKS); $serialized = $this->promotion->jsonSerialize(); unset($serialized['calendar']); unset($serialized['createdAt']); self::assertEquals( [ 'id' => 0, 'start' => $this->promotion->start, 'end' => $this->promotion->end, 'name' => 'Name', 'description' => 'Description', 'budgetCosts' => new FloatInt(), 'budgetEarnings' => new FloatInt(), 'actualCosts' => new FloatInt(), 'actualEarnings' => new FloatInt(), 'tasks' => [], 'media' => [], 'progress' => 10, 'progressType' => ProgressType::TASKS, ], $serialized ); } }