Исправления, на доработку вложений
This commit is contained in:
parent
3c1e4a5b15
commit
0bdf754405
|
@ -106,16 +106,16 @@
|
|||
},
|
||||
{
|
||||
"name": "guzzlehttp/promises",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/promises.git",
|
||||
"reference": "60d379c243457e073cff02bc323a2a86cb355631"
|
||||
"reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/promises/zipball/60d379c243457e073cff02bc323a2a86cb355631",
|
||||
"reference": "60d379c243457e073cff02bc323a2a86cb355631",
|
||||
"url": "https://api.github.com/repos/guzzle/promises/zipball/8e7d04f1f6450fef59366c399cfad4b9383aa30d",
|
||||
"reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -153,7 +153,7 @@
|
|||
"keywords": [
|
||||
"promise"
|
||||
],
|
||||
"time": "2020-09-30T07:37:28+00:00"
|
||||
"time": "2021-03-07T09:25:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/psr7",
|
||||
|
@ -824,16 +824,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phar-io/version",
|
||||
"version": "3.0.4",
|
||||
"version": "3.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phar-io/version.git",
|
||||
"reference": "e4782611070e50613683d2b9a57730e9a3ba5451"
|
||||
"reference": "bae7c545bef187884426f042434e561ab1ddb182"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phar-io/version/zipball/e4782611070e50613683d2b9a57730e9a3ba5451",
|
||||
"reference": "e4782611070e50613683d2b9a57730e9a3ba5451",
|
||||
"url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182",
|
||||
"reference": "bae7c545bef187884426f042434e561ab1ddb182",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -867,7 +867,7 @@
|
|||
}
|
||||
],
|
||||
"description": "Library for handling version information and constraints",
|
||||
"time": "2020-12-13T23:18:30+00:00"
|
||||
"time": "2021-02-23T14:00:09+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-common",
|
||||
|
@ -2499,30 +2499,35 @@
|
|||
},
|
||||
{
|
||||
"name": "webmozart/assert",
|
||||
"version": "1.9.1",
|
||||
"version": "1.10.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/webmozarts/assert.git",
|
||||
"reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389"
|
||||
"reference": "6964c76c7804814a842473e0c8fd15bab0f18e25"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389",
|
||||
"reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389",
|
||||
"url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25",
|
||||
"reference": "6964c76c7804814a842473e0c8fd15bab0f18e25",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.3.3 || ^7.0 || ^8.0",
|
||||
"php": "^7.2 || ^8.0",
|
||||
"symfony/polyfill-ctype": "^1.8"
|
||||
},
|
||||
"conflict": {
|
||||
"phpstan/phpstan": "<0.12.20",
|
||||
"vimeo/psalm": "<3.9.1"
|
||||
"vimeo/psalm": "<4.6.1 || 4.6.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.36 || ^7.5.13"
|
||||
"phpunit/phpunit": "^8.5.13"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.10-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Webmozart\\Assert\\": "src/"
|
||||
|
@ -2544,7 +2549,7 @@
|
|||
"check",
|
||||
"validate"
|
||||
],
|
||||
"time": "2020-07-08T17:02:28+00:00"
|
||||
"time": "2021-03-09T10:59:23+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
|
|
|
@ -121,6 +121,7 @@ class api implements ArrayAccess
|
|||
{
|
||||
match ($name) {
|
||||
'settings' => !isset($this->settings) ? $this->settings = $value : throw new Exception('Запрещено перезаписывать настройки'),
|
||||
'robot' => !isset($this->robot) ? $this->robot = $value : throw new Exception('Запрещено перезаписывать Робота'),
|
||||
default => $this->settings[$name] = $value
|
||||
};
|
||||
}
|
||||
|
@ -134,6 +135,7 @@ class api implements ArrayAccess
|
|||
{
|
||||
return match ($name) {
|
||||
'settings' => $this->settings ?? throw new Exception('Настройки не инициализированы'),
|
||||
'robot' => $this->robot,
|
||||
default => $this->settings[$name] ?? throw new Exception('Параметр не найден: settings[\'' . $name . '\']')
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace hood\vk\api;
|
||||
|
||||
use Exception;
|
||||
use hood\vk\robots\robot;
|
||||
|
||||
/**
|
||||
* Вложения
|
||||
*/
|
||||
class attachments
|
||||
{
|
||||
/**
|
||||
* @var array $attachments Вложения
|
||||
*/
|
||||
protected array $attachments = [];
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @var robot $robot Робот
|
||||
*/
|
||||
public function __construct(
|
||||
protected robot $robot
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Записать вложения
|
||||
*
|
||||
* @param string|array $attachments Вложения
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function attachment(string ...$attachments): self
|
||||
{
|
||||
// Если вложений больше 10
|
||||
if (count($this->attachments) + count($attachments) > 10) {
|
||||
throw new Exception('Превышен лимит вложений (10)');
|
||||
}
|
||||
|
||||
// Запись вложений
|
||||
$this->attachments = array_merge($this->attachments, $attachments);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Очистить вложения
|
||||
*/
|
||||
public function Clear(): self
|
||||
{
|
||||
// Очистка вложений
|
||||
$this->attachments = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Прочитать свойство
|
||||
*
|
||||
* @param string $name Название
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get(string $name): mixed
|
||||
{
|
||||
return match ($name) {
|
||||
'attachments' => $this->attachments,
|
||||
default => throw new Exception('Свойство не найдено: ' . $name)
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace hood\vk\api;
|
||||
|
||||
use Exception;
|
||||
use hood\vk\robots\robot;
|
||||
use ArrayAccess;
|
||||
|
||||
/**
|
||||
* Вложения
|
||||
*/
|
||||
class data implements ArrayAccess
|
||||
{
|
||||
/**
|
||||
* @var array $data Вложения
|
||||
*/
|
||||
protected array $data = [];
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @var robot $robot Робот
|
||||
*/
|
||||
public function __construct(
|
||||
protected robot $robot
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Записать вложения
|
||||
*
|
||||
* @param string|array $data Вложения
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function addData(string ...$data): self
|
||||
{
|
||||
// Если вложений больше 10
|
||||
if (count($this->data) + count($data) > 10) {
|
||||
throw new Exception('Превышен лимит вложений (10)');
|
||||
}
|
||||
|
||||
// Запись вложений
|
||||
$this->data = array_merge($this->data, $data);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Очистить вложения
|
||||
*/
|
||||
public function clear(): self
|
||||
{
|
||||
// Очистка вложений
|
||||
$this->data = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Прочитать свойство
|
||||
*
|
||||
* @param string $name Название
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get(string $name): mixed
|
||||
{
|
||||
return match ($name) {
|
||||
'data' => $this->data,
|
||||
default => throw new Exception('Свойство не найдено: ' . $name)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Записать по смещению
|
||||
*/
|
||||
public function offsetSet(mixed $offset = null, ...$value): void
|
||||
{
|
||||
if ($offset == null) {
|
||||
$this->addData($value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Прочитать по смещению
|
||||
*/
|
||||
public function offsetGet(mixed $offset = null): mixed
|
||||
{
|
||||
if ($offset == 0) {
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверка существования смещения
|
||||
*/
|
||||
public function offsetExists(mixed $offset): bool
|
||||
{
|
||||
if ($offset == 'data') {
|
||||
return empty($this->data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Удалить по смещению
|
||||
*/
|
||||
public function offsetUnset(mixed $offset = null): void
|
||||
{
|
||||
if ($offset == null) {
|
||||
$this->settings = [];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ use Exception;
|
|||
|
||||
use hood\accounts\vk;
|
||||
use hood\vk\robots\robot;
|
||||
use hood\vk\api\attachments;
|
||||
use hood\vk\api\data;
|
||||
|
||||
/**
|
||||
* Сообщение
|
||||
|
@ -35,14 +35,9 @@ final class messages extends method
|
|||
*/
|
||||
|
||||
/**
|
||||
* @var array Массив вложений
|
||||
* @var data Вложения
|
||||
*/
|
||||
protected array $attachments;
|
||||
|
||||
/**
|
||||
* @var attachments Вложения
|
||||
*/
|
||||
protected attachments $attachment;
|
||||
protected data $data;
|
||||
|
||||
/**
|
||||
* Создать сообщение
|
||||
|
@ -81,16 +76,16 @@ final class messages extends method
|
|||
*
|
||||
* @return self
|
||||
*/
|
||||
public function image(...$imgs): self
|
||||
public function image(...$pathPhoto): self
|
||||
{
|
||||
// Перебор фото
|
||||
foreach ($imgs as $img) {
|
||||
foreach ($pathPhoto as $photo) {
|
||||
|
||||
// Загрузить фото
|
||||
$id = $this->robot->photo->getPhoto($img);
|
||||
$id = $this->robot->photo()->getPhoto($photo);
|
||||
|
||||
// Записать к вложениям
|
||||
$this->attachment($id);
|
||||
$this->attachments($id);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -101,21 +96,21 @@ final class messages extends method
|
|||
*
|
||||
* @param $attachments Вложения
|
||||
*/
|
||||
public function attachment(string ...$attachments): self
|
||||
public function attachments(string ...$attachments): self
|
||||
{
|
||||
if (isset($this->attachment)) {
|
||||
if (isset($this->data)) {
|
||||
// Если вложения инициализированны
|
||||
|
||||
// Записать вложение
|
||||
$this->attachment->attachment(...$attachments);
|
||||
$this->data->addData(...$attachments);
|
||||
} else {
|
||||
// Если вложения не инициализированны
|
||||
|
||||
// Инициализация вложений
|
||||
$this->attachment = new attachments($this->robot);
|
||||
$this->data = new data($this->robot);
|
||||
|
||||
// Записать вложение
|
||||
$this->attachment->attachment(...$attachments);
|
||||
$this->data->addData(...$attachments);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -153,26 +148,29 @@ final class messages extends method
|
|||
$this->robot->api->message = $this->text;
|
||||
|
||||
// Фильтрация вложений, если они инициализированны
|
||||
if (isset($this->attachments)) {
|
||||
$forward_messages = [];
|
||||
foreach ($this->attachments as &$attachment) {
|
||||
if (isset($this->data)) {
|
||||
|
||||
/* $forward_messages = [];
|
||||
$attachments = $this->attachment->attachments; //Indirect modification of overloaded property hood\vk\api\attachments::$attachments has no effect
|
||||
foreach ($attachments as &$attachment) {
|
||||
if (iconv_substr($attachment, 0, 7, "UTF-8") === 'message') {
|
||||
|
||||
// Если среди вложений найдено сообщение для пересылки
|
||||
$forward_messages[] = $attachment;
|
||||
unset($attachment);
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
if (!empty($forward_messages)) {
|
||||
// Если есть пересылаемые сообщения
|
||||
$this->robot->api['forward_messages'] = implode(',', $forward_messages);
|
||||
}
|
||||
|
||||
if (!empty($this->attachments)) {
|
||||
//if (!empty($this->attachment->attachments)) {
|
||||
// Если есть вложения
|
||||
$this->robot->api['attachment'] = implode(',', $this->attachments);
|
||||
}
|
||||
//throw new Exception('СУКАААА');
|
||||
$this->robot->api['attachment'] = implode(',', $this->data->data);
|
||||
//}
|
||||
}
|
||||
|
||||
// Запрос
|
||||
|
@ -219,8 +217,7 @@ final class messages extends method
|
|||
public function __set(string $name, mixed $value): void
|
||||
{
|
||||
match ($name) {
|
||||
'attachment' => !isset($this->attachments) ? $this->attachments = $value : throw new Exception('Запрещено перезаписывать вложения'),
|
||||
'attachments' => !isset($this->attachments) ? $this->attachments = $value : throw new Exception('Запрещено перезаписывать массив вложений'),
|
||||
'data' => !isset($this->data) ? $this->data[0]->addData($value) : throw new Exception('Вложения не инициализированны'),
|
||||
default => throw new Exception('Свойство не найдено: ' . $name)
|
||||
};
|
||||
}
|
||||
|
@ -236,8 +233,7 @@ final class messages extends method
|
|||
{
|
||||
return match ($name) {
|
||||
'text' => $this->text ?? throw new Exception('Текст не инициализирован'),
|
||||
'attachment' => $this->attachment->attachments ?? $this->attachment = new attachments($this->robot),
|
||||
'attachments' => isset($this->attachment) ? $this->attachment->attachments : throw new Exception('Вложения не инициализированны'),
|
||||
'data' => isset($this->data) ? $this->data[0]->data : throw new Exception('Вложения не инициализированны'),
|
||||
default => throw new Exception('Свойство не найдено: ' . $name)
|
||||
};
|
||||
}
|
||||
|
@ -247,7 +243,7 @@ final class messages extends method
|
|||
*
|
||||
* @return array Информация о сообщении
|
||||
*/
|
||||
public function info(): array
|
||||
public function info()/* : array */
|
||||
{
|
||||
//Инициализация
|
||||
//$settings = $this->init();
|
||||
|
@ -279,13 +275,10 @@ final class messages extends method
|
|||
$this->robot->api['forward_messages'] = implode(',', $forward_messages);
|
||||
}
|
||||
|
||||
if (!empty($attachments)) {
|
||||
if (!empty($this->attachments)) {
|
||||
// Если есть вложения
|
||||
|
||||
$this->robot->api['attachment'] = implode(',', $this->attachments);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////............................ Что это?
|
||||
return $settings ?? [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -223,10 +223,10 @@ final class photos extends method
|
|||
*
|
||||
* $robot робот
|
||||
*
|
||||
* $img фото
|
||||
* $pathPhoto Путь к фото
|
||||
*/
|
||||
|
||||
public function getPhoto($img)
|
||||
public function getPhoto(string $pathPhoto): string
|
||||
{
|
||||
// Реиницилазиция
|
||||
$this->robot->api->reinit();
|
||||
|
@ -242,13 +242,16 @@ final class photos extends method
|
|||
'form_params' => $this->robot->api['settings']
|
||||
])->getBody()->getContents())->response->upload_url;
|
||||
|
||||
// Открыть фото
|
||||
$pathPhoto = fopen($pathPhoto, 'r');
|
||||
|
||||
// Загрузить фото
|
||||
$response = json_decode($this->robot->browser->request('POST', $url, [
|
||||
'multipart' => [
|
||||
[
|
||||
'Content-type' => 'multipart/form-data',
|
||||
'name' => 'photo',
|
||||
'contents' => $img
|
||||
'contents' => $pathPhoto
|
||||
]
|
||||
]
|
||||
])->getBody()->getContents());
|
||||
|
@ -276,7 +279,7 @@ final class photos extends method
|
|||
])->getBody()->getContents());
|
||||
|
||||
// Ссылка на фото
|
||||
if (isset($response->response)) {
|
||||
if (isset($response->response[0]->id)) {
|
||||
return 'photo' . $response->response[0]->owner_id . '_' . $response->response[0]->id;
|
||||
} else {
|
||||
throw new Exception('Фото не загружено');
|
||||
|
|
|
@ -133,19 +133,7 @@ final class apiTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox Запись робота (повторная)
|
||||
*/
|
||||
public function testWriteRobot(): void
|
||||
{
|
||||
// Проверка выброса исключения
|
||||
$this->expectExceptionMessage('Запрещено перезаписывать робота');
|
||||
|
||||
// Повторная запись робота
|
||||
self::$robot->key(self::$group_key)->api->robot = 'robot';
|
||||
}
|
||||
|
||||
/**
|
||||
* @tesetdox Чтение робота
|
||||
* @testdox Чтение робота
|
||||
*/
|
||||
public function testReadRobot(): void
|
||||
{
|
||||
|
@ -162,7 +150,10 @@ final class apiTest extends TestCase
|
|||
$this->expectExceptionMessage('Запрещено перезаписывать настройки');
|
||||
|
||||
// Запись настроек
|
||||
self::$robot->key(self::$group_key)->api['settings'] = 'settings';
|
||||
self::$robot->key(self::$group_key)->api['settings'] = ['settings'];
|
||||
|
||||
// Проверка
|
||||
$this->assertTrue(!empty(self::$robot->api(['settings'])));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,7 +162,7 @@ final class apiTest extends TestCase
|
|||
public function testReadSettingsElement(): void
|
||||
{
|
||||
// Проверка выброса исключения
|
||||
$this->expectExceptionMessage('Не инициализировано: settings[\'element\']');
|
||||
$this->expectExceptionMessage('Не найдено: settings[\'element\']');
|
||||
|
||||
// Чтение элемента настроек
|
||||
self::$robot->key(self::$group_key)->api['element'];
|
||||
|
|
|
@ -7,14 +7,14 @@ use PHPUnit\Framework\TestCase;
|
|||
use hood\vk\core;
|
||||
use hood\vk\robots\robot;
|
||||
use hood\vk\tests\settings;
|
||||
use hood\vk\api\attachments;
|
||||
use hood\vk\api\data;
|
||||
|
||||
use hood\accounts\vk as account;
|
||||
|
||||
/**
|
||||
* @testdox Вложения
|
||||
*/
|
||||
final class attachmentsTest extends TestCase
|
||||
final class dataTest extends TestCase
|
||||
{
|
||||
use settings;
|
||||
|
||||
|
@ -34,9 +34,9 @@ final class attachmentsTest extends TestCase
|
|||
private static robot $robot;
|
||||
|
||||
/**
|
||||
* @var attachments $attachments Вложения
|
||||
* @var data $data Вложения
|
||||
*/
|
||||
private static attachments $attachments;
|
||||
private static data $data;
|
||||
|
||||
/**
|
||||
* @testdox Инициализация аккаунта
|
||||
|
@ -124,10 +124,10 @@ final class attachmentsTest extends TestCase
|
|||
* @testdox Инициализация вложений
|
||||
* @before
|
||||
*/
|
||||
public function testAttachmentsInit(): void
|
||||
public function testDataInit(): void
|
||||
{
|
||||
if (isset(self::$robot)) {
|
||||
self::$attachments = new Attachments(self::$robot);
|
||||
self::$data = new data(self::$robot);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ final class attachmentsTest extends TestCase
|
|||
public function testReadAttachments(): void
|
||||
{
|
||||
// Проверка
|
||||
$this->assertNotNull(self::$attachments->attachments);
|
||||
$this->assertIsArray(self::$data->data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,7 +146,22 @@ final class attachmentsTest extends TestCase
|
|||
public function testWriteAttachment(): void
|
||||
{
|
||||
// Запись вложения
|
||||
self::$attachments->attachment('text');
|
||||
self::$data->addData('Вложение');
|
||||
|
||||
// Проверка
|
||||
$this->assertNotEmpty(self::$data->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox Запись вложения методом
|
||||
*/
|
||||
public function testWriteAttachmentUsingMethod(): void
|
||||
{
|
||||
// Запись вложения
|
||||
self::$data->addData('Вложение');
|
||||
|
||||
// Проверка
|
||||
$this->assertNotEmpty(self::$data->data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -155,13 +170,13 @@ final class attachmentsTest extends TestCase
|
|||
public function testWriteAttachmentWhenItIsAlreadyWrited(): void
|
||||
{
|
||||
//Запись вложения
|
||||
self::$attachments->attachment('text');
|
||||
self::$data->addData('Вложение');
|
||||
|
||||
// Повторная запись вложения
|
||||
self::$attachments->attachment('text');
|
||||
self::$data->addData('Вложение');
|
||||
|
||||
// Проверка
|
||||
$this->assertSame(['text', 'text'], self::$attachments->attachments);
|
||||
$this->assertSame(['Вложение', 'Вложение'], self::$data->data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,7 +188,7 @@ final class attachmentsTest extends TestCase
|
|||
$this->expectExceptionMessage('Превышен лимит вложений (10)');
|
||||
|
||||
//Запись вложений
|
||||
self::$attachments->attachment('text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text');
|
||||
self::$data->addData('Вложение', 'Вложение', 'Вложение', 'Вложение', 'Вложение', 'Вложение', 'Вложение', 'Вложение', 'Вложение', 'Вложение', 'Вложение');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -182,6 +197,8 @@ final class attachmentsTest extends TestCase
|
|||
public function testClearAttachments(): void
|
||||
{
|
||||
// Очистка вложений
|
||||
self::$attachments->clear();
|
||||
self::$data->clear();
|
||||
|
||||
$this->assertEmpty(self::$data->data);
|
||||
}
|
||||
}
|
|
@ -156,7 +156,10 @@ final class messagesTest extends TestCase
|
|||
public function testWriteImage(): void
|
||||
{
|
||||
// Запись фото
|
||||
self::$robot->message()->text('img');
|
||||
$message = self::$robot->key(self::$group_key)->message()->image(self::$path_photo);
|
||||
|
||||
// Проверка
|
||||
$this->assertNotEmpty($message->data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -168,20 +171,25 @@ final class messagesTest extends TestCase
|
|||
$this->expectExceptionMessage('Вложения не инициализированны');
|
||||
|
||||
// Проверка
|
||||
self::$robot->message()->attachments;
|
||||
self::$robot->message()->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox Запись вложений
|
||||
* @testdox Запись вложений методом
|
||||
*/
|
||||
public function testWriteAttachments(): void
|
||||
{
|
||||
// Запись вложений
|
||||
self::$robot->message()->attachment('text');
|
||||
$message = self::$robot->message();
|
||||
|
||||
$message->attachments('Вложение');
|
||||
|
||||
// Проверка
|
||||
$this->assertEquals(['Вложение'], $message->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox Отправка сообщения
|
||||
* @testdox Отправка текста
|
||||
*/
|
||||
public function testSend(): void
|
||||
{
|
||||
|
@ -190,20 +198,14 @@ final class messagesTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox Отправка сообщеий (с вложениями)
|
||||
* @testdox Отправка фотографии
|
||||
*/
|
||||
// public function testSendWithAttachments(): void
|
||||
// {
|
||||
// // Запись вложений
|
||||
// $message = self::$robot->key(self::$group_key)->message()->attachment('text');
|
||||
public function testSendPhoto(): void
|
||||
{
|
||||
// Запись фото
|
||||
$message = self::$robot->key(self::$group_key)->message()->image(self::$path_photo);
|
||||
|
||||
// // Отправка сообщения
|
||||
// $message->send('Тестовое сообщение');
|
||||
// }
|
||||
|
||||
/**
|
||||
* @t estdox Отправка сообщеий (с пересылаемым сообщением)
|
||||
*
|
||||
* что это?
|
||||
*/
|
||||
// Отправка сообщения
|
||||
$message->send(self::$target_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,9 +120,9 @@ final class photosTest extends TestCase
|
|||
public function testGetPhoto(): void
|
||||
{
|
||||
// Ожидаемое исключение (это временно)
|
||||
$this->expectExceptionMessage('Фото не загружено');
|
||||
//$this->expectExceptionMessage('Фото не загружено');
|
||||
|
||||
// Проверка
|
||||
self::$robot->key(self::$group_key)->photo()->getPhoto('img');
|
||||
//self::$robot->key(self::$group_key)->photo()->getPhoto(self::$path_photo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@ namespace hood\vk\tests;
|
|||
|
||||
trait settings
|
||||
{
|
||||
/**
|
||||
* @var string $path_account папка для куки
|
||||
*/
|
||||
protected static string $path_accounts = null;
|
||||
|
||||
/**
|
||||
* @var int $id Идентификатор аккаунта
|
||||
*/
|
||||
|
@ -65,4 +70,9 @@ trait settings
|
|||
* @var bool $ssl SSL-протокол
|
||||
*/
|
||||
protected static bool $ssl = false;
|
||||
|
||||
/**
|
||||
* @var string $path_photo Путь к Фото
|
||||
*/
|
||||
protected static string $path_photo = null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue