Skip to content

Conversation

@bromiesTM
Copy link

  • Resolves: #

Summary

  • Added tests for files user config service
  • Bugfix to prevent unexpected behaviour due to loose type comparisons when validating configuration values + Tests

TODO

  • ...

Checklist

Not ok: in_array("foo", [true, false]); // returns true
ok: in_array("foo", [true, false], true); // returns false

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
@bromiesTM bromiesTM force-pushed the kh/dev/files-userconfig-tests branch from cf27019 to 49d10ed Compare January 6, 2025 10:47
@artonge artonge requested a review from ArtificialOwl January 6, 2025 12:27
Comment on lines +24 to +40
/**
* @var string
*/
private $userUID;

private $userMock;

/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
private $configMock;

/** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
private $userSessionMock;

/**
* @var UserConfig|\PHPUnit\Framework\MockObject\MockObject
*/
private $userConfigService;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* @var string
*/
private $userUID;
private $userMock;
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
private $configMock;
/** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
private $userSessionMock;
/**
* @var UserConfig|\PHPUnit\Framework\MockObject\MockObject
*/
private $userConfigService;
private string $userUID;
private IUser&MockObject $userMock;
private IConfig&MockObject $configMock;
private IUserSession&MockObject $userSessionMock;
private UserConfig $userConfig;

->withAnyParameters()
->willReturn($this->userMock);

$this->userConfigService = $this->getUserConfigService(['addActivity']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->userConfigService = $this->getUserConfigService(['addActivity']);
$this->userConfig = new UserConfig($this->configMock, $this->userSessionMock);

Comment on lines +46 to +50
$this->userUID = static::getUniqueID('user_id-');
\OC::$server->getUserManager()->createUser($this->userUID, 'test');
\OC_User::setUserId($this->userUID);
\OC_Util::setupFS($this->userUID);
$this->userMock = $this->getUserMock($this->userUID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is all this needed? 🤔

Looks ugly and calls obsolete methods.

Comment on lines +103 to +104
$userConfig = new UserConfig($this->configMock, $this->userSessionMock);
$userConfig->setConfig('crop_image_previews', true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$userConfig = new UserConfig($this->configMock, $this->userSessionMock);
$userConfig->setConfig('crop_image_previews', true);
$this->userConfig->setConfig('crop_image_previews', true);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And same for the other ones

@github-actions
Copy link
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@susnux susnux added this to the Nextcloud 32 milestone Mar 2, 2025
This was referenced Aug 22, 2025
This was referenced Sep 2, 2025
This was referenced Sep 25, 2025
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants