public function testConstruct() { $options = $this->getMock('ZfcUser\\Options\\RegistrationOptionsInterface'); $options->expects($this->once())->method('getEnableUsername')->will($this->returnValue(false)); $options->expects($this->once())->method('getEnableDisplayName')->will($this->returnValue(false)); $options->expects($this->any())->method('getUseRegistrationFormCaptcha')->will($this->returnValue(false)); $form = new Form(null, $options); $elements = $form->getElements(); $this->assertArrayNotHasKey('id', $elements); $this->assertArrayNotHasKey('username', $elements); $this->assertArrayNotHasKey('display_name', $elements); $this->assertArrayHasKey('email', $elements); $this->assertArrayHasKey('password', $elements); $this->assertArrayHasKey('passwordVerify', $elements); }
/** * @dataProvider providerTestConstruct */ public function testConstruct($useCaptcha = false) { $options = $this->getMock('ZfcUser\\Options\\RegistrationOptionsInterface'); $options->expects($this->once())->method('getEnableUsername')->will($this->returnValue(false)); $options->expects($this->once())->method('getEnableDisplayName')->will($this->returnValue(false)); $options->expects($this->any())->method('getUseRegistrationFormCaptcha')->will($this->returnValue($useCaptcha)); if ($useCaptcha && class_exists('\\Zend\\Captcha\\AbstractAdapter')) { $captcha = $this->getMockForAbstractClass('\\Zend\\Captcha\\AbstractAdapter'); $options->expects($this->once())->method('getFormCaptchaOptions')->will($this->returnValue($captcha)); } $form = new Form(null, $options); $elements = $form->getElements(); $this->assertArrayNotHasKey('userId', $elements); $this->assertArrayNotHasKey('username', $elements); $this->assertArrayNotHasKey('display_name', $elements); $this->assertArrayHasKey('email', $elements); $this->assertArrayHasKey('password', $elements); $this->assertArrayHasKey('passwordVerify', $elements); }