コード例 #1
0
 public function testCanCreateAccount()
 {
     $username = self::usernameForCreation();
     $this->initializeManager();
     $this->assertEquals(\Status::newFatal('authmanager-create-disabled'), $this->manager->canCreateAccount($username));
     $mock = $this->getMockForAbstractClass(PrimaryAuthenticationProvider::class);
     $mock->expects($this->any())->method('getUniqueId')->will($this->returnValue('X'));
     $mock->expects($this->any())->method('accountCreationType')->will($this->returnValue(PrimaryAuthenticationProvider::TYPE_CREATE));
     $mock->expects($this->any())->method('testUserExists')->will($this->returnValue(true));
     $mock->expects($this->any())->method('testUserForCreation')->will($this->returnValue(StatusValue::newGood()));
     $this->primaryauthMocks = [$mock];
     $this->initializeManager(true);
     $this->assertEquals(\Status::newFatal('userexists'), $this->manager->canCreateAccount($username));
     $mock = $this->getMockForAbstractClass(PrimaryAuthenticationProvider::class);
     $mock->expects($this->any())->method('getUniqueId')->will($this->returnValue('X'));
     $mock->expects($this->any())->method('accountCreationType')->will($this->returnValue(PrimaryAuthenticationProvider::TYPE_CREATE));
     $mock->expects($this->any())->method('testUserExists')->will($this->returnValue(false));
     $mock->expects($this->any())->method('testUserForCreation')->will($this->returnValue(StatusValue::newGood()));
     $this->primaryauthMocks = [$mock];
     $this->initializeManager(true);
     $this->assertEquals(\Status::newFatal('noname'), $this->manager->canCreateAccount($username . '<>'));
     $this->assertEquals(\Status::newFatal('userexists'), $this->manager->canCreateAccount('UTSysop'));
     $this->assertEquals(\Status::newGood(), $this->manager->canCreateAccount($username));
     $mock = $this->getMockForAbstractClass(PrimaryAuthenticationProvider::class);
     $mock->expects($this->any())->method('getUniqueId')->will($this->returnValue('X'));
     $mock->expects($this->any())->method('accountCreationType')->will($this->returnValue(PrimaryAuthenticationProvider::TYPE_CREATE));
     $mock->expects($this->any())->method('testUserExists')->will($this->returnValue(false));
     $mock->expects($this->any())->method('testUserForCreation')->will($this->returnValue(StatusValue::newFatal('fail')));
     $this->primaryauthMocks = [$mock];
     $this->initializeManager(true);
     $this->assertEquals(\Status::newFatal('fail'), $this->manager->canCreateAccount($username));
 }