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'); }