Example #1
0
 /**
  * @dataProvider getPlugins
  *
  * @param string $method
  * @param string $event
  * @param array $data
  */
 public function testAddNewPlugin($method, $event, array $data)
 {
     $that = $this;
     // check download logo
     if ($data['logo']) {
         $this->downloader->expects($this->once())->method('entity')->will($this->returnCallback(function ($logo, $plugin, $override) use($that, $data) {
             $that->assertEquals($data['logo'], $logo);
             $that->assertTrue($override);
             $that->checkNewPlugin($plugin, $data);
         }));
     }
     $this->rep->expects($this->once())->method('find')->will($this->returnValue(null))->with('foo/bar');
     $this->em->expects($this->once())->method('persist')->will($this->returnCallback(function ($plugin) use($that, $data) {
         $that->checkNewPlugin($plugin, $data);
     }));
     $this->em->expects($this->once())->method('flush');
     $this->client->expects($this->once())->method('getPlugin')->with('foo', 'bar')->will($this->returnValue($data));
     // test
     call_user_func([$this->listener, $method], $this->getEvent($this->getPackage($this->exactly(2)), $event));
 }