aboutsummaryrefslogtreecommitdiffstats
path: root/build/integration/features/bootstrap/Avatar.php
diff options
context:
space:
mode:
Diffstat (limited to 'build/integration/features/bootstrap/Avatar.php')
-rw-r--r--build/integration/features/bootstrap/Avatar.php53
1 files changed, 22 insertions, 31 deletions
diff --git a/build/integration/features/bootstrap/Avatar.php b/build/integration/features/bootstrap/Avatar.php
index 388715340c6..beebf1c024a 100644
--- a/build/integration/features/bootstrap/Avatar.php
+++ b/build/integration/features/bootstrap/Avatar.php
@@ -1,34 +1,16 @@
<?php
+
/**
- * @copyright Copyright (c) 2020, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @author Daniel Calviño Sánchez <danxuliu@gmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-
use Behat\Gherkin\Node\TableNode;
use PHPUnit\Framework\Assert;
require __DIR__ . '/../../vendor/autoload.php';
trait Avatar {
-
- /** @var string **/
+ /** @var string * */
private $lastAvatar;
/** @AfterScenario **/
@@ -110,7 +92,7 @@ trait Avatar {
* @param string $source
*/
public function loggedInUserPostsTemporaryAvatarFromFile(string $source) {
- $file = \GuzzleHttp\Psr7\stream_for(fopen($source, 'r'));
+ $file = \GuzzleHttp\Psr7\Utils::streamFor(fopen($source, 'r'));
$this->sendingAToWithRequesttoken('POST', '/index.php/avatar',
[
@@ -173,13 +155,22 @@ trait Avatar {
* @param string size
*/
public function lastAvatarIsASquareOfSize(string $size) {
- list($width, $height) = getimagesizefromstring($this->lastAvatar);
+ [$width, $height] = getimagesizefromstring($this->lastAvatar);
- Assert::assertEquals($width, $height, 'Avatar is not a square');
+ Assert::assertEquals($width, $height, 'Expected avatar to be a square');
Assert::assertEquals($size, $width);
}
/**
+ * @Then last avatar is not a square
+ */
+ public function lastAvatarIsNotASquare() {
+ [$width, $height] = getimagesizefromstring($this->lastAvatar);
+
+ Assert::assertNotEquals($width, $height, 'Expected avatar to not be a square');
+ }
+
+ /**
* @Then last avatar is not a single color
*/
public function lastAvatarIsNotASingleColor() {
@@ -250,10 +241,10 @@ trait Avatar {
}
private function isSameColor(array $firstColor, array $secondColor, int $allowedDelta = 1) {
- if ($this->isSameColorComponent($firstColor['red'], $secondColor['red'], $allowedDelta) &&
- $this->isSameColorComponent($firstColor['green'], $secondColor['green'], $allowedDelta) &&
- $this->isSameColorComponent($firstColor['blue'], $secondColor['blue'], $allowedDelta) &&
- $this->isSameColorComponent($firstColor['alpha'], $secondColor['alpha'], $allowedDelta)) {
+ if ($this->isSameColorComponent($firstColor['red'], $secondColor['red'], $allowedDelta)
+ && $this->isSameColorComponent($firstColor['green'], $secondColor['green'], $allowedDelta)
+ && $this->isSameColorComponent($firstColor['blue'], $secondColor['blue'], $allowedDelta)
+ && $this->isSameColorComponent($firstColor['alpha'], $secondColor['alpha'], $allowedDelta)) {
return true;
}
@@ -261,8 +252,8 @@ trait Avatar {
}
private function isSameColorComponent(int $firstColorComponent, int $secondColorComponent, int $allowedDelta) {
- if ($firstColorComponent >= ($secondColorComponent - $allowedDelta) &&
- $firstColorComponent <= ($secondColorComponent + $allowedDelta)) {
+ if ($firstColorComponent >= ($secondColorComponent - $allowedDelta)
+ && $firstColorComponent <= ($secondColorComponent + $allowedDelta)) {
return true;
}