Skip to content

Commit

Permalink
include IdpDiscoTest.php from simplesamlphp-module-sildisco
Browse files Browse the repository at this point in the history
  • Loading branch information
briskt committed May 20, 2024
1 parent 15d53d4 commit a0b9cfb
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/IdpDiscoTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

include __DIR__ . '/../vendor/autoload.php';
include __DIR__ . '/../vendor/simplesamlphp/simplesamlphp/modules/sildisco/lib/IdPDisco.php';

use PHPUnit\Framework\TestCase;
use SimpleSAML\Module\sildisco\IdPDisco;

class IdpDiscoTest extends TestCase
{

public function testEnableBetaEnabledEmpty()
{
$idpList = [];
$results = IdPDisco::enableBetaEnabled($idpList);
$expected = [];
$this->assertEquals($expected, $results);
}

public function testEnableBetaEnabledNoChange()
{
$isBetaEnabled = 1;
$enabledKey = IdPDisco::$enabledMdKey;
$idpList = [
'idp1' => [$enabledKey => false],
'idp2' => [$enabledKey => true],
];
$expected = $idpList;

$results = IdPDisco::enableBetaEnabled($idpList, $isBetaEnabled);
$this->assertEquals($expected, $results);
}

public function testEnableBetaEnabledChange()
{
$isBetaEnabled = 1;
$enabledKey = IdPDisco::$enabledMdKey;
$betaEnabledKey = IdPDisco::$betaEnabledMdKey;
$idpList = [
'idp1' => [$enabledKey => false],
'idp2' => [$enabledKey => true, $betaEnabledKey => true],
'idp3' => [$enabledKey => false, $betaEnabledKey => true],
'idp4' => [$enabledKey => false, $betaEnabledKey => false],
];
$expected = $idpList;
$expected['idp3'][$enabledKey] = true;

$results = IdPDisco::enableBetaEnabled($idpList, $isBetaEnabled);
$this->assertEquals($expected, $results);
}

}

0 comments on commit a0b9cfb

Please sign in to comment.