cirrusidentity/simplesamlphp-test-utils
Composer 安装命令:
composer require cirrusidentity/simplesamlphp-test-utils
包简介
Utilities to aid in testing simpleSAMLphp modules
关键字:
README 文档
README
simplesamlphp-test-utils
Utilities to aid in testing SimpleSAMLphp modules
Installation
Install as a dev dependency using composer
composer require --dev cirrusidentity/simplesamlphp-test-utils:dev-master
Update the dependency
composer update -dev cirrusidentity/simplesamlphp-test-utils
Usage
This project makes heavy use of AspectMock to make SSP's internal easier to test.
Adjust your phpunit bootstrap.php per https://github.com/Codeception/AspectMock to setup AspectMock
and also ensure you set backupGlobals="false" in phpunit.xml. See this projects boostrap.php on
some workarounds for getting AspectMock to play nicely with SSP's custom class loader
You can sanity check your project by calling SanityChecker::confirmAspectMockConfigured()
in a test. See AspectMockConfiguredTest for an example.
Clearing Static State
You should reset AspectMock after each test.
use AspectMock\Test as test; ... protected function tearDown() { test::clean(); // remove all registered test doubles }
Several SSP components also cache things across all tests. Some of these classes are
marked with the \SimpleSAML\Utils\ClearableState interface and you can clear this state
at the appropriate time for your tests.
Mock Redirects
Your module may need to redirect the user somewhere. If you try to create a unit test
for a redirect you'll normally have trouble since SSP's redirect method eventually calls exit
You can use MockHttp (which internally uses AspectMock) to change the behavior of the redirect method
to throw an exception instead. You can then catch the exception and asserted the correct URL
was being redirect to
// Enable throwing an exception when redirects would normally be called. MockHttp::throwOnRedirectTrustedURL(); $params = [ 'state' => '1234' ]; try { HTTP::redirectTrustedURL('http://my.url.com', $params); $this->fail('Exception expected'); } catch (RedirectException $e) { $this->assertEquals('redirectTrustedURL', $e->getMessage()); $this->assertEquals('http://my.url.com', $e->getUrl()); $this->assertEquals($params, $e->getParams()); }
Mock Auth Sources
See MockAuthSourceTest.
bootstrap.php needs to explicitly load the Source.php file
$kernel->loadFile($projectRoot . '/vendor/simplesamlphp/simplesamlphp/lib/SimpleSAML/Auth/Source.php');
cirrusidentity/simplesamlphp-test-utils 适用场景与选型建议
cirrusidentity/simplesamlphp-test-utils 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.98k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 02 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「simplesamlphp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cirrusidentity/simplesamlphp-test-utils 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cirrusidentity/simplesamlphp-test-utils 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cirrusidentity/simplesamlphp-test-utils 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SimpleSAMLphp module for using Redis for session storage etc.
A SimpleSAMLPHP module for authorize working with module Perun
SSP Module of various filters developed by Cirrus Identity
Zend\Authentication SAML adapter. Uses existing simpleSAMLphp install.
Filter to remove attribute values which are not properly scoped.
Module with SP files for attribute_check
统计信息
- 总下载量: 3.98k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: LGPL-2.1-only
- 更新时间: 2018-02-20