Merge branch 'ocrampete16-introduce-code-formatting'

This commit is contained in:
Kevin Frantz 2018-09-13 03:30:19 +02:00
commit 2dd0fc4d02
42 changed files with 553 additions and 299 deletions

View File

@ -0,0 +1 @@
(cd $(dirname $(readlink -f ${0}))/../docker-symfony/ && docker-compose exec php php vendor/bin/php-cs-fixer fix .)

View File

@ -24,3 +24,8 @@
###> phpunit/phpunit ### ###> phpunit/phpunit ###
/phpunit.xml /phpunit.xml
###< phpunit/phpunit ### ###< phpunit/phpunit ###
###> friendsofphp/php-cs-fixer ###
/.php_cs
/.php_cs.cache
###< friendsofphp/php-cs-fixer ###

8
application/.php_cs.dist Normal file
View File

@ -0,0 +1,8 @@
<?php
return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
])
;

View File

@ -27,6 +27,7 @@
"symfony/yaml": "*" "symfony/yaml": "*"
}, },
"require-dev": { "require-dev": {
"friendsofphp/php-cs-fixer": "^2.13",
"phpunit/phpunit": "^7", "phpunit/phpunit": "^7",
"symfony/browser-kit": "*", "symfony/browser-kit": "*",
"symfony/css-selector": "*", "symfony/css-selector": "*",

View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "49bb78c3c5e9cebe665f0e40f98e14b8", "content-hash": "e13afdbcd385c77e0ce9b734cf02f8c0",
"packages": [ "packages": [
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
@ -2191,16 +2191,16 @@
}, },
{ {
"name": "swiftmailer/swiftmailer", "name": "swiftmailer/swiftmailer",
"version": "v6.1.2", "version": "v6.1.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/swiftmailer/swiftmailer.git", "url": "https://github.com/swiftmailer/swiftmailer.git",
"reference": "7d760881d266d63c5e7a1155cbcf2ac656a31ca8" "reference": "8ddcb66ac10c392d3beb54829eef8ac1438595f4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/7d760881d266d63c5e7a1155cbcf2ac656a31ca8", "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/8ddcb66ac10c392d3beb54829eef8ac1438595f4",
"reference": "7d760881d266d63c5e7a1155cbcf2ac656a31ca8", "reference": "8ddcb66ac10c392d3beb54829eef8ac1438595f4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2246,7 +2246,7 @@
"mail", "mail",
"mailer" "mailer"
], ],
"time": "2018-07-13T07:04:35+00:00" "time": "2018-09-11T07:12:52+00:00"
}, },
{ {
"name": "symfony/asset", "name": "symfony/asset",
@ -5099,6 +5099,112 @@
} }
], ],
"packages-dev": [ "packages-dev": [
{
"name": "composer/semver",
"version": "1.4.2",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
"reference": "c7cb9a2095a074d131b65a8a0cd294479d785573"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/semver/zipball/c7cb9a2095a074d131b65a8a0cd294479d785573",
"reference": "c7cb9a2095a074d131b65a8a0cd294479d785573",
"shasum": ""
},
"require": {
"php": "^5.3.2 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^4.5 || ^5.0.5",
"phpunit/phpunit-mock-objects": "2.3.0 || ^3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\Semver\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nils Adermann",
"email": "naderman@naderman.de",
"homepage": "http://www.naderman.de"
},
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
},
{
"name": "Rob Bast",
"email": "rob.bast@gmail.com",
"homepage": "http://robbast.nl"
}
],
"description": "Semver library that offers utilities, version constraint parsing and validation.",
"keywords": [
"semantic",
"semver",
"validation",
"versioning"
],
"time": "2016-08-30T16:08:34+00:00"
},
{
"name": "composer/xdebug-handler",
"version": "1.3.0",
"source": {
"type": "git",
"url": "https://github.com/composer/xdebug-handler.git",
"reference": "b8e9745fb9b06ea6664d8872c4505fb16df4611c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/xdebug-handler/zipball/b8e9745fb9b06ea6664d8872c4505fb16df4611c",
"reference": "b8e9745fb9b06ea6664d8872c4505fb16df4611c",
"shasum": ""
},
"require": {
"php": "^5.3.2 || ^7.0",
"psr/log": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Composer\\XdebugHandler\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "John Stevenson",
"email": "john-stevenson@blueyonder.co.uk"
}
],
"description": "Restarts a process without xdebug.",
"keywords": [
"Xdebug",
"performance"
],
"time": "2018-08-31T19:07:57+00:00"
},
{ {
"name": "easycorp/easy-log-handler", "name": "easycorp/easy-log-handler",
"version": "v1.0.7", "version": "v1.0.7",
@ -5149,6 +5255,102 @@
], ],
"time": "2018-07-27T15:41:37+00:00" "time": "2018-07-27T15:41:37+00:00"
}, },
{
"name": "friendsofphp/php-cs-fixer",
"version": "v2.13.0",
"source": {
"type": "git",
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
"reference": "7136aa4e0c5f912e8af82383775460d906168a10"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/7136aa4e0c5f912e8af82383775460d906168a10",
"reference": "7136aa4e0c5f912e8af82383775460d906168a10",
"shasum": ""
},
"require": {
"composer/semver": "^1.4",
"composer/xdebug-handler": "^1.2",
"doctrine/annotations": "^1.2",
"ext-json": "*",
"ext-tokenizer": "*",
"php": "^5.6 || >=7.0 <7.3",
"php-cs-fixer/diff": "^1.3",
"symfony/console": "^3.2 || ^4.0",
"symfony/event-dispatcher": "^3.0 || ^4.0",
"symfony/filesystem": "^3.0 || ^4.0",
"symfony/finder": "^3.0 || ^4.0",
"symfony/options-resolver": "^3.0 || ^4.0",
"symfony/polyfill-php70": "^1.0",
"symfony/polyfill-php72": "^1.4",
"symfony/process": "^3.0 || ^4.0",
"symfony/stopwatch": "^3.0 || ^4.0"
},
"conflict": {
"hhvm": "*"
},
"require-dev": {
"johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0",
"justinrainbow/json-schema": "^5.0",
"keradus/cli-executor": "^1.1",
"mikey179/vfsstream": "^1.6",
"php-coveralls/php-coveralls": "^2.1",
"php-cs-fixer/accessible-object": "^1.0",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.0.1",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.0.1",
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1",
"phpunitgoodpractices/traits": "^1.5.1",
"symfony/phpunit-bridge": "^4.0"
},
"suggest": {
"ext-mbstring": "For handling non-UTF8 characters in cache signature.",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.",
"symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible."
},
"bin": [
"php-cs-fixer"
],
"type": "application",
"extra": {
"branch-alias": {
"dev-master": "2.13-dev"
}
},
"autoload": {
"psr-4": {
"PhpCsFixer\\": "src/"
},
"classmap": [
"tests/Test/AbstractFixerTestCase.php",
"tests/Test/AbstractIntegrationCaseFactory.php",
"tests/Test/AbstractIntegrationTestCase.php",
"tests/Test/Assert/AssertTokensTrait.php",
"tests/Test/IntegrationCase.php",
"tests/Test/IntegrationCaseFactory.php",
"tests/Test/IntegrationCaseFactoryInterface.php",
"tests/Test/InternalIntegrationCaseFactory.php",
"tests/TestCase.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Dariusz Rumiński",
"email": "dariusz.ruminski@gmail.com"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"description": "A tool to automatically fix PHP code style",
"time": "2018-08-23T13:15:44+00:00"
},
{ {
"name": "myclabs/deep-copy", "name": "myclabs/deep-copy",
"version": "1.8.1", "version": "1.8.1",
@ -5350,6 +5552,57 @@
"description": "Library for handling version information and constraints", "description": "Library for handling version information and constraints",
"time": "2018-07-08T19:19:57+00:00" "time": "2018-07-08T19:19:57+00:00"
}, },
{
"name": "php-cs-fixer/diff",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/diff.git",
"reference": "78bb099e9c16361126c86ce82ec4405ebab8e756"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/78bb099e9c16361126c86ce82ec4405ebab8e756",
"reference": "78bb099e9c16361126c86ce82ec4405ebab8e756",
"shasum": ""
},
"require": {
"php": "^5.6 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7.23 || ^6.4.3",
"symfony/process": "^3.3"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Kore Nordmann",
"email": "mail@kore-nordmann.de"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "SpacePossum"
}
],
"description": "sebastian/diff v2 backport support for PHP5.6",
"homepage": "https://github.com/PHP-CS-Fixer",
"keywords": [
"diff"
],
"time": "2018-02-15T16:58:55+00:00"
},
{ {
"name": "phpspec/prophecy", "name": "phpspec/prophecy",
"version": "1.8.0", "version": "1.8.0",
@ -5664,16 +5917,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "7.3.4", "version": "7.3.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "0356331bf62896dc56e3a15030b23b73f38b2935" "reference": "7b331efabbb628c518c408fdfcaf571156775de2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0356331bf62896dc56e3a15030b23b73f38b2935", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7b331efabbb628c518c408fdfcaf571156775de2",
"reference": "0356331bf62896dc56e3a15030b23b73f38b2935", "reference": "7b331efabbb628c518c408fdfcaf571156775de2",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -5744,7 +5997,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2018-09-05T09:58:53+00:00" "time": "2018-09-08T15:14:29+00:00"
}, },
{ {
"name": "sebastian/code-unit-reverse-lookup", "name": "sebastian/code-unit-reverse-lookup",

View File

@ -1,17 +1,15 @@
<?php <?php
namespace App\Controller; namespace App\Controller;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface ActivationInterface interface ActivationInterface
{ {
public function deactivate():Response; public function deactivate(): Response;
public function activate():Response;
}
public function activate(): Response;
}

View File

@ -1,17 +1,15 @@
<?php <?php
namespace App\Controller; namespace App\Controller;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface CreationInterface interface CreationInterface
{ {
public function create():Response; public function create(): Response;
public function delete():Response;
}
public function delete(): Response;
}

View File

@ -1,4 +1,5 @@
<?php <?php
namespace App\Controller; namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -6,9 +7,7 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
class DefaultController extends AbstractController class DefaultController extends AbstractController
{ {
@ -17,15 +16,14 @@ class DefaultController extends AbstractController
*/ */
public function imprint(): Response public function imprint(): Response
{ {
return $this->render("standard/imprint.html.twig"); return $this->render('standard/imprint.html.twig');
} }
/** /**
* @Route("/", name="homepage") * @Route("/", name="homepage")
*/ */
public function homepage(): Response public function homepage(): Response
{ {
return $this->render("standard/homepage.html.twig"); return $this->render('standard/homepage.html.twig');
} }
} }

View File

@ -1,15 +1,13 @@
<?php <?php
namespace App\Controller; namespace App\Controller;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface ModificationInterface interface ModificationInterface
{ {
public function modify(int $id):Response; public function modify(int $id): Response;
} }

View File

@ -1,32 +1,35 @@
<?php <?php
namespace App\Controller; namespace App\Controller;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
class SourceController implements SourceControllerInterface class SourceController implements SourceControllerInterface
{ {
public function modify(int $id): Response public function modify(int $id): Response
{} {
}
public function show(int $id): Response public function show(int $id): Response
{} {
}
public function activate(): Response public function activate(): Response
{} {
}
public function create(): Response public function create(): Response
{} {
}
public function delete(): Response public function delete(): Response
{} {
}
public function deactivate(): Response public function deactivate(): Response
{} {
}
} }

View File

@ -1,15 +1,13 @@
<?php <?php
namespace App\Controller; namespace App\Controller;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface SourceControllerInterface extends CreationInterface, ActivationInterface, ModificationInterface interface SourceControllerInterface extends CreationInterface, ActivationInterface, ModificationInterface
{ {
public function show(int $id):Response; public function show(int $id): Response;
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace App\Entity; namespace App\Entity;
use App\Entity\Attribut\IdAttribut; use App\Entity\Attribut\IdAttribut;
@ -6,22 +7,20 @@ use App\Entity\Attribut\NodeAttribut;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html * @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html
* @ORM\Entity * @ORM\Entity
* @ORM\InheritanceType("JOINED") * @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string") * @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"user" = "User"}) * @ORM\DiscriminatorMap({"user" = "User"})
*/ */
abstract class AbstractSource implements SourceInterface abstract class AbstractSource implements SourceInterface
{ {
use IdAttribut,NodeAttribut; use IdAttribut,NodeAttribut;
/** /**
*
* @var ConfigurationInterface * @var ConfigurationInterface
*/ */
protected $configuration; protected $configuration;
}
}

View File

@ -1,36 +1,35 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\NodeInterface; use App\Entity\NodeInterface;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
trait ChildsAttribut { trait ChildsAttribut
{
/** /**
* Many Nodes have many childs * Many Nodes have many childs.
*
* @ORM\ManyToMany(targetEntity="Node") * @ORM\ManyToMany(targetEntity="Node")
* @ORM\JoinTable(name="nodes_childs", * @ORM\JoinTable(name="nodes_childs",
* joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}, * joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")} * inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}
* ) * )
*
* @var ArrayCollection|NodeInterface[] * @var ArrayCollection|NodeInterface[]
*/ */
protected $childs; protected $childs;
public function getChilds(): ArrayCollection public function getChilds(): ArrayCollection
{ {
return $this->getChilds(); return $this->getChilds();
} }
public function setChilds(ArrayCollection $childs): void public function setChilds(ArrayCollection $childs): void
{ {
$this->childs = $childs; $this->childs = $childs;
} }
} }

View File

@ -1,15 +1,15 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface ChildsAttributeInterface interface ChildsAttributeInterface
{ {
public function setChilds(ArrayCollection $childs):void; public function setChilds(ArrayCollection $childs): void;
public function getChilds():ArrayCollection;
}
public function getChilds(): ArrayCollection;
}

View File

@ -1,29 +1,28 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
trait IdAttribut { trait IdAttribut
{
/** /**
* @ORM\Id() * @ORM\Id()
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @ORM\Column(type="integer")(strategy="AUTO") * @ORM\Column(type="integer")(strategy="AUTO")
*/ */
protected $id; protected $id;
public function setId(int $id): void public function setId(int $id): void
{ {
$this->id = $id; $this->id = $id;
} }
public function getId(): int public function getId(): int
{ {
return $this->id; return $this->id;
} }
} }

View File

@ -1,15 +1,13 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface IdAttributInterface interface IdAttributInterface
{ {
public function setId(int $id): void; public function setId(int $id): void;
public function getId(): int; public function getId(): int;
} }

View File

@ -1,30 +1,28 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
use App\Entity\NodeInterface; use App\Entity\NodeInterface;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
trait NodeAttribut{ trait NodeAttribut
{
/** /**
* @var NodeInterface * @var NodeInterface
* @ORM\OneToOne(targetEntity="Node") * @ORM\OneToOne(targetEntity="Node")
* @ORM\JoinColumn(name="node_id", referencedColumnName="id") * @ORM\JoinColumn(name="node_id", referencedColumnName="id")
*/ */
protected $node; protected $node;
public function setNode(NodeInterface $node): void public function setNode(NodeInterface $node): void
{ {
$this->node = $node; $this->node = $node;
} }
public function getNode(): NodeInterface public function getNode(): NodeInterface
{ {
return $this->node; return $this->node;
} }
} }

View File

@ -1,17 +1,15 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
use App\Entity\NodeInterface; use App\Entity\NodeInterface;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface NodeAttributInterface interface NodeAttributInterface
{ {
public function setNode(NodeInterface $node):void; public function setNode(NodeInterface $node): void;
public function getNode():NodeInterface;
}
public function getNode(): NodeInterface;
}

View File

@ -1,24 +1,24 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\NodeInterface; use App\Entity\NodeInterface;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
trait ParentAttribut { trait ParentAttribut
{
/** /**
* Many Nodes have many parents * Many Nodes have many parents.
* *
* @ORM\ManyToMany(targetEntity="Node") * @ORM\ManyToMany(targetEntity="Node")
* @ORM\JoinTable(name="nodes_parents", * @ORM\JoinTable(name="nodes_parents",
* joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}, * joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")} * inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}
* ) * )
*
* @var ArrayCollection|NodeInterface[] * @var ArrayCollection|NodeInterface[]
*/ */
protected $parents; protected $parents;
@ -33,4 +33,3 @@ trait ParentAttribut {
$this->parents = $parents; $this->parents = $parents;
} }
} }

View File

@ -1,17 +1,15 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface ParentsAttributInterface interface ParentsAttributInterface
{ {
public function setParents(ArrayCollection $parents):void; public function setParents(ArrayCollection $parents): void;
public function getParents():ArrayCollection;
}
public function getParents(): ArrayCollection;
}

View File

@ -1,24 +1,24 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
trait PasswordAttribut { trait PasswordAttribut
{
/** /**
* @ORM\Column(type="string", length=64) * @ORM\Column(type="string", length=64)
*/ */
protected $password; protected $password;
public function getPassword():?string public function getPassword(): ?string
{ {
return $this->password; return $this->password;
} }
public function setPassword(string $password):void{ public function setPassword(string $password): void
{
$this->password = $password; $this->password = $password;
} }
} }

View File

@ -1,18 +1,18 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
trait PlainPasswordAttribute { trait PlainPasswordAttribute
{
/** /**
*
* @Assert\NotBlank() * @Assert\NotBlank()
* @Assert\Length(max=4096) * @Assert\Length(max=4096)
*
* @var string * @var string
*/ */
private $plainPassword; private $plainPassword;
@ -27,4 +27,3 @@ trait PlainPasswordAttribute {
$this->plainPassword = $password; $this->plainPassword = $password;
} }
} }

View File

@ -1,27 +1,29 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
use App\Entity\SourceInterface; use App\Entity\SourceInterface;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
trait SourceAttribut { trait SourceAttribut
{
/** /**
* @ORM\OneToOne(targetEntity="AbstractSource") * @ORM\OneToOne(targetEntity="AbstractSource")
* @ORM\JoinColumn(name="source_id", referencedColumnName="id") * @ORM\JoinColumn(name="source_id", referencedColumnName="id")
*
* @var SourceInterface * @var SourceInterface
*/ */
protected $source; protected $source;
public function getSource():SourceInterface{ public function getSource(): SourceInterface
{
return $this->source; return $this->source;
} }
public function setSource(SourceInterface $source):void{ public function setSource(SourceInterface $source): void
{
$this->source = $source; $this->source = $source;
} }
} }

View File

@ -1,17 +1,15 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
use App\Entity\SourceInterface; use App\Entity\SourceInterface;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface SourceAttributInterface interface SourceAttributInterface
{ {
public function getSource():SourceInterface; public function getSource(): SourceInterface;
public function setSource(SourceInterface $source):void;
}
public function setSource(SourceInterface $source): void;
}

View File

@ -1,25 +1,26 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
/** /**
* This trait doesn't need an own interface because it's covered by symfony * This trait doesn't need an own interface because it's covered by symfony.
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
trait UsernameAttribut{ trait UsernameAttribut
{
/** /**
* @ORM\Column(type="string", length=25, unique=true) * @ORM\Column(type="string", length=25, unique=true)
*/ */
protected $username; protected $username;
public function getUsername():?string public function getUsername(): ?string
{ {
return $this->username; return $this->username;
} }
public function setUsername(string $username):void{ public function setUsername(string $username): void
{
$this->username = \trim($username); $this->username = \trim($username);
} }
} }

