-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/ttl mode on windows #535
base: develop
Are you sure you want to change the base?
Changes from 4 commits
d43fb0b
9b4e48c
c5f3c05
c0ee5f9
deaf901
8b131b4
d4d7e26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
/** | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; under version 2 | ||
* of the License (non-upgradable). | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* Copyright (c) 2018 (original work) Open Assessment Technologies SA; | ||
* | ||
* @author Alexander Zagovorichev <[email protected]> | ||
*/ | ||
|
||
class PhpFileDriverTest extends PHPUnit_Framework_TestCase | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add a namespace to prevent collisions, and this test should work even if tao is not installed, could you consider it a unit test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I can consider it is a unit test and this test will work even if tao is not installed. You don't like that I read real files? |
||
{ | ||
/** | ||
* @var common_persistence_PhpFileDriver | ||
*/ | ||
private $driver; | ||
|
||
protected function setUp() | ||
{ | ||
$this->driver = new common_persistence_PhpFileDriver(); | ||
} | ||
|
||
public function testGetFalse() | ||
{ | ||
self::assertFalse($this->driver->get(false)); | ||
self::assertFalse($this->driver->get(null)); | ||
self::assertFalse($this->driver->get('')); | ||
self::assertFalse($this->driver->get('not existent')); | ||
} | ||
|
||
public function testGet() | ||
{ | ||
$this->driver->connect(false, [ | ||
'dir' => __DIR__ . '/samples/', | ||
'humanReadable' => true, | ||
]); | ||
self::assertEquals('content is here', $this->driver->get('test')); | ||
} | ||
|
||
public function testTtlMode() | ||
{ | ||
$this->driver->connect(false, [ | ||
'dir' => __DIR__ . '/samples/', | ||
'humanReadable' => true, | ||
'ttlMode' => true, | ||
]); | ||
self::assertEquals('Sword', $this->driver->get('testTtl')); | ||
} | ||
|
||
public function ttlFalseDataProvider () | ||
{ | ||
return [ | ||
['testTtlEmpty'], | ||
['testTtlNull'], | ||
['testTtlNoExpires'], | ||
['testTtlExpired'], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider ttlFalseDataProvider | ||
*/ | ||
public function testFalseTtl($id) | ||
{ | ||
$this->driver->connect(false, [ | ||
'dir' => __DIR__ . '/samples/', | ||
'humanReadable' => true, | ||
'ttlMode' => true, | ||
]); | ||
self::assertFalse($this->driver->get($id)); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
return 'content is here'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
return [ | ||
'expiresAt' => time() + 1000, | ||
'value' => 'Sword', | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
return []; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
return [ | ||
'expiresAt' => time() - 1000, | ||
'value' => 'Sword', | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?php | ||
return [ | ||
'value' => 'Sword', | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbout Please, confirm that I can change this behavior: before it worked like this: when file has
return null
- driver returnnull
as a result, but now in such situation it returns 'false'There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ttlMode is true, no file should ever return "null", it should still always return an array with the expiry and the value