Skip to content
Snippets Groups Projects
Select Git revision
  • e699144c5f45a2d2dfaa7e06acd6b0746d3cde7b
  • master default protected
  • ll-api-test
  • php84
  • detached3
  • detached4
  • detached
  • detached2
  • 5.x
  • trydeps
  • 4.x
  • 6.1.0
  • 6.0.2
  • 6.0.1
  • 6.0
  • 5.0.0
  • 4.0.1
  • 4.0.0
  • 3.0.0
19 results

LoginFilterTest.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    LoginFilterTest.php 1.56 KiB
    <?php
    
    namespace ZfcUserTest\Form;
    
    use ZfcUser\Form\LoginFilter as Filter;
    
    class LoginFilterTest extends \PHPUnit_Framework_TestCase
    {
        /**
         * @covers ZfcUser\Form\LoginFilter::__construct
         */
        public function testConstruct()
        {
            $options = $this->getMock('ZfcUser\Options\ModuleOptions');
            $options->expects($this->once())
                    ->method('getAuthIdentityFields')
                    ->will($this->returnValue(array()));
    
            $filter = new Filter($options);
    
            $inputs = $filter->getInputs();
            $this->assertArrayHasKey('identity', $inputs);
            $this->assertArrayHasKey('credential', $inputs);
    
            $this->assertEquals(0, $inputs['identity']->getValidatorChain()->count());
        }
    
        /**
         * @covers ZfcUser\Form\LoginFilter::__construct
         */
        public function testConstructIdentityEmail()
        {
            $options = $this->getMock('ZfcUser\Options\ModuleOptions');
            $options->expects($this->once())
                    ->method('getAuthIdentityFields')
                    ->will($this->returnValue(array('email')));
    
            $filter = new Filter($options);
    
            $inputs = $filter->getInputs();
            $this->assertArrayHasKey('identity', $inputs);
            $this->assertArrayHasKey('credential', $inputs);
    
            $identity = $inputs['identity'];
    
            // test email as identity
            $validators = $identity->getValidatorChain()->getValidators();
            $this->assertArrayHasKey('instance', $validators[0]);
            $this->assertInstanceOf('\Laminas\Validator\EmailAddress', $validators[0]['instance']);
        }
    }