Removed unnecessary API from test cases
This commit is contained in:
parent
4d43f5ca52
commit
d33ee5e7ff
@ -17,17 +17,17 @@ class Action
|
||||
* @GeneratedValue
|
||||
* @Column(type="integer")
|
||||
*/
|
||||
protected $id;
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @Column
|
||||
*/
|
||||
private $name;
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Token", cascade={"persist", "remove"}, mappedBy="action")
|
||||
*/
|
||||
private $tokens;
|
||||
public $tokens;
|
||||
|
||||
public function __construct($name)
|
||||
{
|
||||
@ -38,31 +38,6 @@ class Action
|
||||
public function addToken(Token $token)
|
||||
{
|
||||
$this->tokens[] = $token;
|
||||
$token->setAction($this);
|
||||
}
|
||||
|
||||
public function getTokens()
|
||||
{
|
||||
return $this->tokens;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($nae)
|
||||
{
|
||||
$this->name = $nae;
|
||||
$token->action = $this;
|
||||
}
|
||||
}
|
||||
|
@ -15,35 +15,15 @@ class Client
|
||||
* @GeneratedValue
|
||||
* @Column(type="integer")
|
||||
*/
|
||||
protected $id;
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @Column(unique=true)
|
||||
*/
|
||||
private $name;
|
||||
public $name;
|
||||
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($nae)
|
||||
{
|
||||
$this->name = $nae;
|
||||
}
|
||||
}
|
||||
|
@ -15,26 +15,26 @@ class ComplexAction
|
||||
/**
|
||||
* @Column
|
||||
*/
|
||||
private $name;
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @Id
|
||||
* @OneToOne(targetEntity="Action", cascade={"persist", "remove"})
|
||||
* @JoinColumn(name="action1_id", referencedColumnName="id")
|
||||
*/
|
||||
private $action1;
|
||||
public $action1;
|
||||
|
||||
/**
|
||||
* @Id
|
||||
* @OneToOne(targetEntity="Action", cascade={"persist", "remove"})
|
||||
* @JoinColumn(name="action2_id", referencedColumnName="id")
|
||||
*/
|
||||
private $action2;
|
||||
public $action2;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Token", cascade={"persist", "remove"}, mappedBy="complexAction")
|
||||
*/
|
||||
private $tokens;
|
||||
public $tokens;
|
||||
|
||||
public function __construct(Action $action1, Action $action2, $name)
|
||||
{
|
||||
@ -44,34 +44,25 @@ class ComplexAction
|
||||
$this->tokens = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function addToken(Token $token)
|
||||
{
|
||||
$this->tokens[] = $token;
|
||||
$token->complexAction = $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Action
|
||||
*/
|
||||
public function getAction1()
|
||||
{
|
||||
return $this->action1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Action
|
||||
*/
|
||||
public function getAction2()
|
||||
{
|
||||
return $this->action2;
|
||||
}
|
||||
|
||||
public function addToken(Token $token)
|
||||
{
|
||||
$this->tokens[] = $token;
|
||||
$token->setComplexAction($this);
|
||||
}
|
||||
|
||||
public function getTokens()
|
||||
{
|
||||
return $this->tokens;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
@ -15,18 +15,18 @@ class Login
|
||||
* @GeneratedValue
|
||||
* @Column(type="integer")
|
||||
*/
|
||||
protected $id;
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @Column
|
||||
*/
|
||||
private $name;
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="Token", cascade={"persist", "remove"}, inversedBy="logins")
|
||||
* @JoinColumn(name="token_id", referencedColumnName="token")
|
||||
*/
|
||||
private $token;
|
||||
public $token;
|
||||
|
||||
public function __construct($name)
|
||||
{
|
||||
@ -34,30 +34,10 @@ class Login
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Token $token
|
||||
* @return Token
|
||||
*/
|
||||
public function setToken(Token $token)
|
||||
public function getToken()
|
||||
{
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($nae)
|
||||
{
|
||||
$this->name = $nae;
|
||||
return $this->token;
|
||||
}
|
||||
}
|
||||
|
@ -16,30 +16,30 @@ class Token
|
||||
* @Id
|
||||
* @Column(type="string")
|
||||
*/
|
||||
protected $token;
|
||||
public $token;
|
||||
|
||||
/**
|
||||
* @Column(type="date")
|
||||
*/
|
||||
protected $expiresAt;
|
||||
public $expiresAt;
|
||||
|
||||
/**
|
||||
* @OneToOne(targetEntity="Client")
|
||||
*/
|
||||
protected $client;
|
||||
public $client;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Login", cascade={"persist", "remove"}, mappedBy="token")
|
||||
* @var array
|
||||
*/
|
||||
protected $logins;
|
||||
public $logins;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="Action", cascade={"persist", "remove"}, inversedBy="tokens")
|
||||
* @JoinColumn(name="action_id", referencedColumnName="id")
|
||||
* @var array
|
||||
*/
|
||||
protected $action;
|
||||
public $action;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="ComplexAction", cascade={"persist", "remove"}, inversedBy="tokens")
|
||||
@ -49,7 +49,7 @@ class Token
|
||||
* })
|
||||
* @var ComplexAction
|
||||
*/
|
||||
protected $complexAction;
|
||||
public $complexAction;
|
||||
|
||||
public function __construct($token, Client $client = null)
|
||||
{
|
||||
@ -59,6 +59,31 @@ class Token
|
||||
$this->expiresAt = new \DateTime(date('Y-m-d H:i:s', strtotime("+7 day")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Login $login
|
||||
*/
|
||||
public function addLogin(Login $login)
|
||||
{
|
||||
$this->logins[] = $login;
|
||||
$login->token = $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Client
|
||||
*/
|
||||
public function getClient()
|
||||
{
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Action
|
||||
*/
|
||||
public function getAction()
|
||||
{
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ComplexAction
|
||||
*/
|
||||
@ -67,55 +92,4 @@ class Token
|
||||
return $this->complexAction;
|
||||
}
|
||||
|
||||
public function setComplexAction(ComplexAction $complexAction)
|
||||
{
|
||||
$this->complexAction = $complexAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getLogins()
|
||||
{
|
||||
return $this->logins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Login $login
|
||||
*/
|
||||
public function addLogin(Login $login)
|
||||
{
|
||||
$this->logins[] = $login;
|
||||
$login->setToken($this);
|
||||
}
|
||||
|
||||
public function getAction()
|
||||
{
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
public function setAction(Action $action)
|
||||
{
|
||||
$this->action = $action;
|
||||
}
|
||||
|
||||
public function getToken()
|
||||
{
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
public function getExpiresAt()
|
||||
{
|
||||
return $this->expiresAt;
|
||||
}
|
||||
|
||||
public function getClient()
|
||||
{
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
public function setToken($token)
|
||||
{
|
||||
$this->token = $token;
|
||||
}
|
||||
}
|
||||
|
@ -158,17 +158,17 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$this->assertTrue($this->cache->containsEntity(Token::CLASSNAME, $token->getToken()));
|
||||
$this->assertFalse($this->cache->containsEntity(Token::CLASSNAME, $action->getId()));
|
||||
$this->assertTrue($this->cache->containsEntity(Token::CLASSNAME, $token->token));
|
||||
$this->assertFalse($this->cache->containsEntity(Token::CLASSNAME, $action->id));
|
||||
|
||||
$queryCount = $this->getCurrentQueryCount();
|
||||
$entity = $this->_em->find(Token::CLASSNAME, $token->getToken());
|
||||
$entity = $this->_em->find(Token::CLASSNAME, $token->token);
|
||||
|
||||
$this->assertInstanceOf(Token::CLASSNAME, $entity);
|
||||
$this->assertEquals('token-hash', $entity->getToken());
|
||||
$this->assertEquals('token-hash', $entity->token);
|
||||
|
||||
$this->assertInstanceOf(Action::CLASSNAME, $entity->getAction());
|
||||
$this->assertEquals('exec', $entity->getAction()->getName());
|
||||
$this->assertEquals('exec', $entity->getAction()->name);
|
||||
|
||||
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
|
||||
}
|
||||
@ -189,26 +189,26 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest
|
||||
|
||||
$complexAction->addToken($token);
|
||||
|
||||
$token->setAction($action2);
|
||||
$token->action = $action2;
|
||||
|
||||
$this->_em->persist($token);
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$this->assertTrue($this->cache->containsEntity(Token::CLASSNAME, $token->getToken()));
|
||||
$this->assertFalse($this->cache->containsEntity(Action::CLASSNAME, $action1->getId()));
|
||||
$this->assertFalse($this->cache->containsEntity(Action::CLASSNAME, $action2->getId()));
|
||||
$this->assertFalse($this->cache->containsEntity(Action::CLASSNAME, $action3->getId()));
|
||||
$this->assertTrue($this->cache->containsEntity(Token::CLASSNAME, $token->token));
|
||||
$this->assertFalse($this->cache->containsEntity(Action::CLASSNAME, $action1->id));
|
||||
$this->assertFalse($this->cache->containsEntity(Action::CLASSNAME, $action2->id));
|
||||
$this->assertFalse($this->cache->containsEntity(Action::CLASSNAME, $action3->id));
|
||||
|
||||
$queryCount = $this->getCurrentQueryCount();
|
||||
/**
|
||||
* @var $entity Token
|
||||
*/
|
||||
$entity = $this->_em->find(Token::CLASSNAME, $token->getToken());
|
||||
$entity = $this->_em->find(Token::CLASSNAME, $token->token);
|
||||
|
||||
$this->assertInstanceOf(Token::CLASSNAME, $entity);
|
||||
$this->assertEquals('token-hash', $entity->getToken());
|
||||
$this->assertEquals('token-hash', $entity->token);
|
||||
|
||||
$this->assertEquals($queryCount, $this->getCurrentQueryCount());
|
||||
|
||||
@ -220,9 +220,9 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest
|
||||
$this->assertInstanceOf(Action::CLASSNAME, $entity->getComplexAction()->getAction2());
|
||||
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
|
||||
|
||||
$this->assertEquals('login', $entity->getComplexAction()->getAction1()->getName());
|
||||
$this->assertEquals('login', $entity->getComplexAction()->getAction1()->name);
|
||||
$this->assertEquals($queryCount + 2, $this->getCurrentQueryCount());
|
||||
$this->assertEquals('rememberme', $entity->getComplexAction()->getAction2()->getName());
|
||||
$this->assertEquals('rememberme', $entity->getComplexAction()->getAction2()->name);
|
||||
$this->assertEquals($queryCount + 3, $this->getCurrentQueryCount());
|
||||
}
|
||||
}
|
@ -399,17 +399,17 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$this->assertTrue($this->cache->containsEntity(Token::CLASSNAME, $token->getToken()));
|
||||
$this->assertTrue($this->cache->containsEntity(Token::CLASSNAME, $token->token));
|
||||
|
||||
$queryCount = $this->getCurrentQueryCount();
|
||||
|
||||
$entity = $this->_em->find(Token::CLASSNAME, $token->getToken());
|
||||
$entity = $this->_em->find(Token::CLASSNAME, $token->token);
|
||||
|
||||
$this->assertInstanceOf(Token::CLASSNAME, $entity);
|
||||
$this->assertEquals('token-hash', $entity->getToken());
|
||||
$this->assertEquals('token-hash', $entity->token);
|
||||
$this->assertEquals($queryCount, $this->getCurrentQueryCount());
|
||||
|
||||
$this->assertCount(2, $entity->getLogins());
|
||||
$this->assertCount(2, $entity->logins);
|
||||
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
|
||||
}
|
||||
}
|
||||
|
@ -204,17 +204,17 @@ class SecondLevelCacheOneToOneTest extends SecondLevelCacheAbstractTest
|
||||
|
||||
$queryCount = $this->getCurrentQueryCount();
|
||||
|
||||
$this->assertTrue($this->cache->containsEntity(Token::CLASSNAME, $token->getToken()));
|
||||
$this->assertFalse($this->cache->containsEntity(Client::CLASSNAME, $client->getId()));
|
||||
$this->assertTrue($this->cache->containsEntity(Token::CLASSNAME, $token->token));
|
||||
$this->assertFalse($this->cache->containsEntity(Client::CLASSNAME, $client->id));
|
||||
|
||||
$entity = $this->_em->find(Token::CLASSNAME, $token->getToken());
|
||||
$entity = $this->_em->find(Token::CLASSNAME, $token->token);
|
||||
|
||||
$this->assertInstanceOf(Token::CLASSNAME, $entity);
|
||||
$this->assertInstanceOf(Client::CLASSNAME, $entity->getClient());
|
||||
$this->assertEquals('token-hash', $entity->getToken());
|
||||
$this->assertEquals('token-hash', $entity->token);
|
||||
$this->assertEquals($queryCount, $this->getCurrentQueryCount());
|
||||
|
||||
$this->assertEquals('FabioBatSilva', $entity->getClient()->getName());
|
||||
$this->assertEquals('FabioBatSilva', $entity->getClient()->name);
|
||||
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user