Skip to content

Instantly share code, notes, and snippets.

@adamcameron
Created December 24, 2013 09:44
Show Gist options
  • Save adamcameron/8110951 to your computer and use it in GitHub Desktop.
Save adamcameron/8110951 to your computer and use it in GitHub Desktop.
Demonstrating issue with makePublic()
// Application.cfc
component {
this.mappings = {
"/testbox" = expandPath("/frameworks/testbox/"),
"/mxunit" = expandPath("/frameworks/testbox/system/testing/compat"),
"/unittests" = expandPath("/shared/git/blogExamples/unittests")
};
}
// somepackage/ComponentInDifferentPackage.cfc
component {
package string function aPackageMethod(){
return "test for this value";
}
}
<!--- runTests.cfm --->
<cfoutput>
#createObject("mxunit.runner.DirectoryTestSuite").run(
directory = getDirectoryFromPath(getCurrentTemplatePath()),
componentPath = "unittests.testbox.makepublic",
recurse = false
).getResultsOutput("simple")#
</cfoutput>
// TestMakePublic.cfc
component extends="mxunit.framework.TestCase" {
public void function testMakePublic(){
variables.test = new somepackage.ComponentInDifferentPackage();
makepublic(variables.test, "aPackageMethod");
assertEquals("test for this value", variables.test.aPackageMethod());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment