[TYPO3-mvc] PHPUnit & PHPStorm & Extbase
Jochen Rau
jochen.rau at typoplanet.de
Thu Mar 1 17:27:36 CET 2012
Hi Henjo,
I recently started to backport the FLOW3 UnitTestBootstrap. Unfortunately it's not
finished, yet. Hope it helps anyway.
Karsten describes the PHPStorm settings in his blog post.
Best
Jochen
diff --git a/Tests/Unit/MVC/Web/Routing/UriBuilderTest.php b/Tests/Unit/MVC/Web/Routing/UriBuilderTest.php
index 732fb3b..3cd8522 100644
--- a/Tests/Unit/MVC/Web/Routing/UriBuilderTest.php
+++ b/Tests/Unit/MVC/Web/Routing/UriBuilderTest.php
@@ -25,8 +25,6 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
-require_once (t3lib_extMgm::extPath('extbase') . 'Tests/Unit/Fixtures/Entity.php');
-
class Tx_Extbase_Tests_Unit_MVC_Web_Routing_UriBuilderTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
/**
diff --git a/Tests/Unit/Persistence/SessionTest.php b/Tests/Unit/Persistence/SessionTest.php
index 8c5f217..546ba5f 100644
--- a/Tests/Unit/Persistence/SessionTest.php
+++ b/Tests/Unit/Persistence/SessionTest.php
@@ -25,7 +25,7 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
-class Tx_Extbase_Tests_Unit_Persistence_SessionTest extends tx_phpunit_testcase {
+class Tx_Extbase_Tests_Unit_Persistence_SessionTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
/**
* @test
diff --git a/Tests/Unit/UnitTestBootstrap.php b/Tests/Unit/UnitTestBootstrap.php
new file mode 100644
index 0000000..d6f1e05
--- /dev/null
+++ b/Tests/Unit/UnitTestBootstrap.php
@@ -0,0 +1,47 @@
+<?php
+
+define('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
+define('TYPO3_MODE','FE');
+
+define('PATH_thisScript', getcwd() . '/');
+define('PATH_site', getcwd() . '/');
+define('PATH_t3lib', PATH_site . 't3lib/');
+define('TYPO3_mainDir', 'typo3/');
+define('PATH_typo3', PATH_site . TYPO3_mainDir);
+define('PATH_typo3conf', PATH_site . 'typo3conf/');
+define('PATH_tslib', PATH_site.TYPO3_mainDir.'sysext/cms/tslib/');
+
+
+require_once(PATH_t3lib . 'class.t3lib_div.php');
+require_once(PATH_t3lib . 'class.t3lib_extmgm.php');
+require_once(PATH_t3lib . 'interfaces/interface.t3lib_singleton.php');
+
+
+require(PATH_t3lib . 'config_default.php');
+
+/*
+function autoload($className) {
+ $classNameParts = explode('_', $className, 3);
+ if (isset($classNameParts[2])) {
+ $classFilePathAndName = t3lib_extMgm::extPath('extbase') . 'Classes/' . strtr($classNameParts[2], '_', '/') . '.php';
+ try {
+ if (file_exists($classFilePathAndName)) {
+ require_once($classFilePathAndName);
+ } else {
+ $classFilePathAndName = t3lib_extMgm::extPath('extbase') . strtr($classNameParts[2], '_', '/') . '.php';
+ if (file_exists($classFilePathAndName)) {
+ require_once($classFilePathAndName);
+ }
+ }
+
+ } catch (BadFunctionCallException $exception) {
+ // Catch the exception and do nothing to give
+ // other registered autoloaders a chance to find the file
+ }
+ }
+}
+
+spl_autoload_register('autoload', TRUE, TRUE);
+*/
+
+?>
\ No newline at end of file
diff --git a/Tests/Unit/UnitTests.xml b/Tests/Unit/UnitTests.xml
new file mode 100644
index 0000000..5fee9c0
--- /dev/null
+++ b/Tests/Unit/UnitTests.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<phpunit strict="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true">
+ <testsuites>
+ <testsuite name="All Tests">
+ <directory>../Unit</directory>
+ </testsuite>
+ </testsuites>
+</phpunit>
diff --git a/Tests/Unit/Utility/ExtensionTest.php b/Tests/Unit/Utility/ExtensionTest.php
index b753a3e..e7119cc 100644
--- a/Tests/Unit/Utility/ExtensionTest.php
+++ b/Tests/Unit/Utility/ExtensionTest.php
@@ -28,7 +28,7 @@
* @package Extbase
* @subpackage extbase
*/
-class Tx_Extbase_Tests_Unit_Utility_ExtensionTest extends tx_phpunit_testcase {
+class Tx_Extbase_Tests_Unit_Utility_ExtensionTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
/**
* Contains backup of $TYPO3_CONF_VARS
On 2012-03-01, Henjo Hoeksma <me at henjohoeksma.nl> wrote:
> Hi list,
>
> I would like to make the switch from running unit tests from inside a TYPO3
> installation to running them from within PhpStorm.
>
> I found several resources on achieving this:
>
> [1] This suggests a full typo3 setup (tested, and works but not completely
> the way I like - see below)
> [2] This is for use in FLOW3 applications (not tested, seen in action and
> would like something like this for Extbase extensions)
>
> I have my projects mostly not directly attached in a full TYPO3 system,
> that is not where I am working from. After a commit that I make I sync it
> to my local development instance. I would like to run the tests before my
> commit though.
>
> Any suggestions on how to set this up like [2] but working for standalone
> extbase extensions? Or should I really go back to working from within my
> local development sites?
>
> [1]
> http://wiki.typo3.org/Using_the_PHPUnit_extension_for_TYPO3_v4_in_PhpStorm
> [2]
> http://blog.k-fish.de/2011/12/setting-up-phpstorm-for-use-as-flow3_19.html
>
> Thanks in advance for your thoughts! Keeping to improve workflows!
>
> Kind regards,
>
> Henjo
>
> Problems are small because we learned how to deal with them.
> Problems are big because we need to learn how to deal with them.
--
Every nit picked is a bug fixed
More information about the TYPO3-project-typo3v4mvc
mailing list