phpspec tests within zend 2 module - zend-framework2

I'm trying to move my spec folder into a zend 2 module folder. I don't totally understand how phpspec determines where the source folder is. How can I configure it to use the below folder structure.
\ModuleName
\spec
\ModuleName
\Class.php
\src
\ModuleName
ClassSpec.php
...
...

You can configure spec and src paths, see the docs:
http://phpspec.net/en/latest/cookbook/configuration.html
If that doesn't solve your issue, you'll need to write a phpspec extension and provide a custom resource locator. Here's a similar example for Symfony:
https://github.com/phpspec/Symfony2Extension/blob/master/src/PhpSpec/Symfony2Extension/Locator/PSR0Locator.php

Related

F# Embedded resource is ignoring subfolder structure

I am trying to embed resources (.xsd) to my project. The folder structure is as follows
- Project
project.fsproj
- subfolder
- v1
file.xsd
- v2
file.xsd
This file is embedded as a recourse and I would expect that I can access the files as follows {Namespace}.subfolder.v1.file.xsd and replace v1 with v2 if I want to load v2. However, my resources are being embedded without any reference to namespace or folder structure. When I call GetManifestResourceNames() it tells me that there is only one file
file.xsd
If I change v2/file.xsd -> v2/file2.xsd output for GetManifestResourceNames is
file.xsd
file2.xsd
What I expected the names would be
{Namespace}.v1.file.xsd
{Namespace}.v2.file.xsd
Project is part of a much larger solution that may be causing this in its build process. I can't reproduce the behaviour with an isolated project. But I am not sure where to start looking.

Aurelia compose viewmodel paths

I have components that has dynamic parts with compose. The dynamic parts are in other modules i.e. node projects.
If I want to use a custom element in a page like:
<my-custom-element body.bind="someVariableContainingThePath"></my-custom-element>
I get an error saying that the viewmodel specified in someVariableContainingThePath cannot be found in ./my-custom-element/someVariableContainingThePath.
What is the recommended way to deal with paths when using compose element.
I'm using webpack.
Is there a way to alias a module.
So can set someVariableContainingThePath='moduleA' and then specify
that moduleA = /some/path/my-body-custom-element ?
For webpack bundling you have to give it a hint. Otherwise your view will not get bundled.
you can add your component to globalResourses when configuring aurelia
http://aurelia.io/docs/fundamentals/app-configuration-and-startup#making-resources-global
You have to decorate your module names with PLATFORM.modulename as in .globalResources(PLATFORM.modulename('my-module'))

bean-validation validation.xml ignored

I am using JSR 303 Bean validation in my JSF 2.0 web application and it works fine with annotations. Now I would like to ignore annotations and configure validation rules using the validation.xml file, so this is what I did (I am using an eclipse dynamic web project) :
Added validation.xml under WebContent/META-INF/validation.xml
<?xml version="1.0" encoding="UTF-8"?>
<validation-config
xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
>
<constraint-mapping>META-INF/validation/constraint-mapping.xml</constraint-mapping>
</validation-config>
Then created the file constraint-mapping.xml under WebContent/META-INF/validation/constraint-mapping.xml
<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
<bean class="my.full.path.ValidationMB" ignore-annotations="true">
</bean>
</constraint-mappings>
Having these configurations in place, I suppose the annotations in my bean class ValidationMB shall be ignored, BUT this is not happening!, which makes me assume that the validation.xml file is not being loaded.
any ideas? thanks.
Environment:
Apache Tomcat 7.0.23
javax.faces-2.1.4.jar
hibernate-validator-4.2.0.Final.jar
hibernate-validator-annotation-processor-4.2.0.Final.jar
validation-api-1.0.0.GA.jar
slf4j-api-1.6.1.jar
From the spec: section 4.4.6. XML Configuration: META-INF/validation.xml
Unless explicitly ignored by calling
Configuration.ignoreXMLConfiguration(), a Configuration takes into
account the configuration available in META-INF/validation.xml. This
configuration file is optional but can be used by applications to
refine some of the Bean Validation behavior. If more than one
META-INF/validation.xml file is found in the classpath, a
ValidationException is raised.
To solve my problem I had to create a META-INF folder under the project src folder, which ends in the WEB-INF/classes/META-INF.
The structure of the web application is:
ROOT
|_META-INF -- don't put validation.xml here
|_WEB-INF
|__ classes
|_META-INF
|__validation.xml
But I think that if I pack my web application in a jar file and reuse it in another project It may not work, I will let you know later once I do it.
Try to put your validation.xml directly into the WEB-INF/ directory.
I stumbled across this while looking for something else but wanted to clarify to the OP what is happening. You do in fact need the file to exist at META-INF/validation.xml; however, that is relative to the classpath which is why it worked when you put it under WEB-INF/classes/META-INF/validation.xml.
The cleaner approach is to let the file be put there for you. Your Eclipse project should already be outputting whatever is in your source directory to WEB-INF/classes somehow for you or nothing would be running. But sometimes there are filters on what it outputs so it might excluding something. You might want to check your src dirs and make sure they don't have exclusions.
Just as an example, if you had a Maven war project, all of your java sources would go in src/main/java and the generated classes would end up in the WEB-INF/classes directory. The equivalent happens for src/main/resources which contains non-source files. When I want *.xml, *.properties, etc. to end up in WEB-INF/classes I put them in src/main/resources. For your example I would have a src/main/resources/META-INF/validation.xml file.
Hope this helps anyone else who comes across this and is confused.

How to include multiple php libraries in Symfony?

so, I have some php files in my apps/myprogram/lib folder. e.g. apps/myprogram/lib/myLibA.class.php
When I run in my modules/actions/ scripts, and try to use the functions in myLibA, I cannot. because symfony complains that the myLibA class is not defined.
do I need to specify anywhere in the symfony framework that myLibA.class.php is a required library?
Symfony's autoloader looks by default for your classes in the top-level <project>/lib directory. Any file in that directory or below (with the exception of "vendor") will be searched for classes. Symfony searches for any .php file with class declarations and adds them to the autoload system.
Additionally, you can add search paths in your application's autoload.yml file. For example, for one of my applications I've put a third-party Flickr library in <project>/vendor/phpFlickr, and my <project>/apps/frontend/config/autoload.yml file looks like:
autoload:
vendor_php_flickr:
path: %SF_LIB_DIR%/vendor/phpFlickr
recursive: on
That allows all classes below .../vendor/phpFlickr to be autoloaded.
this is an alternative way, you can define/add to your preExecute this:
public function preExecute()
{
$this->getContext()->getConfiguration()->loadHelpers('Foo', 'Bar');
}
taken from (http://oldforum.symfony-project.org/index.php/m/92916/)

StructureMap scan assemblies from every folder within a given directory

I have a mvc project and in the bin folder i have an plugin folder and it look like this
/bin/
/plugin
/plugin1
/plugin2
and i what to scan with structure map every assembly in plugin folder
i've try with AssembliesFromPath but is not loading any assembly.
How can i load all the assembly from every directory within plugin folder ?
StructureMap doesn't recursively search a path, so you just need to call AssembliesFromPath on each of the paths that contain your plugins (ex: bin\plugin\plugin1, bin\plugin\plugin2).
Of course you don't need to hardcode in all of the subdirectories. StructureMap registration code is c#, which means you can use the language constructs. Call Directory.GetDirectories() on your bin\plugin to get the list of subdirectories, and then just loop over them within your Scan() clause to call AssembliesFromPath on each subdirectory.

Resources