text:
require 'pearson/version'
require 'rubygems'
require 'json'
require 'httparty'
require 'pp'
require 'active_support/core_ext/object/to_query'

module Pearson
  module Base
    # specify a data set to work in
    def set_data_sets(*args)
      comp = *args.join(",").delete(" ")
      @data_sets = comp * ","
    end

    def get_by_id(id)
      if @api_key.nil?
        response = self.class.get("/#{@api}/#{@endpoint}/#{id}")
      else
        response = self.class.get("/#{@api}/#{@endpoint}/#{id}?api_key=#{@api_key}")
      end
      response.parsed_response
    end

    def expand_url(url)
      prepend = "http://api.pearson.com"
      if @api_key.nil?
        prepend + url
      else
        prepend + url + "?apikey=" + @api_key
      end
    end

    def clean_hash(hash)
      hash.delete_if do |key, val|
        if block_given?
          yield(key, val)
        else
          val.nil? || val == 0 || !val || (val.respond_to?('empty?') && val.empty?) || (val.is_a?(String) && val.strip.empty?)
        end
      end

      hash.each do |key, val|
        if hash[key].is_a?(Hash)
          if block_given?
            hash[key] = clean_hash(hash[key], &Proc.new)
          else
            hash[key] = clean_hash(hash[key])
          end
        end
      end

      hash
    end

    def search(search_obj={})
      key = {api_key: "#{@api_key}", offset: 0, limit: 10}
      queries = clean_hash(key.merge(search_obj)).to_query

      if defined?(@data_sets)
        self.class.get("/#{@api}/#{@data_sets}/#{@endpoint}?#{queries}").parsed_response
      else
        self.class.get("/#{@api}/#{@endpoint}?#{queries}").parsed_response
      end
    end
  end

  class Travel
    include Base
    include HTTParty

    format :json
    base_uri 'http://api.pearson.com/v2'

    def initialize(api_key=nil)
      @api_key = api_key
      @api = "travel"
    end

    def topten
      @endpoint = "topten"
      self
    end

    def streetsmart
      @endpoint = "streetsmart"
      self
    end

    def aroundtown
      @endpoint = "around_town"
      self
    end

    def places
      @endpoint = "places"
      self
    end

    def datasets
      @endpoint = "datasets"
      self
    end

    def categories
      @endpoint = "categories"
      self
    end
  end

  class FoodAndDrink
    include Base
    include HTTParty

    format :json
    base_uri 'http://api.pearson.com/v2'

    def initialize(api_key=nil)
      @api_key = api_key
      @api = "foodanddrink"
    end

    def recipes
      @endpoint = "recipes"
      self
    end
  end

  class FTArticles
    include Base
    include HTTParty

    format :json
    base_uri 'http://api.pearson.com/v2'

    def initialize(api_key=nil)
      @api_key = api_key
      @api = "ft"
    end

    def articles
      @endpoint = "articles"
      self
    end
  end

  class Dictionaries
    include Base
    include HTTParty

    format :json
    base_uri 'http://api.pearson.com/v2'

    def initialize(api_key=nil)
      @api_key = api_key
      @api = "dictionaries"
    end

    def entries
      @endpoint = "entries"
      self
    end
  end

  class PenguinClassics
    include Base
    include HTTParty

    format :json
    base_uri 'http://api.pearson.com/'

    def initialize(api_key=nil)
      @api_key = api_key
      @api = "penguin/classics/v1"
    end

    def books
      @endpoint = "books"
      self
    end

    def articles
      @endpoint = "articles"
      self
    end

    def authors
      @endpoint = "authors"
      self
    end
  end
end


text:
import * as actions from '../constants/actionTypes';

export const lockSignInDialog = () => {
  return {
    type: actions.LOCK_SIGN_IN_DIALOG,
  };
};

export const unlockSignInDialog = () => {
  return {
    type: actions.UNLOCK_SIGN_IN_DIALOG,
  };
};

export const resetSignInDialog = values => {
  let action = { type: actions.RESET_SIGN_IN_DIALOG };
  if (values)
    action.values = values;
  return action;
};

export const showSignInDialog = () => {
  return async (dispatch, getState) => {
    let signInDialog = getState().get('signInDialog');
    if (signInDialog.get('locked'))
      return;

    await dispatch(resetSignInDialog());

    return dispatch({
      type: actions.SHOW_SIGN_IN_DIALOG,
    });
  };
};

export const hideSignInDialog = () => {
  return async (dispatch, getState) => {
    let signInDialog = getState().get('signInDialog');
    if (signInDialog.get('locked'))
      return;

    await dispatch(resetSignInDialog());

    return dispatch({
      type: actions.HIDE_SIGN_IN_DIALOG,
    });
  };
};

export const toggleSignInDialog = () => {
  return async (dispatch, getState) => {
    let signInDialog = getState().get('signInDialog');
    if (signInDialog.get('locked'))
      return;

    return dispatch(signInDialog.get('isOpen') ? hideSignInDialog() : showSignInDialog());
  };
};

export const submitSignInDialog = submittedAt => {
  return {
    type: actions.SUBMIT_SIGN_IN_DIALOG,
    submittedAt: submittedAt || Date.now(),
  };
};

export const updateSignInDialog = (data, submittedAt) => {
  return {
    type: actions.UPDATE_SIGN_IN_DIALOG,
    submittedAt: submittedAt || Date.now(),
    data
  };
};

redpajama_set_name: RedPajamaGithub


text:
package ws.l10n.portal.ui.mvc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import ws.l10n.portal.domain.MessageBundle;
import ws.l10n.portal.domain.Permission;
import ws.l10n.portal.domain.PortalUser;
import ws.l10n.portal.repository.BundleRepository;
import ws.l10n.portal.repository.LocaleRepository;
import ws.l10n.portal.repository.ProjectRepository;
import ws.l10n.portal.service.BundleService;
import ws.l10n.portal.service.ProjectService;
import ws.l10n.portal.ui.security.PortalSecurity;

/**
 * @author Sergey Boguckiy
 */
@Controller
@RequestMapping("/bundle")
public class BundleController {

    @Autowired
    private BundleService bundleService;
    @Autowired
    private ProjectRepository projectRepository;
    @Autowired
    private ProjectService projectService;
    @Autowired
    private BundleRepository bundleRepository;
    @Autowired
    private LocaleRepository localeRepository;

    @RequestMapping(method = RequestMethod.GET)
    @PreAuthorize("isAuthenticated() and @permissionChecker.canReadProject(#projectId)")
    public String projectBundles(@RequestParam("p") Integer projectId, ModelMap map) {
        map.put("project", projectRepository.getProjectViewByProjectId(projectId));
        return "project_bundles";
    }

    @RequestMapping(value = "/create", params = "p", method = RequestMethod.GET)
    @PreAuthorize("isAuthenticated() and @permissionChecker.canWriteProject(#projectId)")
    public String createBundleView(@RequestParam(value = "p") Integer projectId, ModelMap map) {
        map.put("locales", localeRepository.getLocaleViews());
        map.put("project", projectRepository.get(projectId));
        return "create_project_bundle";
    }

    @RequestMapping(value = "/create", method = RequestMethod.GET)
    @PreAuthorize("isAuthenticated()")
    public String createBundleView(ModelMap map) {
        PortalUser currentUser = PortalSecurity.currentUser();

        map.put("locales", localeRepository.getLocaleViews());

        map.put("projects", projectService.listByOwnerIdAndPermissions(currentUser.getId(), Permission.WRITE));
        return "create_bundle";

    }

    @RequestMapping(value = "/create", params = "projectId", method = RequestMethod.POST)
    @PreAuthorize("isAuthenticated() and @permissionChecker.canWriteProject(#projectId)")
    public String createBundleForProjectId(@RequestParam("projectId") Integer projectId,
                                           @RequestParam("label") String label,
                                           @RequestParam("defaultLocaleId") String defaultLocaleId,
                                           @RequestParam("version") String version) {
        bundleService.create(projectId, label, version, defaultLocaleId, PortalSecurity.currentUser().getId());
        return "redirect:/bundle?p=" + projectId;
    }

    @RequestMapping(value = "/create", method = RequestMethod.POST)
    @PreAuthorize("isAuthenticated()")
    public String createBundleByProjectIdOrName(
            @RequestParam("projectIdOrName") String projectIdOrName,
            @RequestParam("label") String label,
            @RequestParam("defaultLocaleId") String defaultLocaleId,
            @RequestParam("version") String version) {
        bundleService.create(projectIdOrName, projectIdOrName, label, version, defaultLocaleId, PortalSecurity.currentUser().getId());
        return "redirect:/bundle/all";
    }

