public function testInnoDBConvert()
 {
     $result = $this->countMyIsamTables();
     $this->assertEquals(1, $result);
     /** @var IOutput | \PHPUnit_Framework_MockObject_MockObject $outputMock */
     $outputMock = $this->getMockBuilder('\\OCP\\Migration\\IOutput')->disableOriginalConstructor()->getMock();
     $this->repair->run($outputMock);
     $result = $this->countMyIsamTables();
     $this->assertEquals(0, $result);
 }
 /**
  * Test remove shares where the parent share does not exist anymore
  */
 public function testSharesNonExistingParent()
 {
     $qb = $this->connection->getQueryBuilder();
     $shareValues = ['share_type' => $qb->expr()->literal(Constants::SHARE_TYPE_USER), 'share_with' => $qb->expr()->literal('recipientuser1'), 'uid_owner' => $qb->expr()->literal('user1'), 'item_type' => $qb->expr()->literal('folder'), 'item_source' => $qb->expr()->literal(123), 'item_target' => $qb->expr()->literal('/123'), 'file_source' => $qb->expr()->literal(123), 'file_target' => $qb->expr()->literal('/test'), 'permissions' => $qb->expr()->literal(1), 'stime' => $qb->expr()->literal(time()), 'expiration' => $qb->expr()->literal('2015-09-25 00:00:00')];
     // valid share
     $qb = $this->connection->getQueryBuilder();
     $qb->insert('share')->values($shareValues)->execute();
     $parent = $this->getLastShareId();
     // share with existing parent
     $qb = $this->connection->getQueryBuilder();
     $qb->insert('share')->values(array_merge($shareValues, ['parent' => $qb->expr()->literal($parent)]))->execute();
     $validChild = $this->getLastShareId();
     // share with non-existing parent
     $qb = $this->connection->getQueryBuilder();
     $qb->insert('share')->values(array_merge($shareValues, ['parent' => $qb->expr()->literal($parent + 100)]))->execute();
     $invalidChild = $this->getLastShareId();
     $query = $this->connection->getQueryBuilder();
     $result = $query->select('id')->from('share')->orderBy('id', 'ASC')->execute();
     $rows = $result->fetchAll();
     $this->assertEquals([['id' => $parent], ['id' => $validChild], ['id' => $invalidChild]], $rows);
     $result->closeCursor();
     /** @var IOutput | \PHPUnit_Framework_MockObject_MockObject $outputMock */
     $outputMock = $this->getMockBuilder('\\OCP\\Migration\\IOutput')->disableOriginalConstructor()->getMock();
     $this->repair->run($outputMock);
     $query = $this->connection->getQueryBuilder();
     $result = $query->select('id')->from('share')->orderBy('id', 'ASC')->execute();
     $rows = $result->fetchAll();
     $this->assertEquals([['id' => $parent], ['id' => $validChild]], $rows);
     $result->closeCursor();
 }
 private function renameMimeTypes($currentMimeTypes, $fixedMimeTypes)
 {
     $this->addEntries($currentMimeTypes);
     /** @var IOutput | \PHPUnit_Framework_MockObject_MockObject $outputMock */
     $outputMock = $this->getMockBuilder('\\OCP\\Migration\\IOutput')->disableOriginalConstructor()->getMock();
     $this->repair->run($outputMock);
     // force mimetype reload
     $this->mimetypeLoader->reset();
     $this->checkEntries($fixedMimeTypes);
 }
 /**
  * Test merge shares from group shares
  *
  * @dataProvider sharesDataProvider
  */
 public function testMergeGroupShares($shares, $expectedShares)
 {
     $shareIds = [];
     foreach ($shares as $share) {
         // if parent
         if (isset($share[5])) {
             // adjust to real id
             $share[5] = $shareIds[$share[5]];
         } else {
             $share[5] = null;
         }
         $shareIds[] = $this->createShare($share[0], $share[1], $share[2], $share[3], $share[4], $share[5]);
     }
     /** @var IOutput | \PHPUnit_Framework_MockObject_MockObject $outputMock */
     $outputMock = $this->getMockBuilder('\\OCP\\Migration\\IOutput')->disableOriginalConstructor()->getMock();
     $this->repair->run($outputMock);
     foreach ($expectedShares as $index => $expectedShare) {
         $share = $this->getShareById($shareIds[$index]);
         $this->assertEquals($expectedShare[0], $share['file_target']);
         $this->assertEquals($expectedShare[1], $share['permissions']);
     }
 }