Since: 1.0
Author: Bernhard Schussek (bschussek@gmail.com)
Inheritance: implements Webmozart\Console\Api\IO\OutputStream
Exemplo n.º 1
0
 public function testWriteLineRawDoesNotFormatText()
 {
     $formatter = $this->getMock('Webmozart\\Console\\Api\\Formatter\\Formatter');
     $formatter->expects($this->never())->method('format');
     $this->output->setFormatter($formatter);
     $this->output->writeLineRaw('<tag>text</tag>');
     $this->assertSame('<tag>text</tag>' . PHP_EOL, $this->stream->fetch());
 }
 public function testClear()
 {
     $stream = new BufferedOutputStream();
     $stream->write('Lorem');
     $stream->clear();
     $stream->write('ipsum');
     $stream->close();
     $this->assertSame('ipsum', $stream->fetch());
 }
Exemplo n.º 3
0
 /**
  * Test MigrationsStatus method.
  */
 public function testMigrationsStatus()
 {
     $this->migrationsDirectory = __DIR__ . '/../EmptyMigrations';
     $this->given($service = $this->createService())->and($command = new MigrationsStatusCommand())->and($command->setIo($this->getIO()))->when($service->migrationsStatus($command))->then()->string($this->output->fetch())->contains(' Current Version      <c2>0</c2>')->contains(' Latest Version       <c2>none</c2>')->contains(' Next Version         <c2>none</c2>')->contains(' Executed Migrations  <c2>0</c2>')->contains(' Available Migrations <c2>0</c2>')->contains(' New Migrations       <c2>0</c2>');
     $this->migrationsDirectory = __DIR__ . '/../../../Fixtures/Event';
     $this->given($service = $this->createService())->and($command = new MigrationsStatusCommand())->and($command->setIo($this->getIO()))->when($service->migrationsStatus($command))->then()->string($this->output->fetch())->contains('Invalid migration directory');
     $this->migrationsDirectory = __DIR__ . '/../../../Fixtures/Migrations';
     $this->given($service = $this->createService())->and($command = new MigrationsStatusCommand())->and($command->setIo($this->getIO()))->when($service->migrationsStatus($command))->then()->string($this->output->fetch())->contains(' Current Version      <c2>0</c2>')->contains(' Latest Version       <c2>1.1.0</c2>')->contains(' Next Version         <c2>0.1.0</c2>')->contains(' Executed Migrations  <c2>0</c2>')->contains(' Available Migrations <c2>4</c2>')->contains(' New Migrations       <c2>4</c2>');
     require_once __DIR__ . '/../../../Fixtures/BlogEventSourced.php';
     $aggregates = [PostEventSourced::class, \BlogEventSourced::class];
     $migratorStore = new InMemoryMigrationStore();
     $migratorStore->persist(new Migration($aggregates, Version::fromString('0.1.0'), \DateTime::createFromFormat('Y-m-d H:i:s', '2016-08-26 14:12:00')));
     $migratorStore->persist(new Migration($aggregates, Version::fromString('0.2.0'), \DateTime::createFromFormat('Y-m-d H:i:s', '2016-09-01 18:30:00')));
     $migrator = new Migrator($this->getClassMetadataFactory(), $migratorStore, new InMemoryEventStore(), $this->migrationsDirectory);
     $service = new MigrationsService($migrator);
     $this->given($command = new MigrationsStatusCommand())->and($command->setIo($this->getIO()))->when($service->migrationsStatus($command))->then()->string($this->output->fetch())->contains(' Current Version      <c2>0.2.0 (2016-09-01 18:30:00)</c2>')->contains(' Latest Version       <c2>1.1.0</c2>')->contains(' Next Version         <c2>1.0.0</c2>')->contains(' Executed Migrations  <c2>2</c2>')->contains(' Available Migrations <c2>4</c2>')->contains(' New Migrations       <c2>2</c2>');
 }