Fix deprecated method in tests

This commit is contained in:
Jeremy Benoist
2020-06-15 13:37:50 +02:00
parent 7332d1f4e5
commit 732ec8a2eb
44 changed files with 314 additions and 326 deletions

View File

@ -22,8 +22,8 @@ class CleanDuplicatesCommandTest extends WallabagCoreTestCase
'command' => $command->getName(),
]);
$this->assertContains('Cleaning through 3 user accounts', $tester->getDisplay());
$this->assertContains('Finished cleaning. 0 duplicates found in total', $tester->getDisplay());
$this->assertStringContainsString('Cleaning through 3 user accounts', $tester->getDisplay());
$this->assertStringContainsString('Finished cleaning. 0 duplicates found in total', $tester->getDisplay());
}
public function testRunCleanDuplicatesCommandWithBadUsername()
@ -39,7 +39,7 @@ class CleanDuplicatesCommandTest extends WallabagCoreTestCase
'username' => 'unknown',
]);
$this->assertContains('User "unknown" not found', $tester->getDisplay());
$this->assertStringContainsString('User "unknown" not found', $tester->getDisplay());
}
public function testRunCleanDuplicatesCommandForUser()
@ -55,7 +55,7 @@ class CleanDuplicatesCommandTest extends WallabagCoreTestCase
'username' => 'admin',
]);
$this->assertContains('Cleaned 0 duplicates for user admin', $tester->getDisplay());
$this->assertStringContainsString('Cleaned 0 duplicates for user admin', $tester->getDisplay());
}
public function testDuplicate()
@ -96,7 +96,7 @@ class CleanDuplicatesCommandTest extends WallabagCoreTestCase
'username' => 'admin',
]);
$this->assertContains('Cleaned 1 duplicates for user admin', $tester->getDisplay());
$this->assertStringContainsString('Cleaned 1 duplicates for user admin', $tester->getDisplay());
$nbEntries = $em->getRepository('WallabagCoreBundle:Entry')->findAllByUrlAndUserId($url, $this->getLoggedInUserId());
$this->assertCount(1, $nbEntries);

View File

@ -9,12 +9,11 @@ use Wallabag\CoreBundle\Command\ExportCommand;
class ExportCommandTest extends WallabagCoreTestCase
{
/**
* @expectedException \Symfony\Component\Console\Exception\RuntimeException
* @expectedExceptionMessage Not enough arguments (missing: "username")
*/
public function testExportCommandWithoutUsername()
{
$this->expectException(\Symfony\Component\Console\Exception\RuntimeException::class);
$this->expectExceptionMessage('Not enough arguments (missing: "username")');
$application = new Application($this->getClient()->getKernel());
$application->add(new ExportCommand());
@ -39,7 +38,7 @@ class ExportCommandTest extends WallabagCoreTestCase
'username' => 'unknown',
]);
$this->assertContains('User "unknown" not found', $tester->getDisplay());
$this->assertStringContainsString('User "unknown" not found', $tester->getDisplay());
}
public function testExportCommand()
@ -55,8 +54,8 @@ class ExportCommandTest extends WallabagCoreTestCase
'username' => 'admin',
]);
$this->assertContains('Exporting 5 entrie(s) for user admin...', $tester->getDisplay());
$this->assertContains('Done', $tester->getDisplay());
$this->assertStringContainsString('Exporting 5 entrie(s) for user admin...', $tester->getDisplay());
$this->assertStringContainsString('Done', $tester->getDisplay());
$this->assertFileExists('admin-export.json');
}

View File

