Skip to content

Commit

Permalink
Merge pull request #92 from JordanRL/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
JordanRL committed Jun 26, 2021
2 parents 7b5be5d + 76d1328 commit e4dfa39
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 10 deletions.
42 changes: 34 additions & 8 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
build:
environment:
variables:
COMPOSER_ROOT_VERSION: 2.0
php:
version: 8.0
ini:
xdebug.mode: coverage
nodes:
analysis:
project_setup:
override: true
standalone-tests:
tests:
override: [php-scrutinizer-run]
before:
- mkdir build
- mkdir build/logs
override:
- command: php vendor/bin/phpunit
coverage:
file: build/logs/coverage.clover
format: clover
with-modules-tests:
requires:
- node: standalone-tests
tests:
before:
- mkdir build
- mkdir build/logs
- composer require "samsara/fermat-coordinate-systems:dev-master"
- composer require "samsara/fermat-complex-numbers:dev-master"
- composer require "samsara/fermat-matrices-and-vectors:dev-master"
- composer require "samsara/fermat-stats:dev-master"
- composer require "samsara/fermat-algebra-expressions:dev-master"
override:
- command: php vendor/bin/phpunit -c phpunit-modules.xml
coverage:
file: build/logs/coverage.clover
format: clover
build_failure_conditions:
- 'elements.rating(<= D).new.exists'
- 'project.metric_change("scrutinizer.test_coverage", < -0.05)'
- 'project.metric("scrutinizer.test_coverage", < 0.70)'
- 'project.metric("scrutinizer.quality", < 8)'
tools:
external_code_coverage:
timeout: 600
- 'project.metric("scrutinizer.quality", < 8)'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Fermat

[![Build Status](https://travis-ci.com/JordanRL/Fermat.svg?branch=master)](https://travis-ci.com/github/JordanRL/Fermat) [![Code Coverage](https://scrutinizer-ci.com/g/JordanRL/Fermat/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/JordanRL/Fermat/?branch=master) [![Latest Stable Version](https://poser.pugx.org/samsara/fermat/v/stable)](https://packagist.org/packages/samsara/fermat) [![Total Downloads](https://poser.pugx.org/samsara/fermat/downloads)](https://packagist.org/packages/samsara/fermat) [![Latest Unstable Version](https://poser.pugx.org/samsara/fermat/v/unstable)](https://packagist.org/packages/samsara/fermat) [![License](https://poser.pugx.org/samsara/fermat/license)](https://packagist.org/packages/samsara/fermat)
[![Build Status](https://scrutinizer-ci.com/g/JordanRL/Fermat/badges/build.png?b=master)](https://scrutinizer-ci.com/g/JordanRL/Fermat/build-status/master) [![Code Coverage](https://scrutinizer-ci.com/g/JordanRL/Fermat/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/JordanRL/Fermat/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/JordanRL/Fermat/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/JordanRL/Fermat/?branch=master) [![Latest Stable Version](https://poser.pugx.org/samsara/fermat/v/stable)](https://packagist.org/packages/samsara/fermat) [![Total Downloads](https://poser.pugx.org/samsara/fermat/downloads)](https://packagist.org/packages/samsara/fermat) [![License](https://poser.pugx.org/samsara/fermat/license)](https://packagist.org/packages/samsara/fermat)

**This project is unit tested against 8.0, and merges are not accepted unless the tests pass.**

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
"autoload-dev": {
"psr-4": {
"Samsara\\Fermat\\": "tests/Samsara/Fermat/"
"Samsara\\Fermat\\": ["tests/Samsara/Fermat/", "tests-with-modules/Samsara/Fermat"]
}
}
}
23 changes: 23 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="PSR1.Classes.ClassDeclaration"/>
<rule ref="PSR1.Files.SideEffects"/>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<rule ref="Generic.Files.ByteOrderMark"/>
<rule ref="Generic.NamingConventions.ConstructorName"/>
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<rule ref="Squiz.Scope.MemberVarScope"/>
<rule ref="Squiz.PHP.CommentedOutCode"/>
<rule ref="Squiz.PHP.GlobalKeyword"/>
<rule ref="Squiz.Functions.FunctionDuplicateArgument"/>
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<rule ref="PSR2.Classes.PropertyDeclaration"/>
<rule ref="PSR2.Classes.ClassDeclaration"/>
<rule ref="PSR2.Methods.MethodDeclaration"/>
<rule ref="PSR2.Namespaces.UseDeclaration"/>
<rule ref="PSR2.ControlStructures.SwitchDeclaration"/>
</ruleset>
32 changes: 32 additions & 0 deletions phpunit-modules.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
beStrictAboutOutputDuringTests="true"
timeoutForSmallTests="2"
timeoutForMediumTests="15"
timeoutForLargeTests="60"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">./src/Samsara/Fermat</directory>
</include>
<report>
<clover outputFile="build/logs/coverage.clover"/>
</report>
</coverage>
<testsuites>
<testsuite name="Values">
<directory suffix=".php">./tests-with-modules/Samsara/Fermat/Values</directory>
</testsuite>
</testsuites>
<logging/>
</phpunit>
52 changes: 52 additions & 0 deletions tests-with-modules/Samsara/Fermat/Values/ImmutableDecimal2Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Samsara\Fermat\Values;

use PHPUnit\Framework\TestCase;

/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
class ImmutableDecimal2Test extends TestCase
{


/**
* @group arithmetic
* @group complex
* @medium
*/
public function testImaginaryAdd()
{

$zero = new ImmutableDecimal(0);
$one = new ImmutableDecimal(1);
$oneI = new ImmutableDecimal('1i');

$this->assertEquals('1+1i', $one->add($oneI)->getValue());
$this->assertEquals('1+1i', $oneI->add($one)->getValue());
$this->assertEquals('1i', $oneI->add($zero)->getValue());
$this->assertEquals('1i', $zero->add($oneI)->getValue());

}

/**
* @group arithmetic
* @group complex
* @medium
*/
public function testImaginarySubtract()
{

$zero = new ImmutableDecimal(0);
$one = new ImmutableDecimal(1);
$oneI = new ImmutableDecimal('1i');

$this->assertEquals('1-1i', $one->subtract($oneI)->getValue());
$this->assertEquals('-1+1i', $oneI->subtract($one)->getValue());
$this->assertEquals('1i', $oneI->subtract($zero)->getValue());
$this->assertEquals('-1i', $zero->subtract($oneI)->getValue());

}
}

0 comments on commit e4dfa39

Please sign in to comment.