1
0
Fork 0
mirror of synced 2024-07-03 13:41:01 +12:00
appwrite/tests/unit/Stats/StatsTest.php

70 lines
1.9 KiB
PHP
Raw Normal View History

2021-08-08 20:24:23 +12:00
<?php
namespace Appwrite\Tests;
use Appwrite\Stats\Stats;
use PHPUnit\Framework\TestCase;
use Utopia\App;
class StatsTest extends TestCase
{
/**
* @var Stats
*/
protected $object = null;
public function setUp(): void
{
$host = App::getEnv('_APP_STATSD_HOST', 'telegraf');
$port = App::getEnv('_APP_STATSD_PORT', 8125);
$connection = new \Domnikl\Statsd\Connection\UdpSocket($host, $port);
$statsd = new \Domnikl\Statsd\Client($connection);
2021-08-08 21:23:44 +12:00
2021-08-08 20:24:23 +12:00
$this->object = new Stats($statsd);
}
public function tearDown(): void
{
}
2021-08-08 21:23:44 +12:00
public function testNamespace()
{
$this->object->setNamespace('appwritetest.usage');
$this->assertEquals('appwritetest.usage', $this->object->getNamespace());
}
2021-08-08 20:24:23 +12:00
public function testParams()
{
$this->object
2021-08-08 21:23:44 +12:00
->setParam('projectId', 'appwrite_test')
->setParam('networkRequestSize', 100)
2021-08-08 20:24:23 +12:00
;
2021-08-08 21:23:44 +12:00
$this->assertEquals('appwrite_test', $this->object->getParam('projectId'));
$this->assertEquals(100, $this->object->getParam('networkRequestSize'));
2021-08-08 20:24:23 +12:00
$this->object->submit();
2021-08-08 21:23:44 +12:00
$this->assertEquals(null, $this->object->getParam('projectId'));
$this->assertEquals(null, $this->object->getParam('networkRequestSize'));
2021-08-08 20:24:23 +12:00
}
public function testReset()
{
$this->object
2021-08-08 21:23:44 +12:00
->setParam('projectId', 'appwrite_test')
->setParam('networkRequestSize', 100)
2021-08-08 20:24:23 +12:00
;
2021-08-08 21:23:44 +12:00
$this->assertEquals('appwrite_test', $this->object->getParam('projectId'));
$this->assertEquals(100, $this->object->getParam('networkRequestSize'));
2021-08-08 20:24:23 +12:00
$this->object->reset();
2021-08-08 21:23:44 +12:00
$this->assertEquals(null, $this->object->getParam('projectId'));
$this->assertEquals(null, $this->object->getParam('networkRequestSize'));
$this->assertEquals('appwrite.usage', $this->object->getNamespace());
2021-08-08 20:24:23 +12:00
}
}