/** * @param string $name * @param string $text * @param string $locale * * @return Content */ private function create($name, $text, $locale) { $content = new Content(); $content->setName($name)->setText($text)->setLocale($locale); $this->om->persist($content); $this->om->flush($content); return $content; }
public function testGetDetachesNewObject() { $manager = new ContentManager($this->om); $this->repository->method('findOneBy')->with(['name' => 'name', 'locale' => 'en'])->willReturn(null); $content = new Content(); $content->setName('name')->setText('text')->setLocale('en'); $this->om->expects($this->once())->method('detach')->with($this->callback(function ($value) use($content) { return $value == $content; })); $manager->get('name', 'en', 'text'); }