for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* test security contract (mainly getters and defaults)
*/
namespace Graviton\SecurityBundle\Entities;
use Graviton\TestBundle\Test\WebTestCase;
* Class SecurityContractTest
*
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @link http://swisscom.ch
class SecurityAnonymousTest extends WebTestCase
{
* @param string[] $methods methods to mock
* @return \PHPUnit_Framework_MockObject_MockObject|\Graviton\SecurityBundle\Entities\AnonymousUser
protected function getUserMock(array $methods = array())
return $this->getMockBuilder('\Graviton\SecurityBundle\Entities\AnonymousUser')
->disableOriginalConstructor()
->setMethods($methods)
->getMock();
}
* test getting username from contract
* @return void
public function testUsername()
$customerMock = $this->getMockBuilder('\Graviton\SecurityBundle\Entities\SecurityUser')
->setMethods(array('getUsername', 'getId'))
$customerMock
->expects($this->never())
->method('getId')
->will($this->returnValue(0));
->method('getUsername')
->will($this->returnValue('anonymous'));