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.
Related
I have gotten all the latest jars installed for the Wicket 6.15. I can verify this in the Maven Dependencies directory.
For some reason, I feel it is still pointing to an older version of Wicket. I am getting strange errors with the add method from the MarkupContainer.
Using the quick-start example, in the HomePage class I am getting an error with:
add(new Label("message", "If you see this message wicket is properly configured and running"));
The error is:
The method add(Component[]) in the type MarkupContainer is not applicable for the arguments (Label)
Not sure why it is using Component[] as a argument and not Component... childs
as I am used to.
I am using Eclipse.
Check your import statements. You probably accidentally imported a different Label instead of org.apache.wicket.markup.html.basic.Label.
I've noticed something interesting about Zend Framework's bootstrap. I created a new project and then used
zf enable layout
to enable the layout engine. It worked out of the box, woo!
But then I tried creating a function called _initLayout in the bootstrap to set some options. Interestingly, this seems to disable the layout again, even if the function body is actually empty. No errors are thrown, but the layout script is not used anymore (exception being the case when I actually set the options again and manually call Zend_Layout::startMvc()).
Renaming the function to anything else, like _initFoo makes the layout work again.
So, my question is: is this a function name that is somehow recognised by Zend Framework and extra actions are applied to it, such as cancelling the layout config from application.ini? Are there other cases where I should avoid certain _init* function names in the bootstrap?
The main purpose of the Bootstrap is to setup resources that the application uses. These can either be setup by lines in the config file (resources.resourcename.foo) or by methods in the bootstrap class (_initResourceName()). I assume zf enable layout has added some resources.layout.* lines to the application.ini. By adding an _initLayout method to the bootstrap, ZF will use this to setup the layout resource instead of the configuration lines.
Are there other cases where I should avoid certain _init* function names in the bootstrap?
The resource plugins are detailed in the manual: http://framework.zend.com/manual/en/zend.application.available-resources.html, _init<resourcename>() will always override any corresponding lines in the config.
I've set up a YADIF (Yet Another Dependency Injection Framework) to handle most application dependencies in a Zend framework app - one problem,it kills auto-complete.
Has anyone else had this problem? My general solution is to use YADIF for re-usable library classes, but use "new" for application work (i.e. in controllers or items that extend ZF, since I don't want to go to the trouble of stubbing out Zend in my Unit Tests)
I just found the answer(s) to this inadvertently, so I've added it on behalf of anyone else who encounters this issue:
This solves auto-complete issues for method scope - but doesn't seem to work for class level variables (i.e. variables preceded by $this):
netbeans autocompletion when using singleton to retrieve object instead of new operator?
to set up autocomplete for class instance variables, use #property:
http://www.edmondscommerce.co.uk/netbeans/netbeans-autocomplete-on-class-properties-using-phpdoc/
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.
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.