    @RequestMapping(value = "/edit/{bundleId}", method = RequestMethod.GET)
    @PreAuthorize("isAuthenticated() and @permissionChecker.canWriteBundle(#bundleId)")
    public String editView(@PathVariable("bundleId") Integer bundleId, ModelMap map) {
        MessageBundle messageBundle = bundleRepository.get(bundleId);
        map.put("project", projectRepository.get(messageBundle.getProjectId()));
        map.put("bundle", messageBundle);
        return "create_project_bundle";
    }

    @RequestMapping(value = "/edit/{bundleId}", method = RequestMethod.POST)
    @PreAuthorize("isAuthenticated() and @permissionChecker.canWriteBundle(#bundleId)")
    public String edit(
            @RequestParam("bundleId") Integer bundleId,
            @RequestParam("projectId") Integer projectId,
            @RequestParam("label") String label) {
        bundleService.update(bundleId, label);
        return "redirect:/bundle?p=" + projectId;
    }

    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @PreAuthorize("isAuthenticated() and @permissionChecker.canWriteBundle(#bundleId)")
    @ResponseBody
    public void delete(@RequestParam("bundleId") Integer bundleId) {
        bundleService.delete(bundleId);
    }

    @RequestMapping(value = "/all", method = RequestMethod.GET)
    public String all(ModelMap map) {
        map.put("projects", projectService.allProjectViews(PortalSecurity.currentUser().getId()));
        return "bundle_list";
    }

}


text:
using UnityEngine;
using System.Collections;

public class DialogMenuChar : MonoBehaviour {

	public Canvas panelConfirmDialog;
	public bool dialogOpen;

	// Use this for initialization
	void Start () {
		panelConfirmDialog = GameObject.Find ("Dialog").GetComponent<Canvas> ();
		panelConfirmDialog.enabled = false;
	}

	// Update is called once per frame
	void Update () {

	}

	public void OpenPanel (string arena) {
		if (!dialogOpen) {
			dialogOpen = true;
			panelConfirmDialog.enabled = true;
		}
		else {
			dialogOpen = false;
			panelConfirmDialog.enabled = false;
		}
	}

	public void confirmArena()
	{
		Application.LoadLevel ("arena_selection");
	}

	public void cancel()
	{
		dialogOpen = true;
		OpenPanel ("");
	}
}


text:
"use strict";

const app = require('../../server/app');
const request = require('supertest')(app.listen());
const should = require("should");
const mongoose = require('mongoose');
const	User = mongoose.model('User');
const Logs = mongoose.model('Logs');
const co = require("co");

describe('test/auth/local.test.js',function () {
	//测试需要一篇文章,和这篇文章的评论.
	const mockUsers = [
		'test01' + new Date().getTime() + '@tets.com',
		'test02' + new Date().getTime() + '@tets.com',
		'test03' + new Date().getTime() + '@tets.com'
	];
	before(co.wrap(function *() {
		yield User.create({
			nickname:'测试' + new Date().getTime(),
			email:mockUsers[0],
			password:'test',
			role:'user',
			status:1
		},{
			nickname:'测试' + new Date().getTime(),
			email:mockUsers[1],
			password:'test',
			role:'user',
			status:0
		},{
			nickname:'测试' + new Date().getTime(),
			email:mockUsers[2],
			password:'test',
			role:'user',
			status:2
		})
	}));

	after(co.wrap(function *() {
		yield User.remove({email:{$in:mockUsers}});
		yield Logs.remove();
	}));

	describe('post /auth/local',function () {
		it('should when password error return err',function (done) {
			request.post('/auth/local')
			.send({
				email:mockUsers[0],
				password:'test888'
			})
			.expect(403,done);

		});
		it('should when email error return err',function (done) {
			request.post('/auth/local')
			.send({
				email:'ttttt@ttttt.com',
				password:'test'
			})
			.expect(403,done);
		});
		it('should when status 0 return err',function (done) {
			request.post('/auth/local')
			.send({
				email:mockUsers[1],
				password:'test'
			})
			.expect(403,done);

		});

		it('should when status 2 return err',function (done) {
			request.post('/auth/local')
			.send({
				email:mockUsers[2],
				password:'test'
			})
			.expect(403,done);

		});

		it('should login success return token',function (done) {
			request.post('/auth/local')
			.send({
				email:mockUsers[0],
				password:'test'
			})
			.expect(200)
			.expect('Content-Type', /json/)
			.end(function (err,res) {
				if(err) return done(err);
				res.body.token.should.be.String();
				done();
			});
		});

	});

});


text:
        Key
        Status
        Summary
        Updated

            {{changeLogIssue.issue.displayKey}}
            {{changeLogIssue.issue.displayKey}}

            {{changeLogIssue.issue.status.name}}

            {{changeLogIssue.issue.summary}}

            {{changeLogIssue.issue.updateTime | date: 'mediumDate'}}


text:
package com.eixox.xml;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.Text;

import com.eixox.JetfuelException;
import com.eixox.adapters.Adapter;

/**
 * An Xml adapter that can read from and write to xml text nodes;
 *
 * @author Rodrigo Portela
 *
 * @param <T>
 */
public class XmlTextAdapter<T> implements XmlAdapter<T> {

	/**
	 * The component adapter to parse and format text content;
	 */
	public final Adapter<T> componentAdapter;

	/**
	 * Creates a new simple xml text adapter;
	 *
	 * @param componentAdapter
	 */
	public XmlTextAdapter(Adapter<T> componentAdapter) {
		if (componentAdapter == null)
			throw new JetfuelException("The component adapter cannot be null");
		this.componentAdapter = componentAdapter;

	}

	/**
	 * Parses the text content of the given node as the data type of this component
	 * adapter;
	 */
	public T parse(Node node) {

		StringBuilder builder = new StringBuilder();
		for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling())
			if (child.getNodeType() == Node.TEXT_NODE)
				builder.append(child.getNodeValue());

		return this.componentAdapter.parse(builder.toString());
	}

	/**
	 * Appends the formatted text of the value as a text node to it's parent;
	 */
	public Node format(Object value, Node parent) {
		String txt = this.componentAdapter.formatObject(value);
		if (txt != null && !txt.isEmpty()) {
			Document document = parent.getOwnerDocument();
			Text text = document.createTextNode(txt);
			parent.appendChild(text);
			return text;
		} else {
			return null;
		}
	}

	/**
	 * Gets the data type of this XML adapter.
	 */
	public Class<T> getDataType() {
		return this.componentAdapter.dataType;
	}

}


text:
package.path = "../../?.lua;../?.lua;" .. package.path

local bsp = require "bsp"

local seed = os.time()
local time_running = 0
local edges = {}
local polygon = {
    bsp.new_point(  0,   0),
    bsp.new_point(700,   0),
    bsp.new_point(700, 500),
    bsp.new_point(  0, 500)
}
local condition = bsp.condition.split_by_middle(1000,0.3)

function love.load (arg)
end

function love.update (dt)
    math.randomseed(seed)
    time_running = time_running + dt
    local point_relations = bsp.generate_bsp(polygon,condition,time_running*100)
    edges = bsp.get_edges_from_relations(point_relations)
end

function love.draw ()
    love.graphics.setColor(255,255,255,50)
    love.graphics.rectangle("line",50,50,700,500)
    love.graphics.setColor(255,255,255,255)
    for _,edge in ipairs(edges) do
        love.graphics.line(edge.p1.x+50,edge.p1.y+50,edge.p2.x+50,edge.p2.y+50)
    end

    love.graphics.print(love.timer.getFPS())
end


text:
app.service('appService', ['$http', function($http){
	var s = this;

	s.fetchExcelData = function(){
		return $http.get('/api/getExcelData/1');
	}

    s.getCurrentUser = function(){
        return $http.get('/api/users/current');
    }

    s.getDashboard = function(){
        return $http.get('/dashboard');
    }

    s.getUsers = function(){
        return $http.get('/getUsers');
    }

    s.getTicketById = function(id){
    	return $http.get('/getTicketsById/'+id);
    }

    s.getTickets = function(id){
    	return $http.get('/getTickets');
    }

    s.getVendors = function(id){
    	return $http.get('/getVendors');
    }

    s.sendSms = function(toNumber, msg){
    	return $http.get('/sms?toNumber='+toNumber+'&msg='+msg);
    }

    s.updateUserRole = function(data){
        var result = '/updateUserRole';
        return $http({
            method: 'PUT',
            url: result,
            data: data
        });
    }

    s.assignedTicket = function(data){
        var result = '/assignedTicket';
        return $http({
            method: 'PUT',
            url: result,
            data: data
        });
    }

    s.closeTicket = function(data){
        var result = '/closeTicket';
        return $http({
            method: 'PUT',
            url: result,
            data: data
        });
    }

    s.getAssignedTicketsById = function(id){
    	return $http.get('/getAssignedTicketsById/'+id);
    }

    s.saveTicket = function(data){
        var result = '/saveTicket';
        return $http({
            method: 'POST',
            url: result,
            data: data
        });
    }

}]);


