public function testOnTerminate()
 {
     $track_clear_cache = true;
     $this->keeper->expects($this->once())->method('set')->with(Keeper::LAST_UPDATE_KEY, $this->isInstanceOf(\DateTime::class));
     $this->event->expects($this->once())->method('getCommand')->will($this->returnValue($this->command));
     $this->command->expects($this->once())->method('getName')->will($this->returnValue('cache:clear'));
     $listener = new ConsoleListener($this->keeper, $track_clear_cache);
     $listener->onTerminate($this->event);
 }
 public function testExecute()
 {
     /** @var $input \PHPUnit_Framework_MockObject_MockObject|InputInterface */
     $input = $this->getMock(InputInterface::class);
     /** @var $output \PHPUnit_Framework_MockObject_MockObject|OutputInterface */
     $output = $this->getMock(OutputInterface::class);
     $output->expects($this->once())->method('writeln')->with('Reset last update date of the project is complete.');
     $this->keeper->expects($this->once())->method('set')->will($this->returnCallback(function ($key, $time) {
         $this->assertEquals(Keeper::LAST_UPDATE_KEY, $key);
         $this->assertInstanceOf(\DateTime::class, $time);
         $this->assertTrue($time >= new \DateTime('-1 second'));
         return true;
     }));
     $this->command->run($input, $output);
 }
 /**
  * @dataProvider getTrackMethods
  *
  * @param string $method
  * @param bool $track_individually
  * @param bool $remove
  * @param array $ids
  */
 public function testHandleEvent($method, $track_individually, $remove, array $ids)
 {
     $alias = 'foo';
     $this->keeper->expects($this->at(0))->method('set')->with($alias, $this->isInstanceOf('DateTime'));
     $this->builder->expects($this->once())->method('getEntityAlias')->with($this->entity)->will($this->returnValue($alias));
     if ($track_individually) {
         $suffix = implode(',', $ids);
         $this->builder->expects($this->once())->method('getEntityIdentifier')->with($this->entity)->will($this->returnValue($suffix));
         if ($suffix) {
             if ($remove) {
                 $this->keeper->expects($this->once())->method('remove')->with($alias . $suffix);
             } else {
                 $this->keeper->expects($this->at(1))->method('set')->with($alias . $suffix, $this->isInstanceOf('DateTime'));
             }
         }
     } else {
         $this->builder->expects($this->never())->method('getEntityIdentifier');
     }
     $listener = new DoctrineListener($this->keeper, $this->builder, $track_individually);
     call_user_func([$listener, $method], $this->args);
 }