@ -22,8 +22,8 @@ class GenerateUrlHashesCommandTest extends WallabagCoreTestCase
'command' => $command->getName(),
]);
$this->assertContains('Generating hashed urls for "3" users', $tester->getDisplay());
$this->assertContains('Finished generated hashed urls', $tester->getDisplay());
$this->assertStringContainsString('Generating hashed urls for "3" users', $tester->getDisplay());
$this->assertStringContainsString('Finished generated hashed urls', $tester->getDisplay());
}
public function testRunGenerateUrlHashesCommandWithBadUsername()
@ -39,7 +39,7 @@ class GenerateUrlHashesCommandTest extends WallabagCoreTestCase
'username' => 'unknown',
]);
$this->assertContains('User "unknown" not found', $tester->getDisplay());
$this->assertStringContainsString('User "unknown" not found', $tester->getDisplay());
}
public function testRunGenerateUrlHashesCommandForUser()
@ -55,7 +55,7 @@ class GenerateUrlHashesCommandTest extends WallabagCoreTestCase
'username' => 'admin',
]);
$this->assertContains('Generated hashed urls for user: admin', $tester->getDisplay());
$this->assertStringContainsString('Generated hashed urls for user: admin', $tester->getDisplay());
}
public function testGenerateUrls()
@ -85,7 +85,7 @@ class GenerateUrlHashesCommandTest extends WallabagCoreTestCase
'username' => 'admin',
]);
$this->assertContains('Generated hashed urls for user: admin', $tester->getDisplay());
$this->assertStringContainsString('Generated hashed urls for user: admin', $tester->getDisplay());
$entry = $em->getRepository('WallabagCoreBundle:Entry')->findOneByUrl($url);

View File

@ -103,10 +103,10 @@ class InstallCommandTest extends WallabagCoreTestCase
'command' => $command->getName(),
]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
$this->assertContains('Administration setup.', $tester->getDisplay());
$this->assertContains('Config setup.', $tester->getDisplay());
$this->assertStringContainsString('Checking system requirements.', $tester->getDisplay());
$this->assertStringContainsString('Setting up database.', $tester->getDisplay());
$this->assertStringContainsString('Administration setup.', $tester->getDisplay());
$this->assertStringContainsString('Config setup.', $tester->getDisplay());
}
public function testRunInstallCommandWithReset()
@ -128,14 +128,14 @@ class InstallCommandTest extends WallabagCoreTestCase
'--reset' => true,
]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
$this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay());
$this->assertContains('Administration setup.', $tester->getDisplay());
$this->assertContains('Config setup.', $tester->getDisplay());
$this->assertStringContainsString('Checking system requirements.', $tester->getDisplay());
$this->assertStringContainsString('Setting up database.', $tester->getDisplay());
$this->assertStringContainsString('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay());
$this->assertStringContainsString('Administration setup.', $tester->getDisplay());
$this->assertStringContainsString('Config setup.', $tester->getDisplay());
// we force to reset everything
$this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay());
$this->assertStringContainsString('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay());
}
public function testRunInstallCommandWithDatabaseRemoved()
@ -174,13 +174,13 @@ class InstallCommandTest extends WallabagCoreTestCase
'command' => $command->getName(),
]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
$this->assertContains('Administration setup.', $tester->getDisplay());
$this->assertContains('Config setup.', $tester->getDisplay());
$this->assertStringContainsString('Checking system requirements.', $tester->getDisplay());
$this->assertStringContainsString('Setting up database.', $tester->getDisplay());
$this->assertStringContainsString('Administration setup.', $tester->getDisplay());
$this->assertStringContainsString('Config setup.', $tester->getDisplay());
// the current database doesn't already exist
$this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay());
$this->assertStringContainsString('Creating database and schema, clearing the cache', $tester->getDisplay());
}
public function testRunInstallCommandChooseResetSchema()
@ -200,12 +200,12 @@ class InstallCommandTest extends WallabagCoreTestCase
'command' => $command->getName(),
]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
$this->assertContains('Administration setup.', $tester->getDisplay());
$this->assertContains('Config setup.', $tester->getDisplay());
$this->assertStringContainsString('Checking system requirements.', $tester->getDisplay());
$this->assertStringContainsString('Setting up database.', $tester->getDisplay());
$this->assertStringContainsString('Administration setup.', $tester->getDisplay());
$this->assertStringContainsString('Config setup.', $tester->getDisplay());
$this->assertContains('Dropping schema and creating schema', $tester->getDisplay());
$this->assertStringContainsString('Dropping schema and creating schema', $tester->getDisplay());
}
public function testRunInstallCommandChooseNothing()
@ -244,12 +244,12 @@ class InstallCommandTest extends WallabagCoreTestCase
'command' => $command->getName(),
]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
$this->assertContains('Administration setup.', $tester->getDisplay());
$this->assertContains('Config setup.', $tester->getDisplay());
$this->assertStringContainsString('Checking system requirements.', $tester->getDisplay());
$this->assertStringContainsString('Setting up database.', $tester->getDisplay());
$this->assertStringContainsString('Administration setup.', $tester->getDisplay());
$this->assertStringContainsString('Config setup.', $tester->getDisplay());
$this->assertContains('Creating schema', $tester->getDisplay());
$this->assertStringContainsString('Creating schema', $tester->getDisplay());
}
public function testRunInstallCommandNoInteraction()
@ -266,9 +266,9 @@ class InstallCommandTest extends WallabagCoreTestCase
'interactive' => false,
]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
$this->assertContains('Administration setup.', $tester->getDisplay());
$this->assertContains('Config setup.', $tester->getDisplay());
$this->assertStringContainsString('Checking system requirements.', $tester->getDisplay());
$this->assertStringContainsString('Setting up database.', $tester->getDisplay());
$this->assertStringContainsString('Administration setup.', $tester->getDisplay());
$this->assertStringContainsString('Config setup.', $tester->getDisplay());
}
}