text:
package org.testng;

/**
 * A listener that gets invoked before and after a method is invoked by TestNG. This listener will
 * be invoked for configuration and test methods irrespective of whether they passe/fail or get
 * skipped. This listener invocation can be disabled for SKIPPED tests through one of the below
 * mechanisms:
 *
 *

 *
Command line parameter alwaysRunListeners
 *
Build tool
 *
Via {@code TestNG.alwaysRunListeners(false)}
 *

 */
public interface IInvokedMethodListener extends ITestNGListener {

  default void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
    // not implemented
  }

  default void afterInvocation(IInvokedMethod method, ITestResult testResult) {
    // not implemented
  }

  /**
   * To be implemented if the method needs a handle to contextual information.
   *
   * @param method The invoked method
   * @param testResult The test result
   * @param context The test context
   */
  default void beforeInvocation(
      IInvokedMethod method, ITestResult testResult, ITestContext context) {
    // not implemented
  }

  /**
   * To be implemented if the method needs a handle to contextual information.
   *
   * @param method The invoked method
   * @param testResult The test result
   * @param context The test context
   */
  default void afterInvocation(
      IInvokedMethod method, ITestResult testResult, ITestContext context) {
    // not implemented
  }
}


text:
<?php

/** Zend_Soap_AutoDiscover */
require_once 'Zend/Soap/AutoDiscover.php';

/** Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex */
require_once "Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php";

/** Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence */
require_once "Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php";

/** Include Common TestTypes */
require_once "_files/commontypes.php";

/**
 * Test cases for Zend_Soap_AutoDiscover
 *
 * @category   Zend
 * @package    Zend_Soap
 * @subpackage UnitTests
 * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @group      Zend_Soap
 */
