Skip to content

Commit

Permalink
Revert "make changes backward compatible"
Browse files Browse the repository at this point in the history
This reverts commit 1b31f07.
  • Loading branch information
fabio-ivona committed Aug 28, 2022
1 parent dd35037 commit 8fe6c0d
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 84 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
],
"require": {
"php": "^8.0",
"doctrine/dbal": "^3.4",
"illuminate/contracts": "^8.37 || ^9.0",
"illuminate/http": "^8.37 || ^9.0",
"spatie/laravel-package-tools": "^1.9.2"
Expand Down
2 changes: 1 addition & 1 deletion database/migrations/create_telegraph_bots_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ return new class () extends Migration {
Schema::create('telegraph_bots', function (Blueprint $table) {
$table->id();
$table->string('token')->unique();
$table->string('name');
$table->string('name')->nullable();

$table->timestamps();
});
Expand Down
2 changes: 1 addition & 1 deletion database/migrations/create_telegraph_chats_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ return new class () extends Migration {
Schema::create('telegraph_chats', function (Blueprint $table) {
$table->id();
$table->string('chat_id');
$table->string('name');
$table->string('name')->nullable();

$table->foreignId('telegraph_bot_id')->constrained('telegraph_bots')->cascadeOnDelete();
$table->timestamps();
Expand Down

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions src/TelegraphServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public function configurePackage(Package $package): void
->hasRoute('api')
->hasMigration('create_telegraph_bots_table')
->hasMigration('create_telegraph_chats_table')
->hasMigration('make_name_nullable_in_telegraph_bots_table')
->hasMigration('make_name_nullable_in_telegraph_chats_table')
->hasCommand(CreateNewBotCommand::class)
->hasCommand(CreateNewChatCommand::class)
->hasCommand(SetTelegramWebhookCommand::class)
Expand Down
6 changes: 0 additions & 6 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ protected function databaseSetup($config): void

$migration = include __DIR__ . '/../database/migrations/create_telegraph_chats_table.php.stub';
$migration->up();

$migration = include __DIR__ . '/../database/migrations/make_name_nullable_in_telegraph_bots_table.php.stub';
$migration->up();

$migration = include __DIR__ . '/../database/migrations/make_name_nullable_in_telegraph_chats_table.php.stub';
$migration->up();
}

protected function filesystemSetup($config): void
Expand Down
53 changes: 20 additions & 33 deletions tests/Unit/Models/TelegraphBotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,8 @@
use DefStudio\Telegraph\Facades\Telegraph as Facade;
use DefStudio\Telegraph\Keyboard\Keyboard;

use DefStudio\Telegraph\Models\TelegraphBot;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Illuminate\Support\Str;
use function Spatie\Snapshots\assertMatchesSnapshot;

uses(LazilyRefreshDatabase::class);

test('name is set to ID if missing', function () {
$bot = TelegraphBot::create([
'token' => Str::uuid(),
]);

expect($bot->name)->toBe("Bot #$bot->id");
});

it('can retrieve its telegram info', function () {
Telegraph::fake();
$bot = make_bot();
Expand Down Expand Up @@ -67,10 +54,10 @@
Telegraph::assertSentData(
\DefStudio\Telegraph\Telegraph::ENDPOINT_REGISTER_BOT_COMMANDS,
[
'commands' => [
['command' => 'foo', 'description' => 'bar'],
],
]
'commands' => [
['command' => 'foo', 'description' => 'bar'],
],
]
);
});

Expand Down Expand Up @@ -159,22 +146,22 @@
$bot = make_bot();

$bot->answerInlineQuery("a99", [
InlineQueryResultGif::make(99, 'https://gif.dev', 'https://thumb.gif.test')
->caption('foo')
->title('bar')
->duration(200)
->height(400)
->width(300)
->keyboard(Keyboard::make()->button('buy')->action('buy')->param('id', 99)),
InlineQueryResultGif::make(98, 'https://gif2.dev', 'https://thumb.gif2.test')
->caption('baz')
->title('quz')
->duration(1200)
->height(1400)
->width(1300)
->keyboard(Keyboard::make()->button('buy')->action('buy')->param('id', 98)),

])->send();
InlineQueryResultGif::make(99, 'https://gif.dev', 'https://thumb.gif.test')
->caption('foo')
->title('bar')
->duration(200)
->height(400)
->width(300)
->keyboard(Keyboard::make()->button('buy')->action('buy')->param('id', 99)),
InlineQueryResultGif::make(98, 'https://gif2.dev', 'https://thumb.gif2.test')
->caption('baz')
->title('quz')
->duration(1200)
->height(1400)
->width(1300)
->keyboard(Keyboard::make()->button('buy')->action('buy')->param('id', 98)),

])->send();

Facade::assertSentData(\DefStudio\Telegraph\Telegraph::ENDPOINT_ANSWER_INLINE_QUERY, [
"inline_query_id" => "a99",
Expand Down
12 changes: 0 additions & 12 deletions tests/Unit/Models/TelegraphChatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,10 @@
use DefStudio\Telegraph\Facades\Telegraph;
use DefStudio\Telegraph\Keyboard\Button;
use DefStudio\Telegraph\Keyboard\Keyboard;
use DefStudio\Telegraph\Models\TelegraphBot;
use Illuminate\Support\Facades\Storage;

use Illuminate\Support\Str;
use function Spatie\Snapshots\assertMatchesSnapshot;

test('name is set to ID if missing', function () {
$bot = TelegraphBot::create([
'token' => Str::uuid(),
]);

$chat = $bot->chats()->create(['chat_id' => Str::uuid()]);

expect($chat->name)->toBe("Chat #$chat->id");
});

it('can send a text message', function () {
Telegraph::fake();
$chat = make_chat();
Expand Down

0 comments on commit 8fe6c0d

Please sign in to comment.