View File

@ -21,7 +21,7 @@ class ListUserCommandTest extends WallabagCoreTestCase
'command' => $command->getName(),
]);
$this->assertContains('3/3 user(s) displayed.', $tester->getDisplay());
$this->assertStringContainsString('3/3 user(s) displayed.', $tester->getDisplay());
}
public function testRunListUserCommandWithLimit()
@ -37,7 +37,7 @@ class ListUserCommandTest extends WallabagCoreTestCase
'--limit' => 2,
]);
$this->assertContains('2/3 user(s) displayed.', $tester->getDisplay());
$this->assertStringContainsString('2/3 user(s) displayed.', $tester->getDisplay());
}
public function testRunListUserCommandWithSearch()
@ -53,7 +53,7 @@ class ListUserCommandTest extends WallabagCoreTestCase
'search' => 'boss',
]);
$this->assertContains('1/3 (filtered) user(s) displayed.', $tester->getDisplay());
$this->assertStringContainsString('1/3 (filtered) user(s) displayed.', $tester->getDisplay());
}
public function testRunListUserCommandWithSearchAndLimit()
@ -70,6 +70,6 @@ class ListUserCommandTest extends WallabagCoreTestCase
'--limit' => 1,
]);
$this->assertContains('1/3 (filtered) user(s) displayed.', $tester->getDisplay());
$this->assertStringContainsString('1/3 (filtered) user(s) displayed.', $tester->getDisplay());
}
}

View File

