|
| 1 | +<?php |
| 2 | + |
| 3 | +use Kanboard\Plugin\Registration\Validator\RegistrationValidator; |
| 4 | + |
| 5 | +class RegistrationValidatorTest extends Base |
| 6 | +{ |
| 7 | + public function testWithoutDomainRestriction() |
| 8 | + { |
| 9 | + $validator = new RegistrationValidator($this->container); |
| 10 | + list($result,) = $validator->validateCreation(array( |
| 11 | + 'username' => 'test', |
| 12 | + 'email' => 'test@localhost', |
| 13 | + 'password' => 'test123', |
| 14 | + 'confirmation' => 'test123', |
| 15 | + )); |
| 16 | + |
| 17 | + $this->assertTrue($result); |
| 18 | + } |
| 19 | + |
| 20 | + public function testWithDomainRestriction() |
| 21 | + { |
| 22 | + $this->container['config']->save(array('registration_email_domain' => 'mydomain.tld')); |
| 23 | + $validator = new RegistrationValidator($this->container); |
| 24 | + |
| 25 | + list($result,) = $validator->validateCreation(array( |
| 26 | + 'username' => 'test', |
| 27 | + 'email' => 'test@localhost', |
| 28 | + 'password' => 'test123', |
| 29 | + 'confirmation' => 'test123', |
| 30 | + )); |
| 31 | + |
| 32 | + $this->assertFalse($result); |
| 33 | + |
| 34 | + list($result,) = $validator->validateCreation(array( |
| 35 | + 'username' => 'test', |
| 36 | + 'email' => 'test@mydomain.tld', |
| 37 | + 'password' => 'test123', |
| 38 | + 'confirmation' => 'test123', |
| 39 | + )); |
| 40 | + |
| 41 | + $this->assertTrue($result); |
| 42 | + } |
| 43 | + |
| 44 | + public function testWithMultipleDomainRestriction() |
| 45 | + { |
| 46 | + $this->container['config']->save(array('registration_email_domain' => 'domain1.tld, domain2.tld ,domain3.tld')); |
| 47 | + $validator = new RegistrationValidator($this->container); |
| 48 | + |
| 49 | + list($result,) = $validator->validateCreation(array( |
| 50 | + 'username' => 'test', |
| 51 | + 'email' => 'test@localhost', |
| 52 | + 'password' => 'test123', |
| 53 | + 'confirmation' => 'test123', |
| 54 | + )); |
| 55 | + |
| 56 | + $this->assertFalse($result); |
| 57 | + |
| 58 | + list($result,) = $validator->validateCreation(array( |
| 59 | + 'username' => 'test', |
| 60 | + 'email' => 'test@domain1.tld', |
| 61 | + 'password' => 'test123', |
| 62 | + 'confirmation' => 'test123', |
| 63 | + )); |
| 64 | + |
| 65 | + $this->assertTrue($result); |
| 66 | + |
| 67 | + list($result,) = $validator->validateCreation(array( |
| 68 | + 'username' => 'test', |
| 69 | + 'email' => 'test@domain2.tld', |
| 70 | + 'password' => 'test123', |
| 71 | + 'confirmation' => 'test123', |
| 72 | + )); |
| 73 | + |
| 74 | + $this->assertTrue($result); |
| 75 | + |
| 76 | + list($result,) = $validator->validateCreation(array( |
| 77 | + 'username' => 'test', |
| 78 | + 'email' => 'test@domain3.tld', |
| 79 | + 'password' => 'test123', |
| 80 | + 'confirmation' => 'test123', |
| 81 | + )); |
| 82 | + |
| 83 | + $this->assertTrue($result); |
| 84 | + } |
| 85 | +} |
0 commit comments