/**
  * @expectedException \Flow\Exception\DataModelException
  */
 public function testFailingInsert()
 {
     global $wgFlowCacheTime;
     // Catch the exception and test the cache result then re-throw the exception,
     // otherwise the exception would skip the cache result test
     $cache = new BufferedCache(new BufferedBagOStuff(new \HashBagOStuff()), $wgFlowCacheTime);
     try {
         $treeRepository = new TreeRepository($this->mockDbFactory(false), $cache);
         $this->assertNull($treeRepository->insert($this->descendant, $this->ancestor));
     } catch (\Exception $e) {
         $reflection = new ReflectionClass('\\Flow\\Repository\\TreeRepository');
         $method = $reflection->getMethod('cacheKey');
         $method->setAccessible(true);
         $this->assertSame($cache->get($method->invoke($treeRepository, 'rootpath', $this->descendant)), false);
         $this->assertSame($cache->get($method->invoke($treeRepository, 'parent', $this->descendant)), false);
         throw $e;
     }
 }