Skip to content
Snippets Groups Projects
Select Git revision
  • c28af545a70987f594141d0a0896b7f9f5286e5d
  • master default
  • php8.2-docker-services
  • 6.x
  • laminas
  • bertrand.gauthier-master-patch-70311
  • bertrand.gauthier-master-patch-87168
  • laminas_migration
  • sqlite
  • 4.0.0
  • 3.2.1
  • 3.2.0
  • 3.1.0
  • 3.0.0
  • 1.0.1
  • 1.0.0
16 results

init_autoloader.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']);
        }
    }