View File

@ -1,48 +1,48 @@
<?php <?php
namespace App\Entity; namespace App\Entity;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
class Configuration implements ConfigurationInterface class Configuration implements ConfigurationInterface
{ {
/** /**
*
* @var PropertyInterface * @var PropertyInterface
*/ */
protected $read; protected $read;
/** /**
*
* @var PropertyInterface * @var PropertyInterface
*/ */
protected $write; protected $write;
/** /**
*
* @var PropertyInterface * @var PropertyInterface
*/ */
protected $administrate; protected $administrate;
public function setAdministrate(Property $administrate): void public function setAdministrate(Property $administrate): void
{} {
}
public function getAdministrate(): Property public function getAdministrate(): Property
{} {
}
public function setWrite(Property $write): void public function setWrite(Property $write): void
{} {
}
public function getWrite(): Property public function getWrite(): Property
{} {
}
public function setRead(Property $read): void public function setRead(Property $read): void
{} {
}
public function getRead(): Property public function getRead(): Property
{} {
}
} }

View File

@ -1,24 +1,23 @@
<?php <?php
namespace App\Entity; namespace App\Entity;
/** /**
* This class is not a source! * This class is not a source!
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface ConfigurationInterface interface ConfigurationInterface
{ {
public function setRead(Property $read):void; public function setRead(Property $read): void;
public function getRead():Property;
public function setWrite(Property $write):void;
public function getWrite():Property;
public function setAdministrate(Property $administrate):void;
public function getAdministrate():Property;
}
public function getRead(): Property;
public function setWrite(Property $write): void;
public function getWrite(): Property;
public function setAdministrate(Property $administrate): void;
public function getAdministrate(): Property;
}

View File

@ -1,4 +1,5 @@
<?php <?php
namespace App\Entity; namespace App\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -8,7 +9,6 @@ use App\Entity\Attribut\ParentAttribut;
use App\Entity\Attribut\ChildsAttribut; use App\Entity\Attribut\ChildsAttribut;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
* @ORM\Table(name="node") * @ORM\Table(name="node")
* @ORM\Entity(repositoryClass="App\Repository\NodeRepository") * @ORM\Entity(repositoryClass="App\Repository\NodeRepository")
@ -16,8 +16,7 @@ use App\Entity\Attribut\ChildsAttribut;
class Node implements NodeInterface class Node implements NodeInterface
{ {
use IdAttribut, use IdAttribut,
SourceAttribut, SourceAttribut,
ParentAttribut, ParentAttribut,
ChildsAttribut; ChildsAttribut;
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace App\Entity; namespace App\Entity;
use App\Entity\Attribut\SourceAttributInterface; use App\Entity\Attribut\SourceAttributInterface;
@ -7,10 +8,8 @@ use App\Entity\Attribut\ParentsAttributInterface;
use App\Entity\Attribut\ChildsAttributeInterface; use App\Entity\Attribut\ChildsAttributeInterface;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface NodeInterface extends SourceAttributInterface, IdAttributInterface,ParentsAttributInterface,ChildsAttributeInterface interface NodeInterface extends SourceAttributInterface, IdAttributInterface, ParentsAttributInterface, ChildsAttributeInterface
{} {
}

View File

@ -1,32 +1,29 @@
<?php <?php
namespace App\Entity; namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
class Property implements PropertyInterface class Property implements PropertyInterface
{ {
/** /**
*
* @var ArrayCollection|NodeInterface[] * @var ArrayCollection|NodeInterface[]
*/ */
protected $whitelist; protected $whitelist;
/** /**
*
* @var ArrayCollection|NodeInterface[] * @var ArrayCollection|NodeInterface[]
*/ */
protected $blacklist; protected $blacklist;
public function getLegitimated(): ArrayCollection public function getLegitimated(): ArrayCollection
{} {
}
public function isLegitimated(SourceInterface $source): bool public function isLegitimated(SourceInterface $source): bool
{} {
}
} }

