public function testBasic() { $item = new Item('test-simple'); $this->assertSame('test-simple', $item->getTitle()); $this->assertSame($item, $item->setTitle('tested')); $this->assertSame('tested', $item->getTitle()); $this->assertFalse($item->isHandled()); $this->assertInstanceOf(StateInit::class, $item->getState()); $this->assertEmpty($item->getStatistics()); $this->assertFalse($item->hasStatistics(self::class)); $this->assertSame($item, $item->setStatistic(self::class, 'test1', 'a')); $this->assertSame('a', $item->getStatistic(self::class, 'test1')); $this->assertSame($item, $item->deleteStatistic(self::class, 'test1')); $this->assertNull($item->getStatistic(self::class, 'test1')); $this->expectOutputString('onFinish'); $this->assertSame($item, $item->attach($this)); $this->assertSame($item, $item->detach($this)); $item->attach($this); $this->assertSame($item, $item->start()); $this->assertInstanceOf(StateRunning::class, $item->getState()); $this->assertSame($item, $item->pause()); $this->assertInstanceOf(StatePaused::class, $item->getState()); $this->assertSame($item, $item->resume()); $this->assertInstanceOf(StateRunning::class, $item->getState()); $this->assertSame($item, $item->stop()); $this->assertInstanceOf(StateStopped::class, $item->getState()); }
/** * @param Item $item */ public function onFinish(Item $item) { $this->logger->addRecord($this->level, $item->getTitle(), $item->getStatistics()); $item->setHandled(true); }