class Zend_Soap_AutoDiscoverTest extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        // This has to be done because some CLI setups don't have $_SERVER variables
        // to simuulate that we have an actual webserver.
        if(!isset($_SERVER) || !is_array($_SERVER)) {
            $_SERVER = array();
        }
        $_SERVER['HTTP_HOST'] = 'localhost';
        $_SERVER['REQUEST_URI'] = '/my_script.php?wsdl';
        $_SERVER['SCRIPT_NAME'] = '/my_script.php';
        $_SERVER['HTTPS'] = "off";
    }

    protected function sanitizeWsdlXmlOutputForOsCompability($xmlstring)
    {
        $xmlstring = str_replace(array("\r", "\n"), "", $xmlstring);
        $xmlstring = preg_replace('/(>[\s]{1,}<)/', '', $xmlstring);
        return $xmlstring;
    }

    function testSetClass()
    {
        $scriptUri = 'http://localhost/my_script.php';

        $server = new Zend_Soap_AutoDiscover();
        $server->setClass('Zend_Soap_AutoDiscover_Test');
        $dom = new DOMDocument();
        ob_start();
        $server->handle();
        $dom->loadXML(ob_get_clean());

        $wsdl = '<?xml version="1.0"?>'
              . '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
              .              'xmlns:tns="' . $scriptUri . '" '
              .              'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
              .              'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
              .              'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
              .              'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
              .              'name="Zend_Soap_AutoDiscover_Test" '
              .              'targetNamespace="' . $scriptUri . '">'
              .     '<types>'
              .         '<xsd:schema targetNamespace="' . $scriptUri . '"/>'
              .     '</types>'
              .     '<portType name="Zend_Soap_AutoDiscover_TestPort">'
              .         '<operation name="testFunc1">'
              .             '<documentation>Test Function 1</documentation>'
              .             '<input message="tns:testFunc1In"/>'
              .             '<output message="tns:testFunc1Out"/>'
              .         '</operation>'
              .         '<operation name="testFunc2">'
              .             '<documentation>Test Function 2</documentation>'
              .             '<input message="tns:testFunc2In"/>'
              .             '<output message="tns:testFunc2Out"/>'
              .         '</operation>'
              .         '<operation name="testFunc3">'
              .             '<documentation>Test Function 3</documentation>'
              .             '<input message="tns:testFunc3In"/>'
              .             '<output message="tns:testFunc3Out"/>'
              .         '</operation><operation name="testFunc4">'
              .             '<documentation>Test Function 4</documentation>'
              .             '<input message="tns:testFunc4In"/>'
              .             '<output message="tns:testFunc4Out"/>'
              .         '</operation>'
              .     '</portType>'
              .     '<binding name="Zend_Soap_AutoDiscover_TestBinding" type="tns:Zend_Soap_AutoDiscover_TestPort">'
              .         '<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>'
              .         '<operation name="testFunc1">'
              .             '<soap:operation soapAction="' . $scriptUri . '#testFunc1"/>'
              .             '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'
              .             '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'
              .         '</operation>'
              .         '<operation name="testFunc2">'
              .             '<soap:operation soapAction="' . $scriptUri . '#testFunc2"/>'
              .             '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'
              .             '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'
              .         '</operation>'
              .         '<operation name="testFunc3">'
              .             '<soap:operation soapAction="' . $scriptUri . '#testFunc3"/>'
              .             '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'
              .             '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'
              .         '</operation>'
              .         '<operation name="testFunc4">'
              .             '<soap:operation soapAction="' . $scriptUri . '#testFunc4"/>'
              .             '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'
              .             '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'
              .         '</operation>'
              .     '</binding>'
              .     '<service name="Zend_Soap_AutoDiscover_TestService">'
              .         '<port name="Zend_Soap_AutoDiscover_TestPort" binding="tns:Zend_Soap_AutoDiscover_TestBinding">'
              .             '<soap:address location="' . $scriptUri . '"/>'
              .         '</port>'
              .     '</service>'
              .     '<message name="testFunc1In"/>'
              .     '<message name="testFunc1Out"><part name="return" type="xsd:string"/></message>'
              .     '<message name="testFunc2In"><part name="who" type="xsd:string"/></message>'
              .     '<message name="testFunc2Out"><part name="return" type="xsd:string"/></message>'
              .     '<message name="testFunc3In"><part name="who" type="xsd:string"/><part name="when" type="xsd:int"/></message>'
              .     '<message name="testFunc3Out"><part name="return" type="xsd:string"/></message>'
              .     '<message name="testFunc4In"/>'
              .     '<message name="testFunc4Out"><part name="return" type="xsd:string"/></message>'
              . '</definitions>';

        $dom->save(dirname(__FILE__).'/_files/setclass.wsdl');
        $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()));
        $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate");

        unlink(dirname(__FILE__).'/_files/setclass.wsdl');
    }

    function testSetClassWithDifferentStyles()
    {
        $scriptUri = 'http://localhost/my_script.php';

        $server = new Zend_Soap_AutoDiscover();
        $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com'));
        $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com'));
        $server->setClass('Zend_Soap_AutoDiscover_Test');
        $dom = new DOMDocument();
        ob_start();
        $server->handle();
        $dom->loadXML(ob_get_clean());

        $wsdl = '<?xml version="1.0"?>'
              . '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
              .              'xmlns:tns="' . $scriptUri . '" '
              .              'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
              .              'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
              .              'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
              .              'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
              .              'name="Zend_Soap_AutoDiscover_Test" '
              .              'targetNamespace="' . $scriptUri . '">'
              .     '<types>'
              .         '<xsd:schema targetNamespace="' . $scriptUri . '">'
              .           '<xsd:element name="testFunc1">'
              .             '<xsd:complexType/>'
              .           '</xsd:element>'
              .           '<xsd:element name="testFunc1Response">'
              .             '<xsd:complexType>'
              .               '<xsd:sequence>'
              .                 '<xsd:element name="testFunc1Result" type="xsd:string"/>'
              .               '</xsd:sequence>'
              .             '</xsd:complexType>'
              .           '</xsd:element>'
              .           '<xsd:element name="testFunc2">'
              .             '<xsd:complexType>'
              .               '<xsd:sequence>'
              .                 '<xsd:element name="who" type="xsd:string"/>'
              .               '</xsd:sequence>'
              .             '</xsd:complexType>'
              .           '</xsd:element>'
              .           '<xsd:element name="testFunc2Response">'
              .             '<xsd:complexType>'
              .               '<xsd:sequence>'
              .                 '<xsd:element name="testFunc2Result" type="xsd:string"/>'
              .               '</xsd:sequence>'
              .             '</xsd:complexType>'
              .           '</xsd:element>'
              .           '<xsd:element name="testFunc3">'
              .             '<xsd:complexType>'
              .               '<xsd:sequence>'
              .                 '<xsd:element name="who" type="xsd:string"/>'
              .                 '<xsd:element name="when" type="xsd:int"/>'
              .               '</xsd:sequence>'
              .             '</xsd:complexType>'
              .           '</xsd:element>'
              .           '<xsd:element name="testFunc3Response">'
              .             '<xsd:complexType>'
              .               '<xsd:sequence>'
              .                 '<xsd:element name="testFunc3Result" type="xsd:string"/>'
              .               '</xsd:sequence>'
              .             '</xsd:complexType>'
              .           '</xsd:element>'
              .           '<xsd:element name="testFunc4">'
              .             '<xsd:complexType/>'
              .           '</xsd:element>'
              .           '<xsd:element name="testFunc4Response">'
              .             '<xsd:complexType>'
              .               '<xsd:sequence>'
              .                 '<xsd:element name="testFunc4Result" type="xsd:string"/>'
              .               '</xsd:sequence>'
              .             '</xsd:complexType>'
              .           '</xsd:element>'
              .         '</xsd:schema>'
              .     '</types>'
              .     '<portType name="Zend_Soap_AutoDiscover_TestPort">'
              .         '<operation name="testFunc1">'
              .             '<documentation>Test Function 1</documentation>'
              .             '<input message="tns:testFunc1In"/>'
              .             '<output message="tns:testFunc1Out"/>'
              .         '</operation>'
              .         '<operation name="testFunc2">'
              .             '<documentation>Test Function 2</documentation>'
              .             '<input message="tns:testFunc2In"/>'
              .             '<output message="tns:testFunc2Out"/>'
              .         '</operation>'
              .         '<operation name="testFunc3">'
              .             '<documentation>Test Function 3</documentation>'
              .             '<input message="tns:testFunc3In"/>'
              .             '<output message="tns:testFunc3Out"/>'
              .         '</operation><operation name="testFunc4">'
              .             '<documentation>Test Function 4</documentation>'
              .             '<input message="tns:testFunc4In"/>'
              .             '<output message="tns:testFunc4Out"/>'
              .         '</operation>'
              .     '</portType>'
              .     '<binding name="Zend_Soap_AutoDiscover_TestBinding" type="tns:Zend_Soap_AutoDiscover_TestPort">'
              .         '<soap:binding style="document" transport="http://framework.zend.com"/>'
              .         '<operation name="testFunc1">'
              .             '<soap:operation soapAction="' . $scriptUri . '#testFunc1"/>'
              .             '<input><soap:body use="literal" namespace="http://framework.zend.com"/></input>'
              .             '<output><soap:body use="literal" namespace="http://framework.zend.com"/></output>'
              .         '</operation>'
              .         '<operation name="testFunc2">'
              .             '<soap:operation soapAction="' . $scriptUri . '#testFunc2"/>'
              .             '<input><soap:body use="literal" namespace="http://framework.zend.com"/></input>'
              .             '<output><soap:body use="literal" namespace="http://framework.zend.com"/></output>'
              .         '</operation>'
              .         '<operation name="testFunc3">'
              .             '<soap:operation soapAction="' . $scriptUri . '#testFunc3"/>'
              .             '<input><soap:body use="literal" namespace="http://framework.zend.com"/></input>'
              .             '<output><soap:body use="literal" namespace="http://framework.zend.com"/></output>'
              .         '</operation>'
              .         '<operation name="testFunc4">'
              .             '<soap:operation soapAction="' . $scriptUri . '#testFunc4"/>'
              .             '<input><soap:body use="literal" namespace="http://framework.zend.com"/></input>'
              .             '<output><soap:body use="literal" namespace="http://framework.zend.com"/></output>'
              .         '</operation>'
              .     '</binding>'
              .     '<service name="Zend_Soap_AutoDiscover_TestService">'
              .         '<port name="Zend_Soap_AutoDiscover_TestPort" binding="tns:Zend_Soap_AutoDiscover_TestBinding">'
              .             '<soap:address location="' . $scriptUri . '"/>'
              .         '</port>'
              .     '</service>'
              .     '<message name="testFunc1In">'
              .       '<part name="parameters" element="tns:testFunc1"/>'
              .     '</message>'
              .     '<message name="testFunc1Out">'
              .       '<part name="parameters" element="tns:testFunc1Response"/>'
              .     '</message>'
              .     '<message name="testFunc2In">'
              .       '<part name="parameters" element="tns:testFunc2"/>'
              .     '</message>'
              .     '<message name="testFunc2Out">'
              .       '<part name="parameters" element="tns:testFunc2Response"/>'
              .     '</message>'
              .     '<message name="testFunc3In">'
              .       '<part name="parameters" element="tns:testFunc3"/>'
              .     '</message>'
              .     '<message name="testFunc3Out">'
              .       '<part name="parameters" element="tns:testFunc3Response"/>'
              .     '</message>'
              .     '<message name="testFunc4In">'
              .       '<part name="parameters" element="tns:testFunc4"/>'
              .     '</message>'
              .     '<message name="testFunc4Out">'
              .       '<part name="parameters" element="tns:testFunc4Response"/>'
              .     '</message>'
              . '</definitions>';

        $dom->save(dirname(__FILE__).'/_files/setclass.wsdl');
        $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()));
        $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate");

        unlink(dirname(__FILE__).'/_files/setclass.wsdl');
    }

    /**
     * @group ZF-5072
     */
    function testSetClassWithResponseReturnPartCompabilityMode()
    {
        $scriptUri = 'http://localhost/my_script.php';

        $server = new Zend_Soap_AutoDiscover();
        $server->setClass('Zend_Soap_AutoDiscover_Test');
        $dom = new DOMDocument();
        ob_start();
        $server->handle();
        $dom->loadXML(ob_get_clean());

        $dom->save(dirname(__FILE__).'/_files/setclass.wsdl');
        $this->assertContains('<message name="testFunc1Out"><part name="return"', $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()));
        $this->assertContains('<message name="testFunc2Out"><part name="return"', $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()));
        $this->assertContains('<message name="testFunc3Out"><part name="return"', $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()));
        $this->assertContains('<message name="testFunc4Out"><part name="return"', $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()));

        unlink(dirname(__FILE__).'/_files/setclass.wsdl');
    }

    function testAddFunctionSimple()
    {
        $scriptUri = 'http://localhost/my_script.php';

        $server = new Zend_Soap_AutoDiscover();
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
        $dom = new DOMDocument();
        ob_start();
        $server->handle();
        $dom->loadXML(ob_get_clean());
        $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl');

        $parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
        $name = $parts[0];

        $wsdl = '<?xml version="1.0"?>'.
                '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="' . $scriptUri . '" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="' .$name. '" targetNamespace="' . $scriptUri . '">'.
                '<types><xsd:schema targetNamespace="' . $scriptUri . '"/></types>'.
                '<portType name="' .$name. 'Port">'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc"><documentation>Test Function</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFuncIn"/><output message="tns:Zend_Soap_AutoDiscover_TestFuncOut"/></operation>'.
                '</portType>'.
                '<binding name="' .$name. 'Binding" type="tns:' .$name. 'Port">'.
                '<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc">'.
                '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc"/>'.
                '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/my_script.php"/></input>'.
                '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/my_script.php"/></output>'.
                '</operation>'.
                '</binding>'.
                '<service name="' .$name. 'Service">'.
                '<port name="' .$name. 'Port" binding="tns:' .$name. 'Binding">'.
                '<soap:address location="' . $scriptUri . '"/>'.
                '</port>'.
                '</service>'.
                '<message name="Zend_Soap_AutoDiscover_TestFuncIn"><part name="who" type="xsd:string"/></message>'.
                '<message name="Zend_Soap_AutoDiscover_TestFuncOut"><part name="return" type="xsd:string"/></message>'.
                '</definitions>';
        $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated");
        $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate");

        unlink(dirname(__FILE__).'/_files/addfunction.wsdl');
    }

    function testAddFunctionSimpleWithDifferentStyle()
    {
        $scriptUri = 'http://localhost/my_script.php';

        $server = new Zend_Soap_AutoDiscover();
        $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com'));
        $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com'));
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
        $dom = new DOMDocument();
        ob_start();
        $server->handle();
        $dom->loadXML(ob_get_clean());
        $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl');

        $parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
        $name = $parts[0];

        $wsdl = '<?xml version="1.0"?>'.
                '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="' . $scriptUri . '" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="' .$name. '" targetNamespace="' . $scriptUri . '">'.
                '<types>'.
                '<xsd:schema targetNamespace="' . $scriptUri . '">'.
                '<xsd:element name="Zend_Soap_AutoDiscover_TestFunc"><xsd:complexType><xsd:sequence><xsd:element name="who" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element>'.
                '<xsd:element name="Zend_Soap_AutoDiscover_TestFuncResponse"><xsd:complexType><xsd:sequence><xsd:element name="Zend_Soap_AutoDiscover_TestFuncResult" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element>'.
                '</xsd:schema>'.
                '</types>'.
                '<portType name="' .$name. 'Port">'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc"><documentation>Test Function</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFuncIn"/><output message="tns:Zend_Soap_AutoDiscover_TestFuncOut"/></operation>'.
                '</portType>'.
                '<binding name="' .$name. 'Binding" type="tns:' .$name. 'Port">'.
                '<soap:binding style="document" transport="http://framework.zend.com"/>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc">'.
                '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc"/>'.
                '<input><soap:body use="literal" namespace="http://framework.zend.com"/></input>'.
                '<output><soap:body use="literal" namespace="http://framework.zend.com"/></output>'.
                '</operation>'.
                '</binding>'.
                '<service name="' .$name. 'Service">'.
                '<port name="' .$name. 'Port" binding="tns:' .$name. 'Binding">'.
                '<soap:address location="' . $scriptUri . '"/>'.
                '</port>'.
                '</service>'.
                '<message name="Zend_Soap_AutoDiscover_TestFuncIn"><part name="parameters" element="tns:Zend_Soap_AutoDiscover_TestFunc"/></message>'.
                '<message name="Zend_Soap_AutoDiscover_TestFuncOut"><part name="parameters" element="tns:Zend_Soap_AutoDiscover_TestFuncResponse"/></message>'.
                '</definitions>';
        $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated");
        $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate");

        unlink(dirname(__FILE__).'/_files/addfunction.wsdl');
    }

    /**
     * @group ZF-5072
     */
    function testAddFunctionSimpleInReturnNameCompabilityMode()
    {
        $scriptUri = 'http://localhost/my_script.php';

        $server = new Zend_Soap_AutoDiscover();
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
        $dom = new DOMDocument();
        ob_start();
        $server->handle();
        $dom->loadXML(ob_get_clean());
        $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl');

        $parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
        $name = $parts[0];

        $wsdl = $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML());
        $this->assertContains('<message name="Zend_Soap_AutoDiscover_TestFuncOut"><part name="return" type="xsd:string"/>', $wsdl);
        $this->assertNotContains('<message name="Zend_Soap_AutoDiscover_TestFuncOut"><part name="Zend_Soap_AutoDiscover_TestFuncReturn"', $wsdl);
        $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate");

        unlink(dirname(__FILE__).'/_files/addfunction.wsdl');
    }

    function testAddFunctionMultiple()
    {
        $scriptUri = 'http://localhost/my_script.php';

        $server = new Zend_Soap_AutoDiscover();
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc2');
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc3');
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc4');
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc5');
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc6');
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc7');
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc9');

        $dom = new DOMDocument();
        ob_start();
        $server->handle();
        $dom->loadXML(ob_get_clean());
        $dom->save(dirname(__FILE__).'/_files/addfunction2.wsdl');

        $parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
        $name = $parts[0];

        $wsdl = '<?xml version="1.0"?>'.
                '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="' . $scriptUri . '" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="' .$name. '" targetNamespace="' . $scriptUri . '">'.
                '<types><xsd:schema targetNamespace="' . $scriptUri . '"/></types>'.
                '<portType name="' .$name. 'Port">'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc"><documentation>Test Function</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFuncIn"/><output message="tns:Zend_Soap_AutoDiscover_TestFuncOut"/></operation>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc2"><documentation>Test Function 2</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFunc2In"/></operation>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc3"><documentation>Return false</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFunc3In"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc3Out"/></operation>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc4"><documentation>Return true</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFunc4In"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc4Out"/></operation>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc5"><documentation>Return integer</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFunc5In"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc5Out"/></operation>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc6"><documentation>Return string</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFunc6In"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc6Out"/></operation>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc7"><documentation>Return array</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFunc7In"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc7Out"/></operation>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc9"><documentation>Multiple Args</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFunc9In"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc9Out"/></operation>'.
                '</portType>'.
                '<binding name="' .$name. 'Binding" type="tns:' .$name. 'Port">'.
                '<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc">'.
                '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc"/>'.
                '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
                '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
                '</operation>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc2">'.
                '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc2"/>'.
                '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
                '</operation>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc3">'.
                '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc3"/>'.
                '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
                '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
                '</operation>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc4">'.
                '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc4"/>'.
                '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
                '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
                '</operation>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc5">'.
                '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc5"/>'.
                '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
                '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
                '</operation>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc6">'.
                '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc6"/>'.
                '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
                '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
                '</operation>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc7">'.
                '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc7"/>'.
                '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
                '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
                '</operation>'.
                '<operation name="Zend_Soap_AutoDiscover_TestFunc9">'.
                '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc9"/>'.
                '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
                '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
                '</operation>'.
                '</binding>'.
                '<service name="' .$name. 'Service">'.
                '<port name="' .$name. 'Port" binding="tns:' .$name. 'Binding">'.
                '<soap:address location="' . $scriptUri . '"/>'.
                '</port>'.
                '</service>'.
                '<message name="Zend_Soap_AutoDiscover_TestFuncIn"><part name="who" type="xsd:string"/></message>'.
                '<message name="Zend_Soap_AutoDiscover_TestFuncOut"><part name="return" type="xsd:string"/></message>'.
                '<message name="Zend_Soap_AutoDiscover_TestFunc2In"/>'.
                '<message name="Zend_Soap_AutoDiscover_TestFunc3In"/>'.
                '<message name="Zend_Soap_AutoDiscover_TestFunc3Out"><part name="return" type="xsd:boolean"/></message>'.
                '<message name="Zend_Soap_AutoDiscover_TestFunc4In"/>'.
                '<message name="Zend_Soap_AutoDiscover_TestFunc4Out"><part name="return" type="xsd:boolean"/></message>'.
                '<message name="Zend_Soap_AutoDiscover_TestFunc5In"/>'.
                '<message name="Zend_Soap_AutoDiscover_TestFunc5Out"><part name="return" type="xsd:int"/></message>'.
                '<message name="Zend_Soap_AutoDiscover_TestFunc6In"/>'.
                '<message name="Zend_Soap_AutoDiscover_TestFunc6Out"><part name="return" type="xsd:string"/></message>'.
                '<message name="Zend_Soap_AutoDiscover_TestFunc7In"/>'.
                '<message name="Zend_Soap_AutoDiscover_TestFunc7Out"><part name="return" type="soap-enc:Array"/></message>'.
                '<message name="Zend_Soap_AutoDiscover_TestFunc9In"><part name="foo" type="xsd:string"/><part name="bar" type="xsd:string"/></message>'.
                '<message name="Zend_Soap_AutoDiscover_TestFunc9Out"><part name="return" type="xsd:string"/></message>'.
                '</definitions>';
        $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Generated WSDL did not match expected XML");
        $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate");

        unlink(dirname(__FILE__).'/_files/addfunction2.wsdl');
    }

    /**
     * @group ZF-4117
     */
    public function testUseHttpsSchemaIfAccessedThroughHttps()
    {
        $_SERVER['HTTPS'] = "on";
        $httpsScriptUri = 'https://localhost/my_script.php';

        $server = new Zend_Soap_AutoDiscover();
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');

        ob_start();
        $server->handle();
        $wsdlOutput = ob_get_clean();

        $this->assertContains($httpsScriptUri, $wsdlOutput);
    }

    /**
     * @group ZF-4117
     */
    public function testChangeWsdlUriInConstructor()
    {
        $scriptUri = 'http://localhost/my_script.php';

        $server = new Zend_Soap_AutoDiscover(true, "http://example.com/service.php");
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');

        ob_start();
        $server->handle();
        $wsdlOutput = ob_get_clean();

        $this->assertNotContains($scriptUri, $wsdlOutput);
        $this->assertContains("http://example.com/service.php", $wsdlOutput);
    }

    /**
     * @group ZF-4117
     */
    public function testChangeWsdlUriViaSetUri()
    {
        $scriptUri = 'http://localhost/my_script.php';

        $server = new Zend_Soap_AutoDiscover(true);
        $server->setUri("http://example.com/service.php");
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');

        ob_start();
        $server->handle();
        $wsdlOutput = ob_get_clean();

        $this->assertNotContains($scriptUri, $wsdlOutput);
        $this->assertContains("http://example.com/service.php", $wsdlOutput);
    }

    public function testSetNonStringNonZendUriUriThrowsException()
    {
        $server = new Zend_Soap_AutoDiscover();
        try {
            $server->setUri(array("bogus"));
            $this->fail();
        } catch(Zend_Soap_AutoDiscover_Exception $e) {

        }
    }

    /**
     * @group ZF-4117
     */
    public function testChangingWsdlUriAfterGenerationIsPossible()
    {
        $scriptUri = 'http://localhost/my_script.php';

        $server = new Zend_Soap_AutoDiscover(true);
        $server->setUri("http://example.com/service.php");
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');

        ob_start();
        $server->handle();
        $wsdlOutput = ob_get_clean();

        $this->assertNotContains($scriptUri, $wsdlOutput);
        $this->assertContains("http://example.com/service.php", $wsdlOutput);

        $server->setUri("http://example2.com/service2.php");

        ob_start();
        $server->handle();
        $wsdlOutput = ob_get_clean();

        $this->assertNotContains($scriptUri, $wsdlOutput);
        $this->assertNotContains("http://example.com/service.php", $wsdlOutput);
        $this->assertContains("http://example2.com/service2.php", $wsdlOutput);
    }

    /**
     * @group ZF-4688
     * @group ZF-4125
     *
     */
    public function testUsingClassWithMultipleMethodPrototypesProducesValidWsdl()
    {
        $scriptUri = 'http://localhost/my_script.php';

        $server = new Zend_Soap_AutoDiscover();
        $server->setClass('Zend_Soap_AutoDiscover_TestFixingMultiplePrototypes');

        ob_start();
        $server->handle();
        $wsdlOutput = ob_get_clean();

        $this->assertEquals(1, substr_count($wsdlOutput, '<message name="testFuncIn">'));
        $this->assertEquals(1, substr_count($wsdlOutput, '<message name="testFuncOut">'));
    }

    public function testUnusedFunctionsOfAutoDiscoverThrowException()
    {
        $server = new Zend_Soap_AutoDiscover();
        try {
            $server->setPersistence("bogus");
            $this->fail();
        } catch(Zend_Soap_AutoDiscover_Exception $e) {

        }

        try {
            $server->fault();
            $this->fail();
        } catch(Zend_Soap_AutoDiscover_Exception $e) {

        }

        try {
            $server->loadFunctions("bogus");
            $this->fail();
        } catch(Zend_Soap_AutoDiscover_Exception $e) {

        }
    }

    public function testGetFunctions()
    {
        $server = new Zend_Soap_AutoDiscover();
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
        $server->setClass('Zend_Soap_AutoDiscover_Test');

        $functions = $server->getFunctions();
        $this->assertEquals(
            array('Zend_Soap_AutoDiscover_TestFunc', 'testFunc1', 'testFunc2', 'testFunc3', 'testFunc4'),
            $functions
        );
    }

    /**
     * @group ZF-4835
     */
    public function testUsingRequestUriWithoutParametersAsDefault()
    {
        // Apache
        $_SERVER = array('REQUEST_URI' => '/my_script.php?wsdl', 'HTTP_HOST' => 'localhost');
        $server = new Zend_Soap_AutoDiscover();
        $uri = $server->getUri()->getUri();
        $this->assertNotContains("?wsdl", $uri);
        $this->assertEquals("http://localhost/my_script.php", $uri);

        // Apache plus SSL
        $_SERVER = array('REQUEST_URI' => '/my_script.php?wsdl', 'HTTP_HOST' => 'localhost', 'HTTPS' => 'on');
        $server = new Zend_Soap_AutoDiscover();
        $uri = $server->getUri()->getUri();
        $this->assertNotContains("?wsdl", $uri);
        $this->assertEquals("https://localhost/my_script.php", $uri);

        // IIS 5 + PHP as FastCGI
        $_SERVER = array('ORIG_PATH_INFO' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost');
        $server = new Zend_Soap_AutoDiscover();
        $uri = $server->getUri()->getUri();
        $this->assertNotContains("?wsdl", $uri);
        $this->assertEquals("http://localhost/my_script.php", $uri);

        // IIS
        $_SERVER = array('HTTP_X_REWRITE_URL' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost');
        $server = new Zend_Soap_AutoDiscover();
        $uri = $server->getUri()->getUri();
        $this->assertNotContains("?wsdl", $uri);
        $this->assertEquals("http://localhost/my_script.php", $uri);
    }

    /**
     * @group ZF-4937
     */
    public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce()
    {
        $server = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex');
        $server->setClass('Zend_Soap_AutoDiscoverTestClass2');

        ob_start();
        $server->handle();
        $wsdlOutput = ob_get_clean();

        $this->assertEquals(1,
            substr_count($wsdlOutput, 'wsdl:arrayType="tns:Zend_Soap_AutoDiscoverTestClass1[]"'),
            'wsdl:arrayType definition of TestClass1 has to occour once.'
        );
        $this->assertEquals(1,
            substr_count($wsdlOutput, '<xsd:complexType name="Zend_Soap_AutoDiscoverTestClass1">'),
            'Zend_Soap_AutoDiscoverTestClass1 has to be defined once.'
        );
        $this->assertEquals(1,
            substr_count($wsdlOutput, '<xsd:complexType name="ArrayOfZend_Soap_AutoDiscoverTestClass1">'),
            'ArrayOfZend_Soap_AutoDiscoverTestClass1 should be defined once.'
        );
        $this->assertTrue(
            substr_count($wsdlOutput, '<part name="test" type="tns:Zend_Soap_AutoDiscoverTestClass1"/>') >= 1,
            'Zend_Soap_AutoDiscoverTestClass1 appears once or more than once in the message parts section.'
        );
    }

    /**
     * @group ZF-5330
     */
    public function testDumpOrXmlOfAutoDiscover()
    {
        $server = new Zend_Soap_AutoDiscover();
        $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');

        ob_start();
        $server->handle();
        $wsdlOutput = ob_get_clean();

        $this->assertEquals(
            $this->sanitizeWsdlXmlOutputForOsCompability($wsdlOutput),
            $this->sanitizeWsdlXmlOutputForOsCompability($server->toXml())
        );

        ob_start();
        $server->dump(false);
        $wsdlOutput = ob_get_clean();

        $this->assertEquals(
            $this->sanitizeWsdlXmlOutputForOsCompability($wsdlOutput),
            $this->sanitizeWsdlXmlOutputForOsCompability($server->toXml())
        );
    }

    /**
     * @group ZF-5330
     */
    public function testDumpOrXmlOnlyAfterGeneratedAutoDiscoverWsdl()
    {
        $server = new Zend_Soap_AutoDiscover();
        try {
            $server->dump(false);
            $this->fail();
        } catch(Exception $e) {
            $this->assertTrue($e instanceof Zend_Soap_AutoDiscover_Exception);
        }

        try {
            $server->toXml();
            $this->fail();
        } catch(Exception $e) {
            $this->assertTrue($e instanceof Zend_Soap_AutoDiscover_Exception);
        }
    }

    /**
     * @group ZF-5604
     */
    public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayComplex()
    {
        $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex');
        $autodiscover->setClass('Zend_Soap_AutoDiscover_MyService');
        $wsdl = $autodiscover->toXml();

        $this->assertEquals(1, substr_count($wsdl, '<xsd:complexType name="ArrayOfZend_Soap_AutoDiscover_MyResponse">'));

        $this->assertEquals(0, substr_count($wsdl, 'tns:My_Response[]'));
    }

    /**
     * @group ZF-5430
     */
    public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArraySequence()
    {
        $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence');
        $autodiscover->setClass('Zend_Soap_AutoDiscover_MyServiceSequence');
        $wsdl = $autodiscover->toXml();

        $this->assertEquals(1, substr_count($wsdl, '<xsd:complexType name="ArrayOfString">'));
        $this->assertEquals(1, substr_count($wsdl, '<xsd:complexType name="ArrayOfArrayOfString">'));
        $this->assertEquals(1, substr_count($wsdl, '<xsd:complexType name="ArrayOfArrayOfArrayOfString">'));

        $this->assertEquals(0, substr_count($wsdl, 'tns:string[]'));
    }

    /**
     * @group ZF-5736
     */
    public function testAmpersandInUrlIsCorrectlyEncoded()
    {
        $autodiscover = new Zend_Soap_AutoDiscover();
        $autodiscover->setUri("http://example.com/?a=b&b=c");

        $autodiscover->setClass("Zend_Soap_AutoDiscover_Test");
        $wsdl = $autodiscover->toXml();

        $this->assertContains("http://example.com/?a=b&b=c", $wsdl);
    }

    /**
     * @group ZF-6689
     */
    public function testNoReturnIsOneWayCallInSetClass()
    {
        $autodiscover = new Zend_Soap_AutoDiscover();
        $autodiscover->setClass('Zend_Soap_AutoDiscover_NoReturnType');
        $wsdl = $autodiscover->toXml();

        $this->assertContains(
            '<operation name="pushOneWay"><documentation>@param string $message</documentation><input message="tns:pushOneWayIn"/></operation>',
            $wsdl
        );
    }

    /**
     * @group ZF-6689
     */
    public function testNoReturnIsOneWayCallInAddFunction()
    {
        $autodiscover = new Zend_Soap_AutoDiscover();
        $autodiscover->addFunction('Zend_Soap_AutoDiscover_OneWay');
        $wsdl = $autodiscover->toXml();

        $this->assertContains(
            '<operation name="Zend_Soap_AutoDiscover_OneWay"><documentation>@param string $message</documentation><input message="tns:Zend_Soap_AutoDiscover_OneWayIn"/></operation>',
            $wsdl
        );
    }

    /**
     * @group ZF-8948
     * @group ZF-5766
     */
    public function testRecursiveWsdlDependencies()
    {
        $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex');
        $autodiscover->setClass('Zend_Soap_AutoDiscover_Recursion');
        $wsdl = $autodiscover->toXml();

        //  <types>
        //      <xsd:schema targetNamespace="http://localhost/my_script.php">
        //          <xsd:complexType name="Zend_Soap_AutoDiscover_Recursion">
        //              <xsd:all>
        //                  <xsd:element name="recursion" type="tns:Zend_Soap_AutoDiscover_Recursion"/>

        $path = '//wsdl:types/xsd:schema/xsd:complexType[@name="Zend_Soap_AutoDiscover_Recursion"]/xsd:all/xsd:element[@name="recursion" and @type="tns:Zend_Soap_AutoDiscover_Recursion"]';
        $this->assertWsdlPathExists($wsdl, $path);
    }

    public function assertWsdlPathExists($xml, $path)
    {
        $doc = new DOMDocument('UTF-8');
        $doc->loadXML($xml);

        $xpath = new DOMXPath($doc);
        $xpath->registerNamespace('wsdl', 'http://schemas.xmlsoap.org/wsdl/');

        $nodes = $xpath->query($path);

        $this->assertTrue($nodes->length >= 1, "Could not assert that XML Document contains a node that matches the XPath Expression: " . $path);
    }
}


text:
namespace move_tests
{
    test::seed_t seed(98624);

    template<class T>
    T empty(T*) {
        return T();
    }

    template<class T>
    T create(test::random_values<T> const& v,
            test::object_count& count) {
        T x(v.begin(), v.end());
        count = test::global_object_count;
        return x;
    }

    template<class T>
    T create(test::random_values<T> const& v,
            test::object_count& count,
            BOOST_DEDUCED_TYPENAME T::hasher hf,
            BOOST_DEDUCED_TYPENAME T::key_equal eq,
            BOOST_DEDUCED_TYPENAME T::allocator_type al,
            float mlf) {
        T x(0, hf, eq, al);
        x.max_load_factor(mlf);
        x.insert(v.begin(), v.end());
        count = test::global_object_count;
        return x;
    }

    template <class T>
    void move_construct_tests1(T* ptr, test::random_generator const& generator = test::default_generator)
    {
        BOOST_DEDUCED_TYPENAME T::hasher hf;
        BOOST_DEDUCED_TYPENAME T::key_equal eq;
        BOOST_DEDUCED_TYPENAME T::allocator_type al;

        {
            T y(empty(ptr));
            BOOST_CHECK(y.empty());
            BOOST_CHECK(test::equivalent(y.hash_function(), hf));
            BOOST_CHECK(test::equivalent(y.key_eq(), eq));
            BOOST_CHECK(test::equivalent(y.get_allocator(), al));
            BOOST_CHECK(y.max_load_factor() == 1.0);
            test::check_equivalent_keys(y);
        }

        {
            test::random_values<T> v(1000, generator);
            test::object_count count;
            T y(create(v, count));
            BOOST_CHECK(count == test::global_object_count);
            test::check_container(y, v);
            test::check_equivalent_keys(y);
        }
    }

    template <class T>
    void move_assign_tests1(T*, test::random_generator const& generator = test::default_generator)
    {
        {
            test::random_values<T> v(500, generator);
            test::object_count count;
            T y;
            y = create(v, count);
            BOOST_CHECK(count == test::global_object_count);
            test::check_container(y, v);
            test::check_equivalent_keys(y);
        }
    }

    template <class T>
    void move_construct_tests2(T*,
            test::random_generator const& generator = test::default_generator)
    {
        BOOST_DEDUCED_TYPENAME T::hasher hf(1);
        BOOST_DEDUCED_TYPENAME T::key_equal eq(1);
        BOOST_DEDUCED_TYPENAME T::allocator_type al(1);
        BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);

        test::object_count count;

        {
            test::random_values<T> v(500, generator);
            T y(create(v, count, hf, eq, al, 0.5));
            BOOST_CHECK(count == test::global_object_count);
            test::check_container(y, v);
            BOOST_CHECK(test::equivalent(y.hash_function(), hf));
            BOOST_CHECK(test::equivalent(y.key_eq(), eq));
            BOOST_CHECK(test::equivalent(y.get_allocator(), al));
            BOOST_CHECK(y.max_load_factor() == 0.5); // Not necessarily required.
            test::check_equivalent_keys(y);
        }

        {
            // TODO: To do this correctly requires the fancy new allocator stuff.
            test::random_values<T> v(500, generator);
            T y(create(v, count, hf, eq, al, 2.0), al2);
            BOOST_CHECK(count != test::global_object_count);
            test::check_container(y, v);
            BOOST_CHECK(test::equivalent(y.hash_function(), hf));
            BOOST_CHECK(test::equivalent(y.key_eq(), eq));
            BOOST_CHECK(test::equivalent(y.get_allocator(), al2));
            BOOST_CHECK(y.max_load_factor() == 2.0); // Not necessarily required.
            test::check_equivalent_keys(y);
        }

        {
            test::random_values<T> v(25, generator);
            T y(create(v, count, hf, eq, al, 1.0), al);
#if defined(BOOST_HAS_RVALUE_REFS)
            BOOST_CHECK(count == test::global_object_count);
#else
            BOOST_CHECK(test::global_object_count.constructions - count.constructions <=
                (test::is_map<T>::value ? 50 : 25));
            BOOST_CHECK(count.instances == test::global_object_count.instances);
#endif
            test::check_container(y, v);
            BOOST_CHECK(test::equivalent(y.hash_function(), hf));
            BOOST_CHECK(test::equivalent(y.key_eq(), eq));
            BOOST_CHECK(test::equivalent(y.get_allocator(), al));
            BOOST_CHECK(y.max_load_factor() == 1.0); // Not necessarily required.
            test::check_equivalent_keys(y);
        }
    }

    boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
    boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
    boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
    boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;

    using test::default_generator;
    using test::generate_collisions;

    UNORDERED_TEST(move_construct_tests1,
        ((test_set)(test_multiset)(test_map)(test_multimap))
    )
    UNORDERED_TEST(move_assign_tests1,
        ((test_set)(test_multiset)(test_map)(test_multimap))
    )
    UNORDERED_TEST(move_construct_tests2,
        ((test_set)(test_multiset)(test_map)(test_multimap))
        ((default_generator)(generate_collisions))
    )
}