View File

@ -1,17 +1,15 @@
<?php <?php
namespace App\Entity; namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface PropertyInterface interface PropertyInterface
{ {
public function isLegitimated(SourceInterface $source):bool; public function isLegitimated(SourceInterface $source): bool;
public function getLegitimated():ArrayCollection;
}
public function getLegitimated(): ArrayCollection;
}

View File

@ -1,15 +1,13 @@
<?php <?php
namespace App\Entity; namespace App\Entity;
use App\Entity\Attribut\NodeAttributInterface; use App\Entity\Attribut\NodeAttributInterface;
use App\Entity\Attribut\IdAttributInterface; use App\Entity\Attribut\IdAttributInterface;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface SourceInterface extends IdAttributInterface, NodeAttributInterface interface SourceInterface extends IdAttributInterface, NodeAttributInterface
{ {
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace App\Entity; namespace App\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -6,7 +7,6 @@ use FOS\UserBundle\Model\User as BaseUser;
use App\Entity\Attribut\NodeAttribut; use App\Entity\Attribut\NodeAttribut;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
* @ORM\Table(name="source_user") * @ORM\Table(name="source_user")
* @ORM\Entity(repositoryClass="App\Repository\UserRepository") * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
@ -14,24 +14,24 @@ use App\Entity\Attribut\NodeAttribut;
class User extends BaseUser implements SourceInterface class User extends BaseUser implements SourceInterface
{ {
use NodeAttribut; use NodeAttribut;
/** /**
* @ORM\Column(name="is_active", type="boolean") * @ORM\Column(name="is_active", type="boolean")
*/ */
private $isActive; private $isActive;
/** /**
* @ORM\Id() * @ORM\Id()
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @ORM\Column(type="integer")(strategy="AUTO") * @ORM\Column(type="integer")(strategy="AUTO")
*/ */
protected $id; protected $id;
public function setId(int $id): void public function setId(int $id): void
{ {
$this->id = $id; $this->id = $id;
} }
public function getId(): int public function getId(): int
{ {
return $this->id; return $this->id;
@ -39,8 +39,8 @@ class User extends BaseUser implements SourceInterface
public function __construct() public function __construct()
{ {
parent::__construct (); parent::__construct();
/** /*
* @todo Remove this later * @todo Remove this later
* @var \App\Entity\User $isActive * @var \App\Entity\User $isActive
*/ */

View File

@ -10,29 +10,29 @@ use Symfony\Component\HttpFoundation\RequestStack;
class UserMenuEvent extends Event class UserMenuEvent extends Event
{ {
public const EVENT = 'app.menu.topbar.user'; public const EVENT = 'app.menu.topbar.user';
/** /**
* @var FactoryInterface * @var FactoryInterface
*/ */
private $factory; private $factory;
/** /**
* @var ItemInterface * @var ItemInterface
*/ */
private $item; private $item;
/** /**
* @var RequestStack * @var RequestStack
*/ */
private $request; private $request;
public function __construct(FactoryInterface $factory, ItemInterface $item, RequestStack $request) public function __construct(FactoryInterface $factory, ItemInterface $item, RequestStack $request)
{ {
$this->factory = $factory; $this->factory = $factory;
$this->item = $item; $this->item = $item;
$this->request = $request; $this->request = $request;
} }
/** /**
* @return FactoryInterface * @return FactoryInterface
*/ */
@ -40,7 +40,7 @@ class UserMenuEvent extends Event
{ {
return $this->factory; return $this->factory;
} }
/** /**
* @return ItemInterface * @return ItemInterface
*/ */
@ -48,7 +48,7 @@ class UserMenuEvent extends Event
{ {
return $this->item; return $this->item;
} }
/** /**
* @return RequestStack * @return RequestStack
*/ */
@ -56,4 +56,4 @@ class UserMenuEvent extends Event
{ {
return $this->request; return $this->request;
} }
} }

View File

@ -1,11 +1,11 @@
<?php <?php
namespace App\Form; namespace App\Form;
use App\Entity\User; use App\Entity\User;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType; use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType; use Symfony\Component\Form\Extension\Core\Type\PasswordType;
@ -16,18 +16,18 @@ class UserType extends AbstractType
{ {
$builder $builder
->add('username', TextType::class) ->add('username', TextType::class)
->add('plainPassword', RepeatedType::class, array( ->add('plainPassword', RepeatedType::class, [
'type' => PasswordType::class, 'type' => PasswordType::class,
'first_options' => array('label' => 'Password'), 'first_options' => ['label' => 'Password'],
'second_options' => array('label' => 'Repeat Password'), 'second_options' => ['label' => 'Repeat Password'],
)) ])
; ;
} }
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults(array( $resolver->setDefaults([
'data_class' => User::class, 'data_class' => User::class,
)); ]);
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
// src/Menu/Menu.php // src/Menu/Menu.php
namespace App\Menu; namespace App\Menu;
@ -11,36 +12,35 @@ use Symfony\Component\HttpFoundation\RequestStack;
class Menu class Menu
{ {
/** /**
* @var EventDispatcherInterface * @var EventDispatcherInterface
*/ */
private $dispatcher; private $dispatcher;
/** /**
* @var FactoryInterface * @var FactoryInterface
*/ */
private $factory; private $factory;
public function __construct(FactoryInterface $factory, EventDispatcherInterface $dispatcher) public function __construct(FactoryInterface $factory, EventDispatcherInterface $dispatcher)
{ {
$this->dispatcher = $dispatcher; $this->dispatcher = $dispatcher;
$this->factory = $factory; $this->factory = $factory;
} }
public function userTopbar(RequestStack $request): ItemInterface public function userTopbar(RequestStack $request): ItemInterface
{ {
$menu = $this->factory->createItem('root', array( $menu = $this->factory->createItem('root', [
'childrenAttributes' => array( 'childrenAttributes' => [
'class' => 'navbar-nav mr-auto', 'class' => 'navbar-nav mr-auto',
), ],
)); ]);
$this->dispatcher->dispatch( $this->dispatcher->dispatch(
UserMenuEvent::EVENT, UserMenuEvent::EVENT,
new UserMenuEvent($this->factory, $menu, $request) new UserMenuEvent($this->factory, $menu, $request)
); );
return $menu; return $menu;
} }
} }

View File

@ -1,14 +1,12 @@
<?php <?php
namespace App\Repository; namespace App\Repository;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
class UserRepository extends EntityRepository class UserRepository extends EntityRepository
{ {
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace App\Subscriber; namespace App\Subscriber;
use App\Event\Menu\Topbar\UserMenuEvent; use App\Event\Menu\Topbar\UserMenuEvent;
@ -8,15 +9,12 @@ use Symfony\Component\Translation\TranslatorInterface;
class UserMenuSubscriber implements EventSubscriberInterface class UserMenuSubscriber implements EventSubscriberInterface
{ {
/** /**
*
* @var TokenStorageInterface * @var TokenStorageInterface
*/ */
private $tokenStorage; private $tokenStorage;
/** /**
*
* @var TranslatorInterface * @var TranslatorInterface
*/ */
private $translator; private $translator;
@ -33,61 +31,64 @@ class UserMenuSubscriber implements EventSubscriberInterface
$menu->addChild('start', [ $menu->addChild('start', [
'route' => 'homepage', 'route' => 'homepage',
'attributes' => [ 'attributes' => [
'icon' => 'fab fa-font-awesome-flag' 'icon' => 'fab fa-font-awesome-flag',
],
]
);
$menu->addChild(
'imprint',
[
'route' => 'imprint',
'attributes' => [
'icon' => 'fas fa-address-card',
],
] ]
]); );
$menu->addChild('imprint', [
'route' => 'imprint',
'attributes' => [
'icon' => 'fas fa-address-card'
]
]);
$dropdown = $menu->addChild($this->tokenStorage->getToken() $dropdown = $menu->addChild($this->tokenStorage->getToken()
->getUsername() ?? 'user', [ ->getUsername() ?? 'user', [
'attributes' => [ 'attributes' => [
'dropdown' => true, 'dropdown' => true,
'icon' => 'fas fa-user' 'icon' => 'fas fa-user',
] ],
]); ]);
if ($this->tokenStorage->getToken()->getRoles()) { if ($this->tokenStorage->getToken()->getRoles()) {
$dropdown->addChild('logout', [ $dropdown->addChild('logout', [
'route' => 'logout', 'route' => 'logout',
'attributes' => [ 'attributes' => [
'icon' => 'fas fa-sign-out-alt', 'icon' => 'fas fa-sign-out-alt',
'divider_append' => true 'divider_append' => true,
] ],
]); ]);
$dropdown->addChild('edit profile', [ $dropdown->addChild('edit profile', [
'route' => 'fos_user_profile_edit', 'route' => 'fos_user_profile_edit',
'attributes' => [ 'attributes' => [
'icon' => 'fas fa-user-edit', 'icon' => 'fas fa-user-edit',
'divider_append' => true 'divider_append' => true,
] ],
]); ]);
} else { } else {
$dropdown->addChild('login', [ $dropdown->addChild('login', [
'route' => 'fos_user_security_login', 'route' => 'fos_user_security_login',
'attributes' => [ 'attributes' => [
'divider_append' => true, 'divider_append' => true,
'icon' => 'fas fa-sign-in-alt' 'icon' => 'fas fa-sign-in-alt',
] ],
]); ]);
} }
$dropdown->addChild('register', [ $dropdown->addChild('register', [
'route' => 'fos_user_registration_register', 'route' => 'fos_user_registration_register',
'attributes' => [ 'attributes' => [
'icon' => 'fas fa-file-signature' 'icon' => 'fas fa-file-signature',
] ],
]); ]);
} }
public static function getSubscribedEvents(): array public static function getSubscribedEvents(): array
{ {
return [ return [
UserMenuEvent::EVENT => 'onUserMenuConfigure' UserMenuEvent::EVENT => 'onUserMenuConfigure',
]; ];
} }
} }

View File

@ -1,4 +1,10 @@
{ {
"composer/semver": {
"version": "1.4.2"
},
"composer/xdebug-handler": {
"version": "1.3.0"
},
"doctrine/annotations": { "doctrine/annotations": {
"version": "1.0", "version": "1.0",
"recipe": { "recipe": {
@ -80,6 +86,15 @@
"fig/link-util": { "fig/link-util": {
"version": "1.0.0" "version": "1.0.0"
}, },
"friendsofphp/php-cs-fixer": {
"version": "2.2",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "2.2",
"ref": "81dee417d2cc60cd1c9d6208dff2ec22a1103e93"
}
},
"friendsofsymfony/user-bundle": { "friendsofsymfony/user-bundle": {
"version": "v2.1.2" "version": "v2.1.2"
}, },
@ -110,6 +125,9 @@
"phar-io/version": { "phar-io/version": {
"version": "2.0.1" "version": "2.0.1"
}, },
"php-cs-fixer/diff": {
"version": "v1.3.0"
},
"phpdocumentor/reflection-common": { "phpdocumentor/reflection-common": {
"version": "1.0.1" "version": "1.0.1"
}, },

View File

@ -1,15 +1,13 @@
<?php <?php
namespace App\Tests\Unit\Controller;
namespace App\Tests\Unit\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use App\Controller\DefaultControllerInterface; use App\Controller\DefaultControllerInterface;
use App\Controller\DefaultController; use App\Controller\DefaultController;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
class DefaultControllerTest extends WebTestCase class DefaultControllerTest extends WebTestCase
{ {
@ -17,21 +15,23 @@ class DefaultControllerTest extends WebTestCase
* @var DefaultControllerInterface * @var DefaultControllerInterface
*/ */
protected $defaultController; protected $defaultController;
public function setUp():void{ public function setUp(): void
$this->defaultController = new DefaultController(); {
$this->defaultController = new DefaultController();
} }
public function testHomepage():void{ public function testHomepage(): void
{
$client = static::createClient(); $client = static::createClient();
$client->request('GET', '/'); $client->request('GET', '/');
$this->assertEquals(200, $client->getResponse()->getStatusCode()); $this->assertEquals(200, $client->getResponse()->getStatusCode());
} }
public function testImprint():void{ public function testImprint(): void
{
$client = static::createClient(); $client = static::createClient();
$client->request('GET', '/imprint'); $client->request('GET', '/imprint');
$this->assertEquals(200, $client->getResponse()->getStatusCode()); $this->assertEquals(200, $client->getResponse()->getStatusCode());
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace App\Tests\Unit\Controller; namespace App\Tests\Unit\Controller;
use App\Controller\UserController; use App\Controller\UserController;
@ -6,41 +7,38 @@ use App\Controller\UserControllerInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
class UserControllerTest extends WebTestCase class UserControllerTest extends WebTestCase
{ {
/** /**
*
* @var UserControllerInterface * @var UserControllerInterface
*/ */
protected $userController; protected $userController;
public function setUp():void{ public function setUp(): void
{
$this->userController = new UserController(); $this->userController = new UserController();
} }
public function testLogout(): void public function testLogout(): void
{ {
$client = static::createClient(); $client = static::createClient();
$client->request('GET', '/user/logout'); $client->request('GET', '/user/logout');
$this->assertEquals(200, $client->getResponse()->getStatusCode()); $this->assertEquals(200, $client->getResponse()->getStatusCode());
} }
public function testLogin(): void public function testLogin(): void
{ {
$client = static::createClient(); $client = static::createClient();
$client->request('GET', '/login'); $client->request('GET', '/login');
$this->assertEquals(200, $client->getResponse()->getStatusCode()); $this->assertEquals(200, $client->getResponse()->getStatusCode());
} }
public function testRegister():void public function testRegister(): void
{ {
$client = static::createClient(); $client = static::createClient();
$client->request('GET', '/user/register'); $client->request('GET', '/user/register');
$this->assertEquals(200, $client->getResponse()->getStatusCode()); $this->assertEquals(200, $client->getResponse()->getStatusCode());
} }
} }

View File

@ -1,38 +1,38 @@
<?php <?php
namespace tests\unit\Entity; namespace tests\unit\Entity;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use App\Entity\User; use App\Entity\User;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
class UserTest extends TestCase class UserTest extends TestCase
{ {
const PASSWORD = '12345678'; const PASSWORD = '12345678';
const USERNAME = 'tester'; const USERNAME = 'tester';
/** /**
*
* @var User * @var User
*/ */
protected $user; protected $user;
public function setUp():void{ public function setUp(): void
{
$this->user = new User(); $this->user = new User();
$this->user->setPassword(self::PASSWORD); $this->user->setPassword(self::PASSWORD);
$this->user->setUsername(' '.self::USERNAME.' '); $this->user->setUsername(' '.self::USERNAME.' ');
} }
public function testUsername():void{ public function testUsername(): void
$this->assertEquals(self::USERNAME,$this->user->getUsername()); {
$this->assertEquals(self::USERNAME, $this->user->getUsername());
} }
public function testPassword():void{ public function testPassword(): void
$this->assertEquals(self::PASSWORD,$this->user->getPassword()); {
$this->assertEquals(self::PASSWORD, $this->user->getPassword());
} }
} }