Skip to content

Instantly share code, notes, and snippets.

@roryl
Last active April 22, 2016 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roryl/2a50bde54f70683747f0353926d49179 to your computer and use it in GitHub Desktop.
Save roryl/2a50bde54f70683747f0353926d49179 to your computer and use it in GitHub Desktop.
Lucee Mixin Examples
component {
include template="mixin.cfm";
this.lastFunc = new mixinComponent().lastFunc;
variables.lastFunc = new mixinComponent().lastFunc;
}
component {
function init(){
//Do something on instantiation
return this;
}
}
component {
include template="mixin.cfm"
function init(){
//Do something on instantiation
return this;
}
}
interface {
public function myOtherFunc(required array myArray){
}
public function thirdFunc(required string myString){
}
}
interface {
public function lastFunc(required array myArray){
}
}
component extends="baseComponent" implements="IMixin"{
function init(){
//Do something on instantiation
return this;
}
function myFunc(){
}
}
component {
mixinComponent = new mixinComponent();
this.fourthFunc = mixinComponent.fourthFunc;
variables.fourthFunc = mixinComponent.fourthFunc;
this.fifthFunc = mixinComponent.fifthFunc;
variables.fifthFunc = mixinComponent.fifthFunc;
function init(){
//Do something on instantiation
return this;
}
}
<cfscript>
function myOtherFunc(required array myArray){
}
function thirdFunc(required string myString){
}
</cfscript>
<cfscript>
public function lastFunc(required array myArray){
}
</cfscript>
component {
function fourthFunc(){
}
function fifthFunc(){
}
public function lastFunc(required array myArray){
}
}
/**
* My xUnit Test
*/
component extends="testbox.system.BaseSpec"{
/*********************************** LIFE CYCLE Methods ***********************************/
// executes before all test cases
function beforeTests(){
}
// executes after all test cases
function afterTests(){
}
// executes before every test case
function setup( currentMethod ){
}
// executes after every test case
function teardown( currentMethod ){
}
/*********************************** TEST CASES BELOW ***********************************/
// Remember that test cases MUST start or end with the keyword 'test'
function mixingTest(){
myObj = new implementsComponent();
writeDump(getMetaData(myObj));
}
// Remember that test cases MUST start or end with the keyword 'test'
function basicComponentTest(){
myObj = new basicComponent();
writeDump(myObj);
}
// Remember that test cases MUST start or end with the keyword 'test'
function basicMixinTest(){
myObj = new basicMixin();
writeDump(myObj);
}
// Remember that test cases MUST start or end with the keyword 'test'
function liftTest(){
myObj = new liftComponent();
writeDump(myObj);
}
// Remember that test cases MUST start or end with the keyword 'test'
function interfaceTest(){
myObj = new implementsComponent();
writeDump(myObj);
writeDump(getMetaData(myObj));
}
}
component {
function universalFunctionality(){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment