/** * Tests entity if execution of command createSubdirectory and search works */ public function testEntityExecutionCreateSubdirectoryWithSearch() { $entityType = '\\AppserverIo\\Concurrency\\ExecutorService\\Entities\\NamingDirectory'; $namingDirectory = ExS\Core::newFromEntity($entityType, 'namingDirectory'); $namingDirectory->createSubdirectory('test'); $testDir = $namingDirectory->search('test'); $this->assertInstanceOf('\\AppserverIo\\Concurrency\\ExecutorService\\Entities\\NamingDirectory', $testDir); }
/** * Test entity execution with circular referencing itself * * @return void */ public function testEntityExecutionWithCircularReferences() { $entityType = '\\stdClass'; $stdClass = ExS\Core::newFromEntity($entityType); $stdClass->__invoke(function ($self) { $self->self = $self; }); $returnedStdClass = $stdClass->__return(); $this->assertInstanceOf($entityType, $returnedStdClass); }
/** * Contructor * * @param string $entityType The entity type class to use as entity object * @param string $autoloader The path to the autoloaders class to require * @param string $startFlags The start flags used for starting threads */ public function __construct($entityType, $autoloader = null, $startFlags = null) { // init properties $this->__callbackAllowed = false; $this->__entityType = $entityType; $this->__autoloader = $autoloader; // init entity Core::initEntityAnnotations($this, $entityType); $this->__entityInstance = new $entityType(); $this->__serializedEntityInstance = serialize($this->__entityInstance); // init start flags if (is_null($startFlags)) { $startFlags = PTHREADS_INHERIT_ALL | PTHREADS_ALLOW_GLOBALS; } // start thread routine $this->start($startFlags); }
/** * Test getEntity function when created before and ExS was initialised * * @return void */ public function testGetEntityCreatedBeforeInitialised() { $entityType = '\\AppserverIo\\Concurrency\\ExecutorService\\Entities\\Storage'; ExS\Core::init(); ExS\Core::newFromEntity($entityType, 'storage'); $exSentity = ExS\Core::getEntity('storage'); $this->assertInstanceOf('\\AppserverIo\\Concurrency\\ExecutorService', $exSentity); }
/** * (non-PHPdoc) * @see PHPUnit_Framework_TestCase::tearDown() */ public function tearDown() { // shutdown ExecutorService ExS\Core::shutdown(); }