Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Aug 4, 2024
1 parent fe785b9 commit ac27084
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/src/TestCase/AuthSource/Ldap/LdapBindTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testBindSuccesful(): void
$connectionMock = $this->getMockBuilder(Ldap::class)->onlyMethods(
['bind'],
)->disableOriginalConstructor()->getMock();
$connectionMock->expects($this->once())->method('bind')->willReturn(true);
$connectionMock->expects($this->once())->method('bind');
$confTest = new TestCase\AuthSource\Ldap\Bind(
new TestData([
'authSourceData' => Configuration::loadFromArray($authSourceData),
Expand Down
12 changes: 6 additions & 6 deletions tests/src/TestCase/AuthSource/NegotiateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public function testNegotiateSuccess(): void
$KRB5NegotiateAuthMock = $this->getMockBuilder(KRB5NegotiateAuth::class)->onlyMethods(
['doAuthentication', 'getAuthenticatedUser'],
)->disableOriginalConstructor()->getMock();
$KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->will($this->returnValue(true));
$KRB5NegotiateAuthMock->expects($this->any())->method('getAuthenticatedUser')->will(
$this->returnValue('[email protected]'),
);
$KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->willReturn(true);
$KRB5NegotiateAuthMock->expects($this->any())
->method('getAuthenticatedUser')
->willReturn('[email protected]');
$testData = new TestData([
'handle' => $KRB5NegotiateAuthMock,
]);
Expand All @@ -67,7 +67,7 @@ public function testNegotiateNoAuthorzation(): void
$KRB5NegotiateAuthMock = $this->getMockBuilder(KRB5NegotiateAuth::class)->onlyMethods(
['doAuthentication', 'getAuthenticatedUser'],
)->disableOriginalConstructor()->getMock();
$KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->will($this->returnValue(false));
$KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->willReturn(false);
$testData = new TestData([
'handle' => $KRB5NegotiateAuthMock,
]);
Expand All @@ -82,7 +82,7 @@ public function testNegotiateError(): void
$KRB5NegotiateAuthMock = $this->getMockBuilder(KRB5NegotiateAuth::class)->onlyMethods(
['doAuthentication', 'getAuthenticatedUser'],
)->disableOriginalConstructor()->getMock();
$KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->will($this->returnValue(false));
$KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->willReturn(false);
$testData = new TestData([
'handle' => $KRB5NegotiateAuthMock,
'authorization' => 'test',
Expand Down
2 changes: 1 addition & 1 deletion tests/src/TestCase/CertificatesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TestCertificatesTest extends \PHPUnit\Framework\TestCase

public static function setUpBeforeClass(): void
{
self::$certdir = getcwd() . '/vendor/simplesamlphp/xml-security/tests/resources/certificates/';
self::$certdir = getcwd() . '/vendor/simplesamlphp/xml-security/resources/certificates/';
}

public function testCertExpired(): void
Expand Down
15 changes: 13 additions & 2 deletions tests/src/TestCase/Network/ConnectUriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,27 @@
use SimpleSAML\Module\monitor\TestCase;
use SimpleSAML\Module\monitor\TestData;

use function gethostbyname;
use function sprintf;
use function stream_context_create;

/**
* Tests for TestCase\Network\ConnectUri
*/
class TestConnectUriTest extends \PHPUnit\Framework\TestCase
{
protected string $host;

Check warning on line 20 in tests/src/TestCase/Network/ConnectUriTest.php

View workflow job for this annotation

GitHub Actions / Quality control

PropertyNotSetInConstructor

tests/src/TestCase/Network/ConnectUriTest.php:20:22: PropertyNotSetInConstructor: Property SimpleSAML\Module\monitor\Test\TestConnectUriTest::$host is not defined in constructor of SimpleSAML\Module\monitor\Test\TestConnectUriTest or in any methods called in the constructor (see https://psalm.dev/074)

public static function setUpBeforeClass(): void
{
self::$host = gethostbyname('packagist.org');

Check failure on line 24 in tests/src/TestCase/Network/ConnectUriTest.php

View workflow job for this annotation

GitHub Actions / Quality control

UndefinedPropertyAssignment

tests/src/TestCase/Network/ConnectUriTest.php:24:9: UndefinedPropertyAssignment: Static property SimpleSAML\Module\monitor\Test\TestConnectUriTest::$host is not defined (see https://psalm.dev/038)
}

public function testConnectUriOK(): void
{
$testData = new TestData([
'uri' => 'ssl://127.0.0.1:443',
'uri' => sprintf('ssl://%s:443', self::$host),

Check failure on line 30 in tests/src/TestCase/Network/ConnectUriTest.php

View workflow job for this annotation

GitHub Actions / Quality control

UndefinedPropertyAssignment

tests/src/TestCase/Network/ConnectUriTest.php:30:46: UndefinedPropertyAssignment: Static property SimpleSAML\Module\monitor\Test\TestConnectUriTest::$host is not defined (see https://psalm.dev/038)
'timeout' => 3,
'context' => stream_context_create([
"ssl" => [
"capture_peer_cert" => true,
Expand All @@ -35,7 +45,8 @@ public function testConnectUriOK(): void
public function testConnectUriFailed(): void
{
$testData = new TestData([
'uri' => 'ssl://127.0.0.1:442',
'uri' => sprintf('ssl://%s:442', self::$host),

Check failure on line 48 in tests/src/TestCase/Network/ConnectUriTest.php

View workflow job for this annotation

GitHub Actions / Quality control

UndefinedPropertyAssignment

tests/src/TestCase/Network/ConnectUriTest.php:48:46: UndefinedPropertyAssignment: Static property SimpleSAML\Module\monitor\Test\TestConnectUriTest::$host is not defined (see https://psalm.dev/038)
'timeout' => 3,
]);
$connectionTest = new TestCase\Network\ConnectUri($testData);
$testResult = $connectionTest->getTestResult();
Expand Down

0 comments on commit ac27084

Please sign in to comment.