summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/tests
diff options
context:
space:
mode:
authorFaraz Samapoor <f.samapoor@gmail.com>2023-06-02 15:26:55 +0330
committerFaraz Samapoor <f.samapoor@gmail.com>2023-06-02 15:26:55 +0330
commitb0938b90839503fed01924d4a7874482caf2fc80 (patch)
tree6704ccb6066e29813fd164111e46b896036d65d5 /apps/user_ldap/tests
parent09c5f997c6d185d8b23b37a996e7a1130a426d75 (diff)
downloadnextcloud-server-b0938b90839503fed01924d4a7874482caf2fc80.tar.gz
nextcloud-server-b0938b90839503fed01924d4a7874482caf2fc80.zip
Refactors "strpos" calls in /apps/user_ldap to improve code readability.
Signed-off-by: Faraz Samapoor <f.samapoor@gmail.com>
Diffstat (limited to 'apps/user_ldap/tests')
-rw-r--r--apps/user_ldap/tests/Group_LDAPTest.php6
-rw-r--r--apps/user_ldap/tests/Integration/AbstractIntegrationTest.php2
-rw-r--r--apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php4
-rw-r--r--apps/user_ldap/tests/User_LDAPTest.php2
4 files changed, 7 insertions, 7 deletions
diff --git a/apps/user_ldap/tests/Group_LDAPTest.php b/apps/user_ldap/tests/Group_LDAPTest.php
index edcb4be8819..2f7c0b04cdc 100644
--- a/apps/user_ldap/tests/Group_LDAPTest.php
+++ b/apps/user_ldap/tests/Group_LDAPTest.php
@@ -157,8 +157,8 @@ class Group_LDAPTest extends TestCase {
//to analyze the "dn". All other times we just need to return
//something that is neither null or false, but once an array
//with the users in the group – so we do so all other times for
- //simplicicity.
- if (strpos($name, 'u') === 0) {
+ //simplicity.
+ if (str_starts_with($name, 'u')) {
return strpos($name, '3');
}
return ['u11', 'u22', 'u33', 'u34'];
@@ -1009,7 +1009,7 @@ class Group_LDAPTest extends TestCase {
if (!$nestedGroups) {
// When nested groups are enabled, groups cannot be filtered early as it would
// exclude intermediate groups. But we can, and should, when working with flat groups.
- $this->assertTrue(strpos($filter, $groupFilter) !== false);
+ $this->assertTrue(str_contains($filter, $groupFilter));
}
[$memberFilter] = explode('&', $filter);
if ($memberFilter === 'member='.$dn) {
diff --git a/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php b/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
index e22678620c1..58475a2bea9 100644
--- a/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
+++ b/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
@@ -155,7 +155,7 @@ abstract class AbstractIntegrationTest {
$methods = get_class_methods($this);
$atLeastOneCaseRan = false;
foreach ($methods as $method) {
- if (strpos($method, 'case') === 0) {
+ if (str_starts_with($method, 'case')) {
print("running $method " . PHP_EOL);
try {
if (!$this->$method()) {
diff --git a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php
index 7353c5bef30..993ceec5abb 100644
--- a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php
+++ b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php
@@ -71,7 +71,7 @@ class IntegrationTestUserDisplayName extends AbstractIntegrationTest {
$this->prepareUser($dn, $username);
$displayName = \OC::$server->getUserManager()->get($username)->getDisplayName();
- return strpos($displayName, '(Alice@example.com)') !== false;
+ return str_contains($displayName, '(Alice@example.com)');
}
/**
@@ -88,7 +88,7 @@ class IntegrationTestUserDisplayName extends AbstractIntegrationTest {
$this->prepareUser($dn, $username);
$displayName = \OC::$server->getUserManager()->get($username)->getDisplayName();
- return strpos($displayName, '(Boris@example.com)') === false;
+ return !str_contains($displayName, '(Boris@example.com)');
}
/**
diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php
index b00c93e79f0..e837471bab0 100644
--- a/apps/user_ldap/tests/User_LDAPTest.php
+++ b/apps/user_ldap/tests/User_LDAPTest.php
@@ -1312,7 +1312,7 @@ class User_LDAPTest extends TestCase {
/** @dataProvider avatarDataProvider */
public function testCanChangeAvatar($imageData, $expected) {
- $isValidImage = strpos((string)$imageData, 'valid') === 0;
+ $isValidImage = str_starts_with((string)$imageData, 'valid');
$user = $this->createMock(User::class);
$user->expects($this->once())