RUN_TESTS()


text:
<?php
namespace Scalr\Tests\Model;

use Exception;
use Scalr\Tests\TestCase;
use Scalr\Tests\Fixtures\Model\Entity\Entity1;
use Scalr\Model\Entity\CloudLocation;

/**
 * AbstractEntityTest test
 *
 * @author   Igor Vodiasov <invar@scalr.com>
 * @since    5.0 (06.05.2014)
 */
class AbstractEntityTest extends TestCase
{
    const CL_LOC_ID = '00000001-0001-0001-0001-000000000001';
    const CL_PLATFORM = 'test';
    const CL_URL = '';
    const CL_NAME = 'test';

    /**
     * Data provider for testBuildQuery
     *
     * @return array
     */
    public function providerBuildQuery()
    {
        $array = [
            [[['os' => null]], 'AND', "`prices`.`os` IS NULL"],
            [[['os' => ['$lt' => null]]], 'AND', "`prices`.`os` IS NOT NULL"],
            [[['os' => ['$gt' => null]]], 'AND', "`prices`.`os` IS NOT NULL"],
            [[['os' => ['$gte' => null]]], 'AND', "`prices`.`os` IS NULL"],
            [[['os' => ['$lte' => null]]], 'AND', "`prices`.`os` IS NULL"],
            [[['priceId' => 1], ['os' =>['$ne' => 0]]], 'AND', "`prices`.`price_id` = '1' AND `prices`.`os` <> '0'"],
            [[['priceId' => 1], ['os' =>['$ne' => null]]], 'AND', "`prices`.`price_id` = '1' AND `prices`.`os` IS NOT NULL"],
            [[['priceId' => 1]], 'AND', "`prices`.`price_id` = '1'"],
            [[['priceId' => 1], ['priceId' => 2]], 'AND', "`prices`.`price_id` = '1' AND `prices`.`price_id` = '2'"],
            [[['priceId' => 1], ['priceId' => 2]], 'OR', "(`prices`.`price_id` = '1' OR `prices`.`price_id` = '2')"],
            [[['priceId' => 1], ['os' => '1'], ['$or' => [['cost' => '123'], ['cost' => '234']]], ['name' => ['$like' => '%test']]], 'AND',
                "`prices`.`price_id` = '1' AND `prices`.`os` = '1' AND (`prices`.`cost` = '123.000000' OR `prices`.`cost` = '234.000000') AND `prices`.`name` LIKE('%test')"
            ],
            [[['priceId' => 1], ['os' => '1'], ['$and' => [['cost' => '123'], ['cost' => '234']]], ['name' => ['$like' => '%test']]], 'OR',
                "(`prices`.`price_id` = '1' OR `prices`.`os` = '1' OR `prices`.`cost` = '123.000000' AND `prices`.`cost` = '234.000000' OR `prices`.`name` LIKE('%test'))"
            ],
            [[['os' => ['$in' => [1, 2, 3, 4]]], ['name' => ['$nin' => ['a1', 'a2', 'a3']]]], 'AND',
                "`prices`.`os` IN('1', '2', '3', '4') AND `prices`.`name` NOT IN('a1', 'a2', 'a3')"
            ],
            [[['os' => ['$in' => [1, 2, 3, 4]]], ['name' => 'a1'], ['cost' => ['$gt' => 1, '$lt' => 3]]], 'AND',
                "`prices`.`os` IN('1', '2', '3', '4') AND `prices`.`name` = 'a1' AND `prices`.`cost` > '1.000000' AND `prices`.`cost` < '3.000000'"
            ],
            [[['os' => ['$in' => [3, 4]]], ['name' => 'a2'], ['$or' => [['cost' => ['$gt' => 5]], ['cost' => ['$lt' => 2]]]]], 'AND',
                "`prices`.`os` IN('3', '4') AND `prices`.`name` = 'a2' AND (`prices`.`cost` > '5.000000' OR `prices`.`cost` < '2.000000')"
            ]
        ];

        return $array;
    }

