Skip to content

Commit 620dfde

Browse files
[HttpFoundation] cleanup test case
1 parent aa8b9c0 commit 620dfde

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public function testCloseSession()
7474

7575
public function testReadSession()
7676
{
77-
$this->setFixture(self::PREFIX.'id1', null);
78-
$this->setFixture(self::PREFIX.'id2', 'abc123');
77+
$this->redisClient->set(self::PREFIX.'id1', null);
78+
$this->redisClient->set(self::PREFIX.'id2', 'abc123');
7979

8080
$this->assertEquals('', $this->storage->read('id1'));
8181
$this->assertEquals('abc123', $this->storage->read('id2'));
@@ -85,26 +85,26 @@ public function testWriteSession()
8585
{
8686
$this->assertTrue($this->storage->write('id', 'data'));
8787

88-
$this->assertTrue($this->hasFixture(self::PREFIX.'id'));
89-
$this->assertEquals('data', $this->getFixture(self::PREFIX.'id'));
88+
$this->assertTrue((bool) $this->redisClient->exists(self::PREFIX.'id'));
89+
$this->assertEquals('data', $this->redisClient->get(self::PREFIX.'id'));
9090
}
9191

9292
public function testUseSessionGcMaxLifetimeAsTimeToLive()
9393
{
9494
$this->storage->write('id', 'data');
95-
$ttl = $this->fixtureTtl(self::PREFIX.'id');
95+
$ttl = $this->redisClient->ttl(self::PREFIX.'id');
9696

9797
$this->assertLessThanOrEqual(ini_get('session.gc_maxlifetime'), $ttl);
9898
$this->assertGreaterThanOrEqual(0, $ttl);
9999
}
100100

101101
public function testDestroySession()
102102
{
103-
$this->setFixture(self::PREFIX.'id', 'foo');
103+
$this->redisClient->set(self::PREFIX.'id', 'foo');
104104

105-
$this->assertTrue($this->hasFixture(self::PREFIX.'id'));
105+
$this->assertTrue((bool) $this->redisClient->exists(self::PREFIX.'id'));
106106
$this->assertTrue($this->storage->destroy('id'));
107-
$this->assertFalse($this->hasFixture(self::PREFIX.'id'));
107+
$this->assertFalse((bool) $this->redisClient->exists(self::PREFIX.'id'));
108108
}
109109

110110
public function testGcSession()
@@ -114,12 +114,12 @@ public function testGcSession()
114114

115115
public function testUpdateTimestamp()
116116
{
117-
$lowTTL = 10;
117+
$lowTtl = 10;
118118

119-
$this->setFixture(self::PREFIX.'id', 'foo', $lowTTL);
119+
$this->redisClient->setex(self::PREFIX.'id', $lowTtl, 'foo');
120120
$this->storage->updateTimestamp('id', array());
121121

122-
$this->assertGreaterThan($lowTTL, $this->fixtureTtl(self::PREFIX.'id'));
122+
$this->assertGreaterThan($lowTtl, $this->redisClient->ttl(self::PREFIX.'id'));
123123
}
124124

125125
/**
@@ -142,28 +142,4 @@ public function getOptionFixtures(): array
142142
array(array('prefix' => 'sfs', 'foo' => 'bar'), false),
143143
);
144144
}
145-
146-
protected function setFixture($key, $value, $ttl = null)
147-
{
148-
if (null !== $ttl) {
149-
$this->redisClient->setex($key, $ttl, $value);
150-
} else {
151-
$this->redisClient->set($key, $value);
152-
}
153-
}
154-
155-
protected function getFixture($key)
156-
{
157-
return $this->redisClient->get($key);
158-
}
159-
160-
protected function hasFixture($key): bool
161-
{
162-
return $this->redisClient->exists($key);
163-
}
164-
165-
protected function fixtureTtl($key): int
166-
{
167-
return $this->redisClient->ttl($key);
168-
}
169145
}

0 commit comments

Comments
 (0)