Skip to content

Commit

Permalink
check for the UndefinedInterfaceMethod psalm
Browse files Browse the repository at this point in the history
Signed-off-by: nabim777 <[email protected]>
  • Loading branch information
nabim777 committed Sep 23, 2024
1 parent 034a2c4 commit b2dad67
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ignoreFiles>
<directory name="vendor" />
<directory name="../../**" />
<directory name="../**" />
<!-- <directory name="../**" />-->
</ignoreFiles>
</projectFiles>
<stubs>
Expand Down
18 changes: 8 additions & 10 deletions tests/acceptance/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,9 @@ public function theDataOfTheOCSResponseShouldMatch(
PyStringNode $schemaString
): void {
$responseAsJson = json_decode($this->response->getBody()->getContents());
$_responseAsJson = $responseAsJson->ocs->data;
$responseAsJson = $responseAsJson->ocs->data;
JsonAssertions::assertJsonDocumentMatchesSchema(
$_responseAsJson,
$responseAsJson,
$this->getJSONSchema($schemaString)
);
}
Expand All @@ -569,9 +569,9 @@ public function theDataOfTheOCSResponseShouldMatch(
public function theDataOfTheResponseShouldMatch(
PyStringNode $schemaString
): void {
$_responseAsJson = json_decode($this->response->getBody()->getContents());
$responseAsJson = json_decode($this->response->getBody()->getContents());
JsonAssertions::assertJsonDocumentMatchesSchema(
$_responseAsJson,
$responseAsJson,
$this->getJSONSchema($schemaString)
);
}
Expand Down Expand Up @@ -719,7 +719,10 @@ public function getIdOfFileOrFolder(string $user, string $path): int {
'oc',
'http://owncloud.org/ns'
);
return (int)(string)$responseXmlObject->xpath('//oc:fileid')[0];
$fileId = $responseXmlObject->xpath('//oc:fileid')[0] ?? null;
Assert::assertNotNull($fileId, __METHOD__ . " file $path user $user not found (the file may not exist)");

return (int)(string) $fileId;
}

public function fileOrFolderExists(string $user, string $path): bool {
Expand Down Expand Up @@ -1089,11 +1092,6 @@ public function sendRequestsToAppEndpoint(
$fullUrl = $this->getBaseUrl();
$fullUrl .= "index.php/apps/integration_openproject/" . $endpoint;

// Handle PyStringNode
if ($data instanceof PyStringNode) {
$data = (string)$data;
}

// don't set content-type for multipart requests
if (is_array($data) && $headers === null) {
$options['multipart'] = $data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function theVersionFolderOfFileShouldContainElements(
int $count
):void {
$fileId = $this->featureContext->getIdOfFileOrFolder($user, $path);
Assert::assertNotNull($fileId, __METHOD__ . " file $path user $user not found (the file may not exist)");
$this->theVersionFolderOfFileIdShouldContainElements($user, $fileId, $count);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Controller/ConfigControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ public function checkForUsersCountBeforeTest($expectedCount = 1): IUserManager {
$actualCount = 1;
$userManager = \OC::$server->getUserManager();
$count = 0;
$function = function () use (&$count) {
$function = function (IUser $user) use (&$count) {
$count++;
return null;
};
Expand Down
9 changes: 5 additions & 4 deletions tests/lib/Controller/OpenProjectAPIControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
use Psr\Log\LoggerInterface;

class OpenProjectAPIControllerTest extends TestCase {
/** @var IConfig $configMock */
/** @var IConfig */
private $configMock;

/** @var IRequest $requestMock */
/** @var IRequest */
private $requestMock;

/**
Expand Down Expand Up @@ -79,9 +79,10 @@ public function setUpMocks(): void {

/**
* @param string $token
* @psalm-suppress UndefinedInterfaceMethod
* @return void
*/
public function getUserValueMock($token = '123') {
public function getUserValueMock(string $token = '123'): void {
$this->configMock
->method('getUserValue')
->withConsecutive(
Expand All @@ -93,7 +94,7 @@ public function getUserValueMock($token = '123') {
/**
* @return void
*/
public function testGetNotifications() {
public function testGetNotifications(): void {
$this->getUserValueMock();
$service = $this->getMockBuilder(OpenProjectAPIService::class)
->disableOriginalConstructor()
Expand Down
1 change: 0 additions & 1 deletion tests/lib/Service/OpenProjectAPIServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,6 @@ private function getOpenProjectAPIService(
) {
$certificateManager = $this->getMockBuilder('\OCP\ICertificateManager')->getMock();
$certificateManager->method('getAbsoluteBundlePath')->willReturn('/');
$ocClient = null;
$client = new GuzzleClient();
$clientConfigMock = $this->getMockBuilder(IConfig::class)->getMock();
$clientConfigMock
Expand Down

0 comments on commit b2dad67

Please sign in to comment.