Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
10d6a8ad
Commit
10d6a8ad
authored
Jun 07, 2006
by
doctrine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a test case for the first implementation of pessimistic offline locking.
parent
3daf04df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
0 deletions
+70
-0
PessimisticLockingTestCase.php
tests/PessimisticLockingTestCase.php
+67
-0
run.php
tests/run.php
+3
-0
No files found.
tests/PessimisticLockingTestCase.php
0 → 100644
View file @
10d6a8ad
<?
PHP
require_once
(
"UnitTestCase.php"
);
class
Doctrine_PessimisticLockingTestCase
extends
Doctrine_UnitTestCase
{
private
$lockingManager
;
/**
* Sets up everything for the lock testing
*
* Creates a locking manager and a test record to work with.
*/
public
function
setUp
()
{
parent
::
setUp
();
$this
->
lockingManager
=
new
Doctrine_Locking_Manager_Pessimistic
(
$this
->
session
);
// Create sample data to test on
$entry1
=
new
Forum_Entry
();
$entry1
->
author
=
'Bart Simpson'
;
$entry1
->
topic
=
'I love donuts!'
;
$entry1
->
save
();
}
/**
* Tests the basic locking mechanism
*
* Currently tested: successful lock, failed lock, release lock
*/
public
function
testLock
()
{
$entries
=
$this
->
session
->
query
(
"FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'"
);
// Test successful lock
$gotLock
=
$this
->
lockingManager
->
getLock
(
$entries
[
0
],
'romanb'
);
$this
->
assertTrue
(
$gotLock
);
// Test failed lock (another user already got a lock on the entry)
$gotLock
=
$this
->
lockingManager
->
getLock
(
$entries
[
0
],
'konstav'
);
$this
->
assertFalse
(
$gotLock
);
// Test release lock
$released
=
$this
->
lockingManager
->
releaseLock
(
$entries
[
0
],
'romanb'
);
$this
->
assertTrue
(
$released
);
}
/**
* Tests the release mechanism of aged locks
*/
public
function
testReleaseAgedLocks
()
{
$entries
=
$this
->
session
->
query
(
"FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'"
);
$this
->
lockingManager
->
getLock
(
$entries
[
0
],
'romanb'
);
$released
=
$this
->
lockingManager
->
releaseAgedLocks
(
-
1
);
// age -1 seconds => release all
$this
->
assertTrue
(
$released
);
// A second call should return false (no locks left)
$released
=
$this
->
lockingManager
->
releaseAgedLocks
(
-
1
);
$this
->
assertFalse
(
$released
);
}
}
?>
\ No newline at end of file
tests/run.php
View file @
10d6a8ad
...
...
@@ -12,6 +12,7 @@ require_once("RecordTestCase.php");
require_once
(
"AccessTestCase.php"
);
require_once
(
"ValidatorTestCase.php"
);
require_once
(
"CollectionTestCase.php"
);
require_once
(
"PessimisticLockingTestCase.php"
);
require_once
(
"CacheSqliteTestCase.php"
);
require_once
(
"CollectionOffsetTestCase.php"
);
...
...
@@ -45,6 +46,8 @@ $test->addTestCase(new Doctrine_CollectionTestCase());
$test
->
addTestCase
(
new
Doctrine_QueryTestCase
());
$test
->
addTestCase
(
new
Doctrine_PessimisticLockingTestCase
());
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment