forked from doctrine/orm
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
fabios
committed
Oct 1, 2013
1 parent
b8f368e
commit 59ff676
Showing
12 changed files
with
953 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\Mocks; | ||
|
||
use Doctrine\ORM\Cache\CacheEntry; | ||
use Doctrine\ORM\Cache\CacheKey; | ||
use Doctrine\ORM\Cache\Lock; | ||
use Doctrine\ORM\Cache\Region; | ||
|
||
class CacheRegionMock implements Region | ||
{ | ||
public $calls = array(); | ||
public $returns = array(); | ||
public $name; | ||
|
||
public function addReturn($method, $value) | ||
{ | ||
$this->returns[$method][] = $value; | ||
} | ||
|
||
public function getReturn($method, $datault) | ||
{ | ||
if (isset($this->returns[$method]) && ! empty($this->returns[$method])) { | ||
return array_shift($this->returns[$method]); | ||
} | ||
|
||
return $datault; | ||
} | ||
|
||
public function getName() | ||
{ | ||
$this->calls[__FUNCTION__][] = array(); | ||
|
||
return $this->name; | ||
} | ||
|
||
public function contains(CacheKey $key) | ||
{ | ||
$this->calls[__FUNCTION__][] = array('key' => $key); | ||
|
||
return $this->getReturn(__FUNCTION__, false); | ||
} | ||
|
||
public function evict(CacheKey $key) | ||
{ | ||
$this->calls[__FUNCTION__][] = array('key' => $key); | ||
|
||
return $this->getReturn(__FUNCTION__, true); | ||
} | ||
|
||
public function evictAll() | ||
{ | ||
$this->calls[__FUNCTION__][] = array(); | ||
|
||
return $this->getReturn(__FUNCTION__, true); | ||
} | ||
|
||
public function get(CacheKey $key) | ||
{ | ||
$this->calls[__FUNCTION__][] = array('key' => $key); | ||
|
||
return $this->getReturn(__FUNCTION__, null); | ||
} | ||
|
||
public function put(CacheKey $key, CacheEntry $entry, Lock $lock = null) | ||
{ | ||
$this->calls[__FUNCTION__][] = array('key' => $key, 'entry' => $entry); | ||
|
||
return $this->getReturn(__FUNCTION__, true); | ||
} | ||
|
||
public function clear() | ||
{ | ||
$this->calls = array(); | ||
$this->returns = array(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\Models\Cache; | ||
|
||
/** | ||
* @Entity | ||
* @Table("cache_flight") | ||
* @Cache("NONSTRICT_READ_WRITE") | ||
*/ | ||
class Flight | ||
{ | ||
const CLASSNAME = __CLASS__; | ||
|
||
/** | ||
* @Id | ||
* @Cache | ||
* @ManyToOne(targetEntity="City") | ||
* @JoinColumn(name="leaving_from_city_id", referencedColumnName="id") | ||
*/ | ||
protected $leavingFrom; | ||
|
||
/** | ||
* @Id | ||
* @Cache | ||
* @ManyToOne(targetEntity="City") | ||
* @JoinColumn(name="going_to_city_id", referencedColumnName="id") | ||
*/ | ||
protected $goingTo; | ||
|
||
/** | ||
* @Column(type="date") | ||
*/ | ||
protected $departure; | ||
|
||
/** | ||
* @param \Doctrine\Tests\Models\Cache\City $leavingFrom | ||
* @param \Doctrine\Tests\Models\Cache\City $goingTo | ||
*/ | ||
public function __construct(City $leavingFrom, City $goingTo) | ||
{ | ||
$this->goingTo = $goingTo; | ||
$this->leavingFrom = $leavingFrom; | ||
$this->departure = new \DateTime(); | ||
} | ||
|
||
public function getLeavingFrom() | ||
{ | ||
return $this->leavingFrom; | ||
} | ||
|
||
public function getGoingTo() | ||
{ | ||
return $this->goingTo; | ||
} | ||
|
||
public function getDeparture() | ||
{ | ||
return $this->departure; | ||
} | ||
|
||
public function setDeparture($departure) | ||
{ | ||
$this->departure = $departure; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.