TASK: First example test and setup

This commit is contained in:
Daniel Siepmann 2018-06-20 21:10:52 +02:00
parent d281851d6d
commit ad85bb0444
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
5 changed files with 158 additions and 0 deletions

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
composer.lock
vendor
index.php
typo3
Tests

View file

@ -0,0 +1,38 @@
<?php
namespace Codappix\TestingTalk\Controller;
/*
* Copyright (C) 2018 Daniel Siepmann <coding@daniel-siepmann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use TYPO3\CMS\Extbase\Domain\Model\FrontendUser;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
/**
* Lists and enables editing of frontend users.
*/
class FrontendUserController extends ActionController
{
/**
* @param FrontendUser $frontendUser
*/
public function showAction(FrontendUser $frontendUser)
{
$this->view->assign('frontendUser', $frontendUser);
}
}

View file

@ -0,0 +1,45 @@
<?php
namespace Codappix\TestingTalk\Domain\Model;
/*
* Copyright (C) 2018 Daniel Siepmann <coding@daniel-siepmann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use TYPO3\CMS\Extbase\DomainObject\AbstractValueObject;
class Address extends AbstractValueObject
{
protected $street = '';
protected $houseNumber = '';
public function __construct(string $street, string $houseNumber)
{
$this->street = trim($street);
$this->houseNumber = trim($houseNumber);
}
public function getStreet() : string
{
return $this->street;
}
public function getHouseNumber() : string
{
return $this->houseNumber;
}
}

25
composer.json Normal file
View file

@ -0,0 +1,25 @@
{
"name": "codappix/testing_talk",
"description": "Example Extension to show testing",
"type": "typo3-cms-extension",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "Daniel Siepmann",
"email": "coding@daniel-siepmann.de"
}
],
"autoload": {
"psr-4": {
"Codappix\\TestingTalk\\": "Classes/"
}
},
"require": {
"typo3/cms-core": "^8.7"
},
"extra": {
"typo3/cms": {
"web-dir": "web"
}
}
}

45
readme.rst Normal file
View file

@ -0,0 +1,45 @@
Testing Talk
============
Clean everything::
rm -rf composer.lock vendor web Tests
Install dependencies
--------------------
Using composer::
composer install
PHPUnit Installation
--------------------
Install phpunit::
composer require --dev phpunit/phpunit ^6.5
Why 6.x? We use 6.x to support PHP 7.0.
Check installation::
./vendor/bin/phpunit --version
Links:
* https://phpunit.de/
* https://packagist.org/packages/phpunit/phpunit
Create first test
-----------------
We want to test the controller first::
mkdir -p Tests/Unit/Domain/Model
cp Resources/Private/CodeExamples/Tests/Unit/Domain/Model/AddressTest.php \
Tests/Unit/Domain/Model/AddressTest.php
Execute first test::
./vendor/bin/phpunit Tests/Unit/