PHP Classes

File: tests/GroupTest.php

Recommend this page to a friend!
  Classes 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:
Date: 1 month ago
Size: 1,261 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

use
Tomloprod\TimeWarden\Group;
use
Tomloprod\TimeWarden\Task;

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);

   
/** @todo comprobar que task tenga el grupo (taskable) */
});

it('can replace the last task', function (): void {
   
$group = new Group('GroupName');

   
$task1 = $group->createTask('TaskName1');
   
$task2 = new Task('TaskName2', $group);

   
$group->replaceLastTask($task2);

   
expect($group->getTasks())
        ->
not->toContain($task1);

   
expect($group->getTasks())
        ->
toContain($task2);
});

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();
});