PHP Classes

File: test/ForkManagerEventTest.php

Recommend this page to a friend!
  Classes of nvb   Process Fork Manager for PHP   test/ForkManagerEventTest.php   Download  
File: test/ForkManagerEventTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: Process Fork Manager for PHP
Run parallel processes and manage their execution
Author: By
Last change:
Date: 8 years ago
Size: 2,360 bytes
 

Contents

Class file image Download
<?php
/**
 * @author stev leibelt <artodeto@bazzline.net>
 * @since 2014-08-05
 */

namespace Test\Net\Bazzline\Component\ProcessForkManager;

use
Net\Bazzline\Component\ProcessForkManager\ForkManagerEvent;

/**
 * Class ForkManagerEventTest
 * @package Test\Net\Bazzline\Component\ProcessForkManager
 */
class ForkManagerEventTest extends ForkManagerTestCase
{
    public function
testGetHasAndSetForkManager()
    {
       
$event = $this->getNewEvent();
       
$manager = $this->getMockOfForkManager();

       
$this->assertFalse($event->hasForkManager());
       
$this->assertNull($event->getForkManager());

       
$event->setForkManager($manager);

       
$this->assertTrue($event->hasForkManager());
       
$this->assertEquals($manager, $event->getForkManager());
    }

    public function
testGetHasAndSetSource()
    {
       
$event = $this->getNewEvent();
       
$source = __METHOD__;

       
$this->assertFalse($event->hasSource());
       
$this->assertNull($event->getSource());

       
$event->setSource($source);

       
$this->assertTrue($event->hasSource());
       
$this->assertEquals($source, $event->getSource());
    }

    public function
testGetHasAndSetTask()
    {
       
$event = $this->getNewEvent();
       
$task = $this->getMockOfAbstractTask();

       
$this->assertFalse($event->hasTask());
       
$this->assertNull($event->getTask());

       
$event->setTask($task);

       
$this->assertTrue($event->hasTask());
       
$this->assertEquals($task, $event->getTask());
    }

    public function
testClone()
    {
       
$firstEvent = $this->getNewEvent();
       
$firstEvent->setForkManager($this->getMockOfForkManager());
       
$firstEvent->setSource(__METHOD__);
       
$firstEvent->setTask($this->getMockOfAbstractTask());

       
$this->assertTrue($firstEvent->hasForkManager());
       
$this->assertTrue($firstEvent->hasSource());
       
$this->assertTrue($firstEvent->hasTask());

       
$secondEvent = clone $firstEvent;

       
$this->assertNotEquals($firstEvent, $secondEvent);
       
$this->assertFalse($secondEvent->hasForkManager());
       
$this->assertFalse($secondEvent->hasSource());
       
$this->assertFalse($secondEvent->hasTask());
    }

   
/**
     * @return ForkManagerEvent
     */
   
private function getNewEvent()
    {
        return new
ForkManagerEvent();
    }
}