@ -70,7 +70,7 @@ class ReloadEntryCommandTest extends WallabagCoreTestCase
$this->assertNotEmpty($reloadedEntry->getContent());
}
$this->assertContains('Done', $tester->getDisplay());
$this->assertStringContainsString('Done', $tester->getDisplay());
}
/**
@ -98,7 +98,7 @@ class ReloadEntryCommandTest extends WallabagCoreTestCase
$reloadedBobEntry = $entryRepository->find($this->bobEntry->getId());
$this->assertEmpty($reloadedBobEntry->getContent());
$this->assertContains('Done', $tester->getDisplay());
$this->assertStringContainsString('Done', $tester->getDisplay());
}
public function testRunReloadEntryWithoutEntryCommand()
@ -115,7 +115,7 @@ class ReloadEntryCommandTest extends WallabagCoreTestCase
'interactive' => false,
]);
$this->assertContains('No entry to reload', $tester->getDisplay());
$this->assertNotContains('Done', $tester->getDisplay());
$this->assertStringContainsString('No entry to reload', $tester->getDisplay());
$this->assertStringNotContainsString('Done', $tester->getDisplay());
}
}

View File

@ -10,12 +10,11 @@ use Wallabag\UserBundle\Entity\User;
class ShowUserCommandTest extends WallabagCoreTestCase
{
/**
* @expectedException \Symfony\Component\Console\Exception\RuntimeException
* @expectedExceptionMessage Not enough arguments
*/
public function testRunShowUserCommandWithoutUsername()
{
$this->expectException(\Symfony\Component\Console\Exception\RuntimeException::class);
$this->expectExceptionMessage('Not enough arguments');
$application = new Application($this->getClient()->getKernel());
$application->add(new ShowUserCommand());
@ -40,7 +39,7 @@ class ShowUserCommandTest extends WallabagCoreTestCase
'username' => 'unknown',
]);
$this->assertContains('User "unknown" not found', $tester->getDisplay());
$this->assertStringContainsString('User "unknown" not found', $tester->getDisplay());
}
public function testRunShowUserCommandForUser()
@ -56,11 +55,11 @@ class ShowUserCommandTest extends WallabagCoreTestCase
'username' => 'admin',
]);
$this->assertContains('Username: admin', $tester->getDisplay());
$this->assertContains('Email: bigboss@wallabag.org', $tester->getDisplay());
$this->assertContains('Display name: Big boss', $tester->getDisplay());
$this->assertContains('2FA (email) activated', $tester->getDisplay());
$this->assertContains('2FA (OTP) activated', $tester->getDisplay());
$this->assertStringContainsString('Username: admin', $tester->getDisplay());
$this->assertStringContainsString('Email: bigboss@wallabag.org', $tester->getDisplay());
$this->assertStringContainsString('Display name: Big boss', $tester->getDisplay());
$this->assertStringContainsString('2FA (email) activated', $tester->getDisplay());
$this->assertStringContainsString('2FA (OTP) activated', $tester->getDisplay());
}
public function testShowUser()
@ -89,6 +88,6 @@ class ShowUserCommandTest extends WallabagCoreTestCase
'username' => 'admin',
]);
$this->assertContains('Display name: Bug boss', $tester->getDisplay());
$this->assertStringContainsString('Display name: Bug boss', $tester->getDisplay());
}
}

View File

@ -9,12 +9,11 @@ use Wallabag\CoreBundle\Command\TagAllCommand;
class TagAllCommandTest extends WallabagCoreTestCase
{
/**
* @expectedException \Symfony\Component\Console\Exception\RuntimeException
* @expectedExceptionMessage Not enough arguments (missing: "username")
*/
public function testRunTagAllCommandWithoutUsername()
{
$this->expectException(\Symfony\Component\Console\Exception\RuntimeException::class);
$this->expectExceptionMessage('Not enough arguments (missing: "username")');
$application = new Application($this->getClient()->getKernel());
$application->add(new TagAllCommand());
@ -39,7 +38,7 @@ class TagAllCommandTest extends WallabagCoreTestCase
'username' => 'unknown',
]);
$this->assertContains('User "unknown" not found', $tester->getDisplay());
$this->assertStringContainsString('User "unknown" not found', $tester->getDisplay());
}
public function testRunTagAllCommand()
@ -55,7 +54,7 @@ class TagAllCommandTest extends WallabagCoreTestCase
'username' => 'admin',
]);
$this->assertContains('Tagging entries for user admin...', $tester->getDisplay());
$this->assertContains('Done', $tester->getDisplay());
$this->assertStringContainsString('Tagging entries for user admin...', $tester->getDisplay());
$this->assertStringContainsString('Done', $tester->getDisplay());
}
}