summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/EmailLogin/tests/EmailPasswordAuthenticationProviderTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/EmailLogin/tests/EmailPasswordAuthenticationProviderTest.php')
-rw-r--r--www/wiki/extensions/EmailLogin/tests/EmailPasswordAuthenticationProviderTest.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/www/wiki/extensions/EmailLogin/tests/EmailPasswordAuthenticationProviderTest.php b/www/wiki/extensions/EmailLogin/tests/EmailPasswordAuthenticationProviderTest.php
new file mode 100644
index 00000000..34ce9efe
--- /dev/null
+++ b/www/wiki/extensions/EmailLogin/tests/EmailPasswordAuthenticationProviderTest.php
@@ -0,0 +1,54 @@
+<?php
+
+namespace EmailLogin\Test;
+
+use EmailLogin\EmailPasswordAuthenticationProvider;
+use MediaWiki\Auth\AuthenticationRequest;
+use MediaWiki\Auth\AuthenticationResponse;
+use MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider;
+use MediaWiki\Auth\PasswordAuthenticationRequest;
+use Mockery;
+use phpmock\mockery\PHPMockery;
+
+define('DB_REPLICA', 0);
+
+class EmailPasswordAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
+{
+ private $provider;
+
+ protected function setUp()
+ {
+ Mockery::mock('overload:'.AuthenticationResponse::class)
+ ->shouldReceive('newAbstain')
+ ->andReturn(new AuthenticationResponse());
+ Mockery::mock('overload:'.LocalPasswordPrimaryAuthenticationProvider::class)
+ ->shouldReceive('beginPrimaryAuthentication')
+ ->andReturn(new AuthenticationResponse());
+ Mockery::mock('overload:'.PasswordAuthenticationRequest::class);
+ $req = new PasswordAuthenticationRequest();
+ $req->username = 'foo';
+ Mockery::mock('overload:'.AuthenticationRequest::class)
+ ->shouldReceive('getRequestByClass')
+ ->andReturn($req);
+ $row = new \StdClass();
+ $row->user_name = 'foo';
+ Mockery::mock('overload:DatabaseMysqli')
+ ->shouldReceive('selectRow')
+ ->andReturn(false, $row);
+ PHPMockery::mock('EmailLogin', 'wfGetDB')->andReturn(new \DatabaseMysqli());
+ $this->provider = new EmailPasswordAuthenticationProvider();
+ }
+
+ protected function tearDown()
+ {
+ Mockery::close();
+ }
+
+ public function testBeginPrimaryAuthentication()
+ {
+ //With no row
+ $this->assertInstanceOf(AuthenticationResponse::class, $this->provider->beginPrimaryAuthentication([]));
+ //With a row
+ $this->assertInstanceOf(AuthenticationResponse::class, $this->provider->beginPrimaryAuthentication([]));
+ }
+}