    /**
     * @test
     * @dataProvider providerBuildQuery
     */
    public function testBuildQuery($criteria, $conjunction, $sql)
    {
        $entity = new Entity1();
        $sqlResult = $entity->_buildQuery($criteria, $conjunction);
        $this->assertEquals(trim($sqlResult['where']), trim($sql));
    }

    /**
     * Creates entity
     *
     * @param    string     $id            optional uuid
     * @param    string     $cloudLocation optional
     * @return   \Scalr\Model\Entity\CloudLocation
     */
    private function getCloudLocationEntity($id = null, $cloudLocation = self::CL_NAME)
    {
        //Create test cloud location
        $cl = new CloudLocation();
        $cl->cloudLocationId = $id ?: self::CL_LOC_ID;

        //Platform,url,cloudLocation is unique key
        $cl->platform = self::CL_PLATFORM;
        $cl->url = self::CL_URL;
        $cl->cloudLocation = self::CL_NAME;

        return $cl;
    }

    /**
     * Removes entity by identifier
     *
     * @param   string    $id  UUID
     */
    private function removeCloudLocationEntityByIdIfExists($id)
    {
        $cl = CloudLocation::findPk($id);
        /* @var $cl \Scalr\Model\Entity\CloudLocation */
        if ($cl instanceof CloudLocation) {
            //Removes previously created location
            $cl->delete();
        }
    }

    /**
     * Cleanups cloud locations
     */
    private function cleanupCloudLocations()
    {
        $cl2Identifier = CloudLocation::calculateCloudLocationId(self::CL_PLATFORM, self::CL_NAME, self::CL_URL);
        $cl3Identifier = CloudLocation::calculateCloudLocationId(self::CL_PLATFORM, self::CL_NAME . '3', self::CL_URL);
        //Removes records
        $this->removeCloudLocationEntityByIdIfExists(self::CL_LOC_ID);
        $this->removeCloudLocationEntityByIdIfExists($cl2Identifier);
        $this->removeCloudLocationEntityByIdIfExists($cl3Identifier);
    }

    /**
     * SCALRCORE-951 we should avoid ON DUPLICATE KEY UPDATE clause on tables with multiple unique indexes
     * @test
     * @functional
     */
    public function testFunctionalSeveralUniqueKeys()
    {
        $db = \Scalr::getDb();

        //Removes previously created records if they exist
        $this->cleanupCloudLocations();

        $cl2Identifier = CloudLocation::calculateCloudLocationId(self::CL_PLATFORM, self::CL_NAME, self::CL_URL);
        $cl3Identifier = CloudLocation::calculateCloudLocationId(self::CL_PLATFORM, self::CL_NAME . '3', self::CL_URL);

        //Creates the first record
        $cl = $this->getCloudLocationEntity();
        $cl->save();
        unset($cl);

        //Checks if it has been saved properly
        $cl = CloudLocation::findPk(self::CL_LOC_ID);
        $this->assertInstanceOf('Scalr\\Model\\Entity\\CloudLocation', $cl);
        $this->assertEquals(self::CL_LOC_ID, $cl->cloudLocationId);
        $this->assertEquals(self::CL_URL, $cl->url);
        $this->assertEquals(self::CL_NAME, $cl->cloudLocation);
        $this->assertEquals(self::CL_PLATFORM, $cl->platform);

        $cl3 = $this->getCloudLocationEntity($cl3Identifier);
        $cl3->cloudLocation = self::CL_NAME . '3';

        $cl3->save();

        //Record with this unique key already exists
        $cl3->cloudLocation = self::CL_NAME;

        //Saving record with existing unique key
        $ex = false;
        try {
            $cl3->save();
            $this->cleanupCloudLocations();
        } catch (Exception $e) {
            //"Duplicate entry 'test--test' for key 'idx_unique'"
            $ex = true;
            $this->assertContains("Duplicate entry", $e->getMessage());
        }
        $this->assertTrue($ex, "Duplicate entry 'test--test' for key 'idx_unique' must be thrown here (3)");

        //Trying to create with the same unique key as $cl but different primary key
        $cl2 = $this->getCloudLocationEntity($cl2Identifier);
        //Checks they're different
        $this->assertNotEquals(self::CL_LOC_ID, $cl2Identifier);

        //unique key should cause error, and should not be just ignored
        $ex = false;
        try {
            $cl2->save();
            $this->cleanupCloudLocations();
        } catch (Exception $e) {
            $ex = true;
            $this->assertContains("Duplicate entry", $e->getMessage());
        }
        $this->assertTrue($ex, "Duplicate entry 'test--test' for key 'idx_unique' must be thrown here (2)");

        $this->assertNull(CloudLocation::findPk($cl2Identifier));

        $this->cleanupCloudLocations();
    }
}