public function testNonExistingCustomerNonInSession()
{
$customer = $this->getMock('Sonata\\Component\\Customer\\CustomerInterface');
$customerManager = $this->getMock('Sonata\\Component\\Customer\\CustomerManagerInterface');
$customerManager->expects($this->once())->method('findOneBy')->will($this->returnValue(false));
$customerManager->expects($this->once())->method('create')->will($this->returnValue($customer));
$session = $this->getMock('Symfony\\Component\\HttpFoundation\\Session\\Session');
$user = new ValidUser();
$token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
$token->expects($this->once())->method('getUser')->will($this->returnValue($user));
$securityContext = $this->getMock('Symfony\\Component\\Security\\Core\\SecurityContextInterface');
$securityContext->expects($this->once())->method('isGranted')->will($this->returnValue(true));
$securityContext->expects($this->once())->method('getToken')->will($this->returnValue($token));
$localeDetector = $this->getMock('Sonata\\IntlBundle\\Locale\\LocaleDetectorInterface');
$localeDetector->expects($this->once())->method('getLocale')->will($this->returnValue('en'));
$customerSelector = new CustomerSelector($customerManager, $session, $securityContext, $localeDetector);
$customer = $customerSelector->get();
$this->assertInstanceOf('Sonata\\Component\\Customer\\CustomerInterface', $customer);
}