Skip to content
Snippets Groups Projects
Commit 5c7f7a64 authored by Marko Ivancic's avatar Marko Ivancic
Browse files

Implement basic project structure

parent 40a7ea07
No related branches found
No related tags found
1 merge request!1Relate histories
Showing
with 7586 additions and 51 deletions
# Cache and logs (Symfony2)
/app/cache/*
/app/logs/*
!app/cache/.gitkeep
!app/logs/.gitkeep
# Email spool folder
/app/spool/*
# Cache, session files and logs (Symfony3)
/var/cache/*
/var/logs/*
/var/sessions/*
!var/cache/.gitkeep
!var/logs/.gitkeep
!var/sessions/.gitkeep
# Logs (Symfony4)
/var/log/*
!var/log/.gitkeep
# Parameters
/app/config/parameters.yml
/app/config/parameters.ini
# Managed by Composer
/app/bootstrap.php.cache
/var/bootstrap.php.cache
/bin/*
!bin/console
!bin/symfony_requirements
/.idea/
/vendor/
# Assets and user uploads
/web/bundles/
/web/uploads/
# PHPUnit
/app/phpunit.xml
/phpunit.xml
# Build data
/build/
# Composer PHAR
/composer.phar
# Backup entities generated with doctrine:generate:entities command
**/Entity/*~
# Embedded web-server pid file
/.web-server-pid
/build/
\ No newline at end of file
{
"name": "srcehr/simplesamlphp-module-accounting",
"description": "The SimpleSAMLphp accounting module",
"type": "simplesamlphp-module",
"license": "LGPL-2.1-or-later",
"authors": [
{
"name": "Marko Ivančić",
"email": "marko.ivancic@srce.hr"
}
],
"config": {
"allow-plugins": {
"simplesamlphp/composer-module-installer": true
}
},
"autoload": {
"psr-4": {
"SimpleSAML\\Module\\accounting\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"SimpleSAML\\Test\\Module\\accounting\\": "tests/src/"
}
},
"require": {
"php": "^7.4 || ^8.0",
"ext-pdo": "*",
"ext-pdo_mysql": "*",
"ext-pdo_sqlite": "*",
"simplesamlphp/composer-module-installer": "^1"
},
"require-dev": {
"vimeo/psalm": "^4",
"phpunit/phpunit": "^9",
"squizlabs/php_codesniffer": "^3",
"simplesamlphp/simplesamlphp": "^2@beta",
"simplesamlphp/simplesamlphp-test-framework": "^1"
}
}
This diff is collapsed.
<?php
$config = [
'test-config' => 'test-value',
];
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: SimpleSAMLphp 2.0.0\n"
"Report-Msgid-Bugs-To: simplesamlphp-translation@googlegroups.com\n"
"POT-Creation-Date: 2016-10-12 09:31+0200\n"
"PO-Revision-Date: 2022-01-09 12:14+0200\n"
"Last-Translator: Marko Ivancic <mivanci@srce.hr\n"
"Language: en\n"
"Language-Team: \n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.3.4\n"
msgid "Accounting"
msgstr "Accounting"
<?xml version="1.0"?>
<ruleset name="SimpleSAMLphp accounting module ruleset">
<file>config-templates</file>
<file>src</file>
<file>tests</file>
<file>www</file>
<!-- Use this to exclude paths. You can have multiple patterns -->
<!--<exclude-pattern>*/tests/*</exclude-pattern>-->
<!--<exclude-pattern>*/other/*</exclude-pattern>-->
<exclude-pattern>www/assets/*</exclude-pattern>
<!-- This is the rule we inherit from. If you want to exlude some specific rules, see the docs on how to do that -->
<rule ref="PSR12"/>
</ruleset>
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile="build/.phpunit.cache/test-results"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage cacheDirectory="build/.phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<clover outputFile="build/coverage/clover.xml"/>
<html outputDirectory="build/coverage/html"/>
<text outputFile="php://stdout"/>
</report>
</coverage>
<logging>
<junit outputFile="build/logs/junit.xml"/>
</logging>
<php>
<env name="SIMPLESAMLPHP_CONFIG_DIR" value="tests/config-templates"/>
</php>
</phpunit>
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<directory name="config-templates" />
<directory name="tests" />
<directory name="www" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<!-- Ignore the fact that $config variable is not used in particular config files. -->
<UnusedVariable>
<errorLevel type="suppress">
<directory name="config-templates" />
<directory name="tests/config-templates" />
</errorLevel>
</UnusedVariable>
<!--
Ignore PropertyNotSetInConstructor for phpunit tests. For example, this will ignore things like
"Property SomeTestClass::$backupStaticAttributes is not defined in constructor of SomeTestClass..."
-->
<PropertyNotSetInConstructor>
<errorLevel type="suppress">
<directory name="tests" />
</errorLevel>
</PropertyNotSetInConstructor>
</issueHandlers>
</psalm>
accounting-test:
path: /test
defaults: { _controller: 'SimpleSAML\Module\accounting\Controller\Test::test' }
services:
# default configuration for services in *this* file
_defaults:
public: false
SimpleSAML\Module\accounting\ModuleConfiguration:
class: SimpleSAML\Module\accounting\ModuleConfiguration
\ No newline at end of file
<?php
namespace SimpleSAML\Module\accounting\Controller;
use SimpleSAML\Configuration;
use SimpleSAML\Locale\Translate;
use SimpleSAML\Module\accounting\ModuleConfiguration;
use SimpleSAML\Session;
use SimpleSAML\XHTML\Template;
use Symfony\Component\HttpFoundation\Request;
class Test
{
protected Configuration $configuration;
protected Session $session;
protected ModuleConfiguration $moduleConfiguration;
/**
* @param Configuration $configuration
* @param Session $session The current user session.
* @param ModuleConfiguration $moduleConfiguration
*/
public function __construct(
Configuration $configuration,
Session $session,
ModuleConfiguration $moduleConfiguration
) {
$this->configuration = $configuration;
$this->session = $session;
$this->moduleConfiguration = $moduleConfiguration;
}
/**
* @param Request $request
* @return Template
* @throws \Exception
*/
public function test(Request $request): Template
{
$template = new Template($this->configuration, 'accounting:configuration.twig');
$template->data = [
'test' => Translate::noop('Accounting'),
'test_config' => $this->moduleConfiguration->getConfiguration()->getString('test_config'),
];
return $template;
}
}
<?php
namespace SimpleSAML\Module\accounting\Exceptions\ModuleConfiguration;
class InvalidConfigurationNameException extends \InvalidArgumentException
{
}
<?php
namespace SimpleSAML\Module\accounting;
use SimpleSAML\Configuration;
use SimpleSAML\Module\accounting\Exceptions\ModuleConfiguration\InvalidConfigurationNameException;
class ModuleConfiguration
{
protected Configuration $configuration;
public const FILE_NAME = 'module_accounting.php';
/**
* @throws \Exception
*/
public function __construct(string $fileName = null)
{
$fileName = $fileName ?? self::FILE_NAME;
$this->configuration = Configuration::getConfig($fileName);
}
/**
* @param string $name
* @return mixed
*/
public function getValue(string $name)
{
if (! $this->configuration->hasValue($name)) {
throw new InvalidConfigurationNameException(sprintf('Config name does not exist (%s).', $name));
}
return $this->configuration->getValue($name);
}
/**
* @return Configuration
*/
public function getConfiguration(): Configuration
{
return $this->configuration;
}
}
{% set pagetitle = 'Accounting configuration page'|trans %}
{% set frontpage_section = 'main' %}
{% extends "base.twig" %}
{% block preload %}
<link rel="stylesheet" href="{{ asset('css/accounting.css', 'accounting') }}">
{% endblock %}
{% block content %}
<h2>{{ pagetitle }} </h2>
<p>
{{ test }}, <br>
{{ test_config }}
</p>
{% endblock %}
<?php
$config = [
'test-config' => 'test-value',
];
<?php
namespace SimpleSAML\Test\Module\accounting;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Configuration;
use SimpleSAML\Module\accounting\ModuleConfiguration;
/**
* @covers \SimpleSAML\Module\accounting\ModuleConfiguration
*/
class ModuleConfigurationTest extends TestCase
{
public function testSample(): void
{
// Configuration directory is set by phpunit using php ENV setting feature (check phpunit.xml).
$moduleConfiguration = new ModuleConfiguration('module_accounting_basic.php');
$this->assertInstanceOf(Configuration::class, $moduleConfiguration->getConfiguration());
}
}
.test table {
border: 1px solid #eee;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment