PHP Classes

File: tests/GroupTest.php

Recommend this page to a friend!
  Packages of tomloprod   Time Warden   tests/GroupTest.php   Download  
File: tests/GroupTest.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Time Warden
Measure PHP execution time and invoke callbacks
Author: By
Last change: chore: coding style changes
ref: replace task substitution system

Delete the `replaceLastTask` method and simply change the name of the last empty task when creating a new one.
chore: code style on GroupTest
test: created task belongs to group (taskable)
Date: 5 months ago
Size: 830 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

use
Tomloprod\TimeWarden\Group;

it('can be created with a name', function (): void {
   
$group = new Group('GroupName');

   
expect($group->name)->toBe('GroupName');
});

it('can add a task', function (): void {
   
$group = new Group('GroupName');
   
$task = $group->createTask('TaskName');

   
expect($group->getTasks())->toContain($task);

   
expect($task->getTaskable())->toBe($group);
});

it('can start the last task if it exists', function (): void {
   
$group = new Group('GroupName');
   
$task = $group->createTask('TaskName');

   
$group->start();

   
expect($task->hasStarted())->toBeTrue();
});

it('does not start any task if no tasks exist', function (): void {
   
$group = new Group('GroupName');

   
$group->start();

   
expect($group->getLastTask())->toBeNull();
});