Skip to content

Commit

Permalink
rm tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
iGusev committed Jun 30, 2024
1 parent 469526d commit 9665c1f
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 159 deletions.
95 changes: 0 additions & 95 deletions src/Botan.php

This file was deleted.

28 changes: 1 addition & 27 deletions src/Events/EventCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Closure;
use ReflectionFunction;
use TelegramBot\Api\Botan;
use TelegramBot\Api\Types\Update;

class EventCollection
Expand All @@ -14,28 +13,7 @@ class EventCollection
*
* @var array
*/
protected $events;

/**
* Botan tracker
*
* @var \TelegramBot\Api\Botan|null
*/
protected $tracker;

/**
* EventCollection constructor.
*
* @param string $trackerToken
*/
public function __construct($trackerToken = null)
{
$this->events = [];
if ($trackerToken) {
@trigger_error(sprintf('Passing $trackerToken to %s is deprecated', self::class), \E_USER_DEPRECATED);
$this->tracker = new Botan($trackerToken);
}
}
protected $events = [];

/**
* Add new event to collection
Expand All @@ -62,10 +40,6 @@ public function handle(Update $update)
/* @var \TelegramBot\Api\Events\Event $event */
if ($event->executeChecker($update) === true) {
if ($event->executeAction($update) === false) {
if ($this->tracker && ($message = $update->getMessage())) {
$checker = new ReflectionFunction($event->getChecker());
$this->tracker->track($message, $checker->getStaticVariables()['name']);
}
break;
}
}
Expand Down
37 changes: 0 additions & 37 deletions tests/Events/EventCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace TelegramBot\Api\Test\Events;

use PHPUnit\Framework\TestCase;
use TelegramBot\Api\Botan;
use TelegramBot\Api\Events\Event;
use TelegramBot\Api\Events\EventCollection;
use TelegramBot\Api\Types\Update;
Expand Down Expand Up @@ -92,38 +91,6 @@ public function testAdd2($action)
}
}

/**
* @param \Closure $action
* @param \Closure $checker
* @param Update $update
*
* @dataProvider data
*/
public function testHandle1($action, $checker, $update)
{
$item = new EventCollection('testToken');
$name = 'test';
$item->add($action, function ($update) use ($name) {
return true;
});

$mockedTracker = $this->getMockBuilder(Botan::class)
->disableOriginalConstructor()
->getMock();

// Configure the stub.

$mockedTracker->expects($this->once())->method('track')->willReturn(null);

$reflection = new \ReflectionClass($item);
$reflectionProperty = $reflection->getProperty('tracker');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($item, $mockedTracker);
$reflectionProperty->setAccessible(false);

$item->handle($update);
}

/**
* @param \Closure $action
* @param \Closure $checker
Expand All @@ -139,16 +106,12 @@ public function testHandle2($action, $checker, $update)
return true;
});

$mockedTracker = $this->getMockBuilder(Botan::class)
->disableOriginalConstructor()
->getMock();

$mockedEvent = $this->getMockBuilder(Event::class)
->disableOriginalConstructor()
->getMock();

// Configure the stub.
$mockedTracker->expects($this->exactly(0))->method('track')->willReturn(null);
$mockedEvent->expects($this->once())->method('executeChecker')->willReturn(true);
$mockedEvent->expects($this->once())->method('executeAction')->willReturn(true);

Expand Down

0 comments on commit 9665c1f

Please sign in to comment.