public function testWrite()
 {
     $dispatcher = $this->getNewMockDispatcherCallable([function ($name, Event $event) {
         $this->assertSame(BeanstalkEvents::STREAM_WRITE, $name);
         $this->assertSame("foo\nbar", $event->getWrite());
         $this->assertTrue((bool) preg_match('/\\d+\\.\\d+/', $event->getTime()));
     }, function ($name, Event $event) {
         $this->assertSame(BeanstalkEvents::STREAM_READ, $name);
         $this->assertSame("foo\n", $event->getRead());
         $this->assertTrue((bool) preg_match('/\\d+\\.\\d+/', $event->getTime()));
     }, function ($name, Event $event) {
         $this->assertSame(BeanstalkEvents::STREAM_READ, $name);
         $this->assertSame("bar", $event->getRead());
         $this->assertTrue((bool) preg_match('/\\d+\\.\\d+/', $event->getTime()));
     }]);
     $connection = (new Connection())->setSocket(fopen('php://memory', 'r+'));
     $connection->setDispatcher($dispatcher);
     $configuration = new Configuration(null);
     $configuration->setConnection($connection);
     $manager = (new Manager())->addConfiguration('default', $configuration);
     $this->assertTrue($manager->getConfiguration()->getConnection()->hasDispatcher());
     $manager->getConfiguration()->getConnection()->write("foo\nbar");
     $manager->getConfiguration()->getConnection()->rewind();
     $manager->getConfiguration()->getConnection()->readLine();
     $manager->getConfiguration()->getConnection()->read(3);
 }