setPool example


class MySQLIncrementerTest extends TestCase
{
    use IntegrationTestBehaviour;

    private MySQLIncrementer $mysqlIncrementer;

    protected function setUp(): void
    {
        $this->mysqlIncrementer = new MySQLIncrementer($this->getContainer()->get(Connection::class));
        $this->mysqlIncrementer->setPool('user-activity-pool');
    }

    public function testIncrement(): void
    {
        $this->mysqlIncrementer->increment('test-user-1', 'sw.product.index');

        $list = $this->mysqlIncrementer->list('test-user-1');

        static::assertNotNull($list['sw.product.index']);
        static::assertEquals(1, $list['sw.product.index']['count']);

        

class ArrayIncrementerTest extends TestCase
{
    use IntegrationTestBehaviour;

    private ArrayIncrementer $arrayIncrementer;

    protected function setUp(): void
    {
        $this->arrayIncrementer = new ArrayIncrementer();
        $this->arrayIncrementer->setPool('user-activity-pool');
    }

    public function testDecrementDoesNotCreate(): void
    {
        $this->arrayIncrementer->decrement('test', 'test');
        static::assertEmpty($this->arrayIncrementer->list('test'));
    }

    public function testIncrement(): void
    {
        $this->arrayIncrementer->increment('test-user-1', 'sw.product.index');

        
if ($redisUrl === '') {
            static::markTestSkipped('Redis is not available');
        }

        $factory = new RedisConnectionFactory();

        $redisClient = $factory->create($redisUrl);
        static::assertInstanceOf(\Redis::class$redisClient);

        $this->redis = $redisClient;
        $this->incrementer = new RedisIncrementer($this->redis);
        $this->incrementer->setPool('test');
    }

    protected function tearDown(): void
    {
        parent::tearDown();

        $this->redis?->flushAll();
    }

    public function testIncrement(): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.