Zend Framework 1.11.2
PHPUnit 3.5.10
PHP 5.3.1
NetBeans 6.9.1
http://pastebin.com/L5bi9AgY
I followed Lebensold's tutorial.
Testing works, even with things like
$this->dispatch('/');
$this->assertResponseCode(200);
, but as soon as I require a controller class (pastebin, #33) to instantiate it in the setUp() method, I get an error saying that PHPUnit didn't find the parent class (Zend_Controller_Action). So my guess is that I've somehow missed something in bootstrap, because I don't get all the classes loaded (?).
Also, when using the "#covers Class::method" annotation, I get the same type of error.
Any suggestions are welcomed. Thanks.
Try requiring the controller class from within your setup, e.g.
class SearchControllerTest extends ControllerTestCase {
public function setUp() {
parent::setUp();
require_once(APPLICATION_PATH . '/controllers/SearchController.php');
}
}
I remember having similar problem and it worked this way.
Related
I am currently trying to write a Hook to add extra fields to a Flexform. Therefore I followed this tutorial: https://docs.typo3.org/typo3cms/extensions/news/DeveloperManual/ExtendNews/ExtendFlexforms/Index.html?fref=gc&dti=250938618364487#extend-flexforms-with-custom-fields
But when I go to a page in the backend that contains an options from a Flexform I get the following Error:
Class 'ID\SearchBarAdditional\Hooks\FlexFormHook' not found.
I register the Hook in the ext_localconf like this:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::class]['flexParsing'][] = \ID\SearchBarAdditional\Hooks\FlexFormHook::class;
and my Hook-file is here: typo3conf/ext/search_bar_additional/Classes/Hooks
and is initialized that way:
namespace ID\SearchBarAdditional\Hooks;
class FlexFormHook { /* ... */
So in my opinion everything is in the right place and should work, but I do still get the error that TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance("ID\SearchBarAdditional\Hooks\FlexFormHook") fails.
Do you guys have any ideas, what could be wrong? Do I have to register the Hook in \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( or something similar (as the posted code is really the only thing I've done)?
This is a typical class loading error. Check that you added your PHP namespaces to composer autoloading and/or ext_emconf.php and make sure your filenames are correctly named according to PSR-4. If in doubt you can inspect the class loading map files generated by composer in vendor/composer (if you use composer for class loading, which you definitely should do).
I found the mistake: My Hook does indeed not get loaded. I tried to 'include' it in the ext_localconf.php and it is working now.
But as this is of course an extremely ugly solution I posted a second question, how to load a hook here: Typo3 8.X - autoload Hook
Thank you for your help!!!
I use HTML file for my welcome page. I want to open Eclipse Wizard from intro page using
href="http://org.eclipse.ui.intro/runAction?pluginId=MobileTalk&class=mobiletalk.intro.ShowPerspectiveIntroAction"
In the class ShowPerspectiveIntroAction, my code as follows:
Class c = Class.forName("tttt.ddt.plugin.project.NewTtttProjectWizard");
Wizard wizard = (Wizard) c.newInstance();
WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),wizard);
dialog.open();
But I get the error: classnotfound:tttt.ddt.plugin.project.NewTtttProjectWizard
how can I open any Eclipse Wizard from intro page correctly?
From looking at your code I suspect it is a class loader issue. Using Class.forName is not a safe practice in Eclipse/OSGI because each plugin/bundle uses their own class loader and as a result a lot of times Class Not Found Exceptions happen. A better approach is to get the Bundle/Plugin that contains your wizard class by doing this: Platform.getBundle("com.stackoverflow.myplugindId"), that returns an instance of Bundle. Then on the instance of bundle call the .loadClass("tttt.ddt.plugin.project.NewTtttProjectWizard") which will use the correct class loader and then once you have an instance of the Class you can call the newInstance() method which will resolve your Class not found issue. Hope that helps, class loading is more complex in an OSGI environment because every plugin has its own class loader for security reasons so I advise against using Class.forName in your code. - Duncan
I am using Zend FW 1 and PHPUnit 3.5.15.
In a parent class I am declaring public static function _doInsert(DomainObject $object) and I am overriding this in a child class.
The only difference in the method signature of the child class is that it hints for an object that is more specific than DomainObject, something like DomainObjectChild. This seems to work fine as far as my application goes, however PHPUnit chokes with an error. It says that the declaration of the method in the child class should be compatible with that of the parent.
Any ideas, my bright friends?
This is an E_STRICT level warning that is coming from PHP, not PHPUnit. Check your error_reporting settings for the CLI version of PHP (which usually has a seperate php.ini file) or any PHP settings being overridden in your PHPUnit configuration.
You can either fix the problem in your code to remove the warning, or change the error_reporting level that PHPUnit is using.
Using AutoFac 2.3.2, I am trying to do the following:
var builder = new Autofac.ContainerBuilder();
builder.RegisterType<SomeDependency>().As<IDependency>();
RegisterType is not there. Not seeing it with intellisense, compiler doesn't know it's there. Looking in the help shows that the RegisterType method is an extension method. Is there something I'm missing? Why is this extension method not showing up?
I'm using VS2010, attempting the above code in a test project and a web application project.
You need to use use Autofac or use the static method directly.
use Autofac;
namespace X
{
builder.RegisterType<MyType>();
}
or
Autofac.RegistrationExtensions.RegisterType<MyType>(builder);
I was following an example found here on StackOverflow, and everything went well until I need to register my types.
My web application is running on Silverlight 4, with Prism and MVVM.
The example is using "Microsoft.Practices.Unity" (it's a windows form application)
Bootstrapper.cs
protected override void ConfigureContainer()
{
base.ConfigureContainer();
Container.RegisterType<IApplicationMenuRegistry, MenuRegistry>();
Container.RegisterType<IApplicationCommands, ApplicationCommands>();
Container.RegisterType<ShellViewModel, ShellViewModel>(new Microsoft.Practices.Unity.ContainerControlledLifetimeManager());
}
Mine is using: Microsoft.Practices.Unity.Silverlight (web) and throws the following error:
The non-generic method 'Microsoft.Practices.Unity.IUnityContainer.RegisterType(...) cannot be used with type arguments.
And the RegisterType<> constructor is not visible for me. Which alternatives do I have to register my types?
I am using Unity for Silverlight and have not had this issue.
According to this post, http://unity.codeplex.com/workitem/8205, you need to add "using Microsoft.Practices.Unity;" to the file. The generic versions of Resolve are extension methods and you need to pull in the namespace to use them.
Apparently ReSharper may think the using statement is not needed and may remove it.
Hope that helps.