text:
//---------------------------------------------------------------------------
//	Greenplum Database
//	Copyright (C) 2011 EMC Corp.
//
//	@filename:
//		CPhysicalStreamAgg.cpp
//
//	@doc:
//		Implementation of stream aggregation operator
//---------------------------------------------------------------------------

#include "gpos/base.h"

#include "gpopt/base/CColRefSetIter.h"
#include "gpopt/base/COptCtxt.h"
#include "gpopt/base/CDistributionSpecHashed.h"
#include "gpopt/base/CDistributionSpecSingleton.h"
#include "gpopt/base/CKeyCollection.h"
#include "gpopt/operators/CExpressionHandle.h"
#include "gpopt/operators/CPhysicalStreamAgg.h"

using namespace gpopt;

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalStreamAgg::CPhysicalStreamAgg
//
//	@doc:
//		Ctor
//
//---------------------------------------------------------------------------
CPhysicalStreamAgg::CPhysicalStreamAgg
	(
	CMemoryPool *mp,
	CColRefArray *colref_array,
	CColRefArray *pdrgpcrMinimal,
	COperator::EGbAggType egbaggtype,
	BOOL fGeneratesDuplicates,
	CColRefArray *pdrgpcrArgDQA,
	BOOL fMultiStage,
	BOOL isAggFromSplitDQA,
	CLogicalGbAgg::EAggStage aggStage,
  BOOL should_enforce_distribution
	)
	:
	CPhysicalAgg
	(
	mp,
	colref_array,
	pdrgpcrMinimal,
	egbaggtype,
	fGeneratesDuplicates,
	pdrgpcrArgDQA,
	fMultiStage,
	isAggFromSplitDQA,
	aggStage,
	should_enforce_distribution
	),
	m_pos(NULL)
{
	GPOS_ASSERT(NULL != m_pdrgpcrMinimal);
	m_pcrsMinimalGrpCols = GPOS_NEW(mp) CColRefSet(mp, m_pdrgpcrMinimal);
	InitOrderSpec(mp, m_pdrgpcrMinimal);
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalStreamAgg::InitOrderSpec
//
//	@doc:
//		Initialize the order spec using the given array of columns
//
//---------------------------------------------------------------------------
void
CPhysicalStreamAgg::InitOrderSpec
	(
	CMemoryPool *mp,
	CColRefArray *pdrgpcrOrder
	)
{
	GPOS_ASSERT(NULL != pdrgpcrOrder);

	CRefCount::SafeRelease(m_pos);
	m_pos = GPOS_NEW(mp) COrderSpec(mp);
	const ULONG size = pdrgpcrOrder->Size();
	for (ULONG ul = 0; ul < size; ul++)
	{
		CColRef *colref = (*pdrgpcrOrder)[ul];

		// TODO: 12/21/2011 - ; this seems broken: a colref must not embed
		// a pointer to a cached object
		gpmd::IMDId *mdid = colref->RetrieveType()->GetMdidForCmpType(IMDType::EcmptL);
		mdid->AddRef();

		m_pos->Append(mdid, colref, COrderSpec::EntLast);
	}
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalStreamAgg::~CPhysicalStreamAgg
//
//	@doc:
//		Dtor
//
//---------------------------------------------------------------------------
CPhysicalStreamAgg::~CPhysicalStreamAgg()
{
	m_pcrsMinimalGrpCols->Release();
	m_pos->Release();
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalStreamAgg::PosCovering
//
//	@doc:
//		Construct order spec on grouping column so that it covers required
//		order spec, the function returns NULL if no covering order spec
//		can be created
//
//---------------------------------------------------------------------------
COrderSpec *
CPhysicalStreamAgg::PosCovering
	(
	CMemoryPool *mp,
	COrderSpec *posRequired,
	CColRefArray *pdrgpcrGrp
	)
	const
{
	GPOS_ASSERT(NULL != posRequired);

	if (0 == posRequired->UlSortColumns())
	{
		// required order must be non-empty
		return NULL;
	}

	// create a set of required sort columns
	CColRefSet *pcrsReqd = posRequired->PcrsUsed(mp);

	COrderSpec *pos = NULL;

	CColRefSet *pcrsGrpCols = GPOS_NEW(mp) CColRefSet(mp, pdrgpcrGrp);
	if (pcrsGrpCols->ContainsAll(pcrsReqd))
	{
		// required order columns are included in grouping columns, we can
		// construct a covering order spec
		pos = GPOS_NEW(mp) COrderSpec(mp);

		// extract order expressions from required order
		const ULONG ulReqdSortCols = posRequired->UlSortColumns();
		for (ULONG ul = 0; ul < ulReqdSortCols; ul++)
		{
			CColRef *colref = const_cast<CColRef *>(posRequired->Pcr(ul));
			IMDId *mdid = posRequired->GetMdIdSortOp(ul);
			COrderSpec::ENullTreatment ent = posRequired->Ent(ul);
			mdid->AddRef();
			pos->Append(mdid, colref, ent);
		}

		// augment order with remaining grouping columns
		const ULONG size = pdrgpcrGrp->Size();
		for (ULONG ul = 0; ul < size; ul++)
		{
			CColRef *colref = (*pdrgpcrGrp)[ul];
			if (!pcrsReqd->FMember(colref))
			{
				IMDId *mdid = colref->RetrieveType()->GetMdidForCmpType(IMDType::EcmptL);
				mdid->AddRef();
				pos->Append(mdid, colref, COrderSpec::EntLast);
			}
		}
	}
	pcrsGrpCols->Release();
	pcrsReqd->Release();

	return pos;
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalStreamAgg::PosRequiredStreamAgg
//
//	@doc:
//		Compute required sort columns of the n-th child
//
//---------------------------------------------------------------------------
COrderSpec *
CPhysicalStreamAgg::PosRequiredStreamAgg
	(
	CMemoryPool *mp,
	CExpressionHandle &exprhdl,
	COrderSpec *posRequired,
	ULONG
#ifdef GPOS_DEBUG
	child_index
#endif // GPOS_DEBUG
	,
	CColRefArray *pdrgpcrGrp
	)
	const
{
	GPOS_ASSERT(0 == child_index);

	COrderSpec *pos = PosCovering(mp, posRequired, pdrgpcrGrp);
	if (NULL == pos)
	{
		// failed to find a covering order spec, use local order spec
		m_pos->AddRef();
		pos = m_pos;
	}

	// extract sort columns from order spec
	CColRefSet *pcrs = pos->PcrsUsed(mp);

	// get key collection of the relational child
	CKeyCollection *pkc = exprhdl.DeriveKeyCollection(0);

	if (NULL != pkc && pkc->FKey(pcrs, false /*fExactMatch*/))
	{
		CColRefSet *pcrsReqd = posRequired->PcrsUsed(m_mp);
		BOOL fUsesDefinedCols = FUnaryUsesDefinedColumns(pcrsReqd, exprhdl);
		pcrsReqd->Release();

		if (!fUsesDefinedCols)
		{
			// we are grouping on child's key,
			// stream agg does not need to sort child and we can pass through input spec
			pos->Release();
			posRequired->AddRef();
			pos = posRequired;
		}
	}
	pcrs->Release();

	return pos;
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalStreamAgg::PosDerive
//
//	@doc:
//		Derive sort order
//
//---------------------------------------------------------------------------
COrderSpec *
CPhysicalStreamAgg::PosDerive
	(
	CMemoryPool *, // mp
	CExpressionHandle &exprhdl
	)
	const
{
	return PosDerivePassThruOuter(exprhdl);
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalStreamAgg::EpetOrder
//
//	@doc:
//		Return the enforcing type for order property based on this operator
//
//---------------------------------------------------------------------------
CEnfdProp::EPropEnforcingType
CPhysicalStreamAgg::EpetOrder
	(
	CExpressionHandle &exprhdl,
	const CEnfdOrder *peo
	)
	const
{
	GPOS_ASSERT(NULL != peo);
	GPOS_ASSERT(!peo->PosRequired()->IsEmpty());

	// get the order delivered by the stream agg node
	COrderSpec *pos = CDrvdPropPlan::Pdpplan(exprhdl.Pdp())->Pos();
	if (peo->FCompatible(pos))
	{
		// required order will be established by the stream agg operator
		return CEnfdProp::EpetUnnecessary;
	}

	// required order will be enforced on limit's output
	return CEnfdProp::EpetRequired;
}

// EOF


text:
package com.a21vianet.quincysx.library.crypto.converters;

public class EndianConverter {

    /**
     * Switches between little and big endian byte orders
     *
     * @param hex hex-encoded string
     * @return hex-encoded string with switched byte order
     */
    public static String switchEndianness(final String hex) {
        int lengthInBytes = hex.length() / 2;
        char[] chars = new char[hex.length()];
        for (int index = 0; index < lengthInBytes; index++) {
            int reversedIndex = lengthInBytes - 1 - index;
            chars[reversedIndex * 2] = hex.charAt(index * 2);
            chars[reversedIndex * 2 + 1] = hex.charAt(index * 2 + 1);
        }
        return new String(chars);
    }
}

redpajama_set_name: RedPajamaGithub


text:
package multiline

import (
	"regexp"
	"strings"
	"sync"
	"testing"
	"time"

	"github.com/fsouza/go-dockerclient"
	"github.com/gliderlabs/logspout/router"
)

type dummyAdapter struct {
	messages []*router.Message
	*sync.WaitGroup
}

type testData struct {
	input          []string
	expected       []string
	pattern        *regexp.Regexp
	matchFirstLine bool
	negateMatch    bool
}

type envTestData struct {
	env      []string
	def      bool
	expected bool
}

func (da *dummyAdapter) Stream(logstream chan *router.Message) {
	for m := range logstream {
		da.messages = append(da.messages, m)
	}
	da.Done()
}

func TestMultiline(t *testing.T) {
	tests := []*testData{
		{
			input: []string{
				"some",
				"  multi",
				"  line",
				"other",
				"  multiline",
			},
			expected: []string{
				"some\n  multi\n  line",
				"other\n  multiline",
			},
			pattern:        regexp.MustCompile(`^\s`),
			matchFirstLine: true,
			negateMatch:    true,
		},
		{
			input: []string{
				"some:",
				"multi",
				"line",
				"other:",
				"multiline",
			},
			expected: []string{
				"some:\nmulti\nline",
				"other:\nmultiline",
			},
			pattern:        regexp.MustCompile(`:$`),
			matchFirstLine: true,
			negateMatch:    false,
		},
		{
			input: []string{
				"some$",
				"multi$",
				"line",
				"other$",
				"multiline",
			},
			expected: []string{
				"some$\nmulti$\nline",
				"other$\nmultiline",
			},
			pattern:        regexp.MustCompile(`\$$`),
			matchFirstLine: false,
			negateMatch:    true,
		},
		{
			input: []string{
				"some",
				"multi",
				"line!",
				"other",
				"multiline!",
			},
			expected: []string{
				"some\nmulti\nline!",
				"other\nmultiline!",
			},
			pattern:        regexp.MustCompile(`!$`),
			matchFirstLine: false,
			negateMatch:    false,
		},
		{
			input: []string{
				"not yet",
				"Traceback",
				" tb1",
				" tb2!",
				"Error123",
				"no more traceback",
				"STATEMENT:",
				" still statement",
				"end of statement",
				"no more statement",
			},
			expected: []string{
				"not yet",
				"Traceback\n tb1\n tb2!\nError123",
				"no more traceback",
				"STATEMENT:\n still statement\nend of statement",
				"no more statement",
			},
			pattern:        regexp.MustCompile(`^(DETAIL:|STATEMENT:|Traceback|\s)`),
			matchFirstLine: false,
			negateMatch:    true,
		},
	}

	for _, test := range tests {
		in := make(chan *router.Message)
		out := make(chan *router.Message)
		container := &docker.Container{
			ID:     "test",
			Config: &docker.Config{},
		}

		da := &dummyAdapter{make([]*router.Message, 0), &sync.WaitGroup{}}
		da.Add(1)

		ma := &Adapter{
			out:             out,
			subAdapter:      da,
			enableByDefault: true,
			pattern:         test.pattern,
			matchFirstLine:  test.matchFirstLine,
			negateMatch:     test.negateMatch,
			flushAfter:      time.Second * 10,
			checkInterval:   time.Millisecond * 100,
			buffers:         make(map[string]*router.Message),
			nextCheck:       time.After(time.Millisecond * 100),
			separator:       "\n",
		}

		go ma.Stream(in)

		for _, i := range test.input {
			in <- &router.Message{
				Container: container,
				Data:      i,
				Source:    "stdout",
				Time:      time.Now(),
			}
		}

		close(in)
		da.Wait()

		for i, m := range da.messages {
			if m.Data != test.expected[i] {
				t.Errorf("Expected: '%v', Got: '%v'", replaceNewLines(test.expected[i]), replaceNewLines(m.Data))
			}
		}
	}
}

func TestContainerEnv(t *testing.T) {
	tests := []envTestData{
		{
			def:      true,
			env:      []string{},
			expected: true,
		},
		{
			def:      false,
			env:      []string{},
			expected: false,
		},
		{
			def:      true,
			env:      []string{"LOGSPOUT_MULTILINE=true"},
			expected: true,
		},
		{
			def:      false,
			env:      []string{"LOGSPOUT_MULTILINE=true"},
			expected: true,
		},
		{
			def:      true,
			env:      []string{"LOGSPOUT_MULTILINE=false"},
			expected: false,
		},
		{
			def:      false,
			env:      []string{"LOGSPOUT_MULTILINE=false"},
			expected: false,
		},
	}

	for _, test := range tests {
		container := &docker.Container{
			ID: "test",
			Config: &docker.Config{
				Env: test.env,
			},
		}

		result := multilineContainer(container, test.def)

		if result != test.expected {
			t.Errorf("Expected: %v, Got: %v, env: %v", test.expected, result, test.env)
		}
	}
}

func replaceNewLines(str string) string {
	return strings.Replace(str, "\n", "\\n", -1)
}


text:
(function() {
    'use strict';

    function TvPopular(TvPopularService){
        return {
            restrict: 'EA',
            replace: true,
            templateUrl: './src/app/components/tvPopular/template.html',
            scope: {
                filter: "@",
                page: "@"
            },
            controllerAs: 'vm',
            bindToController: true,
            /*jshint unused:false*/
            controller: function($log, TvPopularService, $stateParams) {
                var vm = this;
                var filter = vm.filter;
                var page = $stateParams.page ? Number($stateParams.page) : 1;
                var pageToLoad = page + 1;
                var pageToReload = page - 1;
                TvPopularService.getMovie(page).then(function(data) {
                    vm.populartvs = filter > 0 ? _.slice(data.data.results, 0, filter) : data.data.results;
                    vm.page = page;
                    if(data.data.total_pages > page) vm.pageToLoad = pageToLoad;
                    vm.pageToReload = pageToReload;
                    vm.filter = filter ;
                });
            },
            link: function(scope, elm, attrs){
                scope.goBack = function() {
                    window.history.back();
                };
            }
        };
    }

    angular.module('tvPopularDirective', ['service.populartv'])
        .directive('tvPopular', TvPopular);

})();


text:
<!--This file is generated-->

# remark-lint-no-duplicate-headings-in-section

[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]

[`remark-lint`][mono] rule to warn when headings with the same text are used
multiple times per section.

## Contents

*   [What is this?](#what-is-this)
*   [When should I use this?](#when-should-i-use-this)
*   [Presets](#presets)
*   [Install](#install)
*   [Use](#use)
*   [API](#api)
    *   [`unified().use(remarkLintNoDuplicateHeadingsInSection[, config])`](#unifieduseremarklintnoduplicateheadingsinsection-config)
*   [Recommendation](#recommendation)
*   [Examples](#examples)
*   [Compatibility](#compatibility)
*   [Contribute](#contribute)
*   [License](#license)

## What is this?

This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
rule.
Lint rules check markdown code style.

## When should I use this?

You can use this package to check that headings with the same text are
used once per section.

## Presets

This rule is not included in a preset maintained here.

## Install

This package is [ESM only][esm].
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:

```sh
npm install remark-lint-no-duplicate-headings-in-section
```

In Deno with [Skypack][]:

```js
import remarkLintNoDuplicateHeadingsInSection from 'https://cdn.skypack.dev/remark-lint-no-duplicate-headings-in-section@3?dts'
```

In browsers with [Skypack][]:

```html
<script type="module">
  import remarkLintNoDuplicateHeadingsInSection from 'https://cdn.skypack.dev/remark-lint-no-duplicate-headings-in-section@3?min'
</script>
```

## Use

On the API:

```js
import {read} from 'to-vfile'
import {reporter} from 'vfile-reporter'
import {remark} from 'remark'
import remarkLint from 'remark-lint'
import remarkLintNoDuplicateHeadingsInSection from 'remark-lint-no-duplicate-headings-in-section'

main()

async function main() {
  const file = await remark()
    .use(remarkLint)
    .use(remarkLintNoDuplicateHeadingsInSection)
    .process(await read('example.md'))

  console.error(reporter(file))
}
```

On the CLI:

```sh
remark --use remark-lint --use remark-lint-no-duplicate-headings-in-section example.md
```

On the CLI in a config file (here a `package.json`):

```diff
 …
 "remarkConfig": {
   "plugins": [
     …
     "remark-lint",
+    "remark-lint-no-duplicate-headings-in-section",
     …
   ]
 }
 …
```

## API

This package exports no identifiers.
The default export is `remarkLintNoDuplicateHeadingsInSection`.

### `unified().use(remarkLintNoDuplicateHeadingsInSection[, config])`

This rule supports standard configuration that all remark lint rules accept
(such as `false` to turn it off or `[1, options]` to configure it).

There are no options.

## Recommendation

It's likely a mistake that the same heading text is used in the same
section.

## Examples

##### `ok.md`

###### In

```markdown
## Alpha

### Bravo

## Charlie

### Bravo

### Delta

#### Bravo

#### Echo

##### Bravo
```

###### Out

No messages.

##### `not-ok.md`

###### In

```markdown
## Foxtrot

### Golf

### Golf
```

###### Out

```text
5:1-5:9: Do not use headings with similar content per section (3:1)
```

##### `not-ok-tolerant-heading-increment.md`

###### In

```markdown
# Alpha

#### Bravo

###### Charlie

#### Bravo

###### Delta
```

###### Out

```text
7:1-7:11: Do not use headings with similar content per section (3:1)
```

## Compatibility

Projects maintained by the unified collective are compatible with all maintained
versions of Node.js.
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
Our projects sometimes work with older versions, but this is not guaranteed.

## Contribute

See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
to get started.
See [`support.md`][support] for ways to get help.

This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.

## License

[MIT][license] © [Titus Wormer][author]

[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg

[build]: https://github.com/remarkjs/remark-lint/actions

[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg

[coverage]: https://codecov.io/github/remarkjs/remark-lint

[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-no-duplicate-headings-in-section.svg

[downloads]: https://www.npmjs.com/package/remark-lint-no-duplicate-headings-in-section

[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-no-duplicate-headings-in-section.svg

[size]: https://bundlephobia.com/result?p=remark-lint-no-duplicate-headings-in-section

[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg

[backers-badge]: https://opencollective.com/unified/backers/badge.svg

[collective]: https://opencollective.com/unified

[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg

[chat]: https://github.com/remarkjs/remark/discussions

[unified]: https://github.com/unifiedjs/unified

[remark]: https://github.com/remarkjs/remark

[mono]: https://github.com/remarkjs/remark-lint

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[skypack]: https://www.skypack.dev

[npm]: https://docs.npmjs.com/cli/install

[health]: https://github.com/remarkjs/.github

[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md

[support]: https://github.com/remarkjs/.github/blob/main/support.md

[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md

[license]: https://github.com/remarkjs/remark-lint/blob/main/license

[author]: https://wooorm.com


text:
Wrapper for the jquery fg menu widget of the filament group.
Provides a menu with Dropdown, iPod Drilldown, and Flyout styles with ARIA Support and ThemeRoller Ready
http://www.filamentgroup.com/lab/jquery_ipod_style_and_flyout_menus/

## Installation

Add this line to your application's Gemfile:

    gem 'jquery-fg-menu-rails', github: 'JoostVanAverbeke/jquery-fg-menu-rails'

And then execute:

    $ bundle install

## Usage

And include in your applications.js

	//=require fg.menu

You definitly need to install the jquery 1.3.2 or higher in your rails application.
Just for your information, this can be easily be realized by adding this line to your application's Gemfile

	gem 'jquery-rails'

And then execute again:

	$ bundle install

Include in your application.css

	*=require fg.menu

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request


text:
'use strict';

const path = require('path');
const sinon = require('sinon');
const editor = require('..');
const memFs = require('mem-fs');
const escape = require('escape-regexp');

describe('#readJSON()', () => {
  let store;
  let fs;

  beforeEach(() => {
    store = memFs.create();
    fs = editor.create(store);
  });

  it('read the content of a file', () => {
    const obj = fs.readJSON(path.join(__dirname, 'fixtures/file.json'));
    expect(obj.foo).toBe('bar');
  });

  it('calls read() with path', () => {
    const read = sinon.spy(fs, 'read');
    const file = path.join(__dirname, 'fixtures/file.json');
    fs.readJSON(file);
    sinon.assert.calledOnce(read);
    sinon.assert.calledWith(read, file);
    read.restore();
  });

  it('return defaults if file does not exist and defaults is provided', () => {
    const obj = fs.readJSON(path.join(__dirname, 'no-such-file.json'), {foo: 'bar'});
    expect(obj.foo).toBe('bar');
  });

  it('throw error if file could not be parsed as JSON, even if defaults is provided', () => {
    expect(fs.readJSON.bind(fs, path.join(__dirname, 'fixtures/file-tpl.txt'), {foo: 'bar'})).toThrow();
  });

  it('throw error with file path info', () => {
    var filePath = path.join(__dirname, 'fixtures/file-tpl.txt');
    expect(fs.readJSON.bind(fs, filePath), new RegExp(escape(filePath))).toThrow();
  });
});


text:
package org.kie.workbench.common.dmn.api.definition.model;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;

import org.kie.workbench.common.dmn.api.definition.HasComponentWidths;
import org.kie.workbench.common.dmn.api.definition.HasTypeRef;
import org.kie.workbench.common.dmn.api.property.dmn.Description;
import org.kie.workbench.common.dmn.api.property.dmn.Id;
import org.kie.workbench.common.dmn.api.property.dmn.QName;

import static java.util.Collections.singletonList;

public abstract class Expression extends DMNElement implements HasTypeRef,
                                                               HasComponentWidths {

    protected QName typeRef;

    protected java.util.List<Double> componentWidths = new ArrayList<>();

    public Expression() {
    }

    public Expression(final Id id,
                      final Description description,
                      final QName typeRef) {
        super(id,
              description);
        this.typeRef = typeRef;
    }

    /**
     * It represents a contract for all subclasses of {@link Expression}.
     * Its purpose is to exploit polymorphism when we deeply copy the Expression boxed inside the {@link Decision}
     */
    public abstract Expression copy();

    // -----------------------
    // DMN properties
    // -----------------------

    @Override
    public QName getTypeRef() {
        return typeRef;
    }

    @Override
    public void setTypeRef(final QName typeRef) {
        this.typeRef = typeRef;
    }

    @Override
    public java.util.List<Double> getComponentWidths() {
        final int requiredComponentWidthCount = getRequiredComponentWidthCount();
        if (componentWidths.size() != requiredComponentWidthCount) {
            componentWidths = new ArrayList<>(requiredComponentWidthCount);
            IntStream.range(0, requiredComponentWidthCount).forEach(i -> componentWidths.add(null));
        }
        return componentWidths;
    }

    @Override
    public DMNModelInstrumentedBase asDMNModelInstrumentedBase() {
        return this;
    }

    @Override
    public List<HasTypeRef> getHasTypeRefs() {
        return new ArrayList<>(singletonList(this));
    }
}


text:
set -ueo pipefail

UNSTABLE=${UNSTABLE:-0}
BETA=${BETA:-0}

REPO_HOST=https://repos.insights.digitalocean.com
REPO_GPG_KEY=${REPO_HOST}/sonar-agent.asc
REPO_GPG_KEY_CURRENT=${REPO_HOST}/sonar-agent-current.asc

repo="do-agent"
[ "${UNSTABLE}" != 0 ] && repo="do-agent-unstable"
[ "${BETA}" != 0 ] && repo="do-agent-beta"

dist="unknown"
deb_list=/etc/apt/sources.list.d/digitalocean-agent.list
rpm_repo=/etc/yum.repos.d/digitalocean-agent.repo

function main() {
	[ "$(id -u)" != "0" ] && \
		abort "This script must be executed as root."

	clean
	check_do
	check_dist

	case "${dist}" in
		debian|ubuntu)
			install_apt
			;;
		centos|cloudlinux|fedora|almalinux|rocky)
			install_rpm
			;;
		*)
			not_supported
			;;
	esac
}

function wait_for_apt() {
	while fuser /var/{lib/{dpkg,apt/lists},cache/apt/archives}/lock >/dev/null 2>&1; do
		echo "Waiting on apt.."
		sleep 2
	done
}

function install_apt() {
	export DEBIAN_FRONTEND=noninteractive
	# forcefully remove any existing installations
	wait_for_apt && ( apt-get purge -y do-agent >/dev/null 2>&1 || : )

	echo "Installing apt repository..."
	wait_for_apt && ( apt-get -qq update || true )
	wait_for_apt && apt-get -qq install -y ca-certificates gnupg2 apt-utils apt-transport-https curl
	echo "deb ${REPO_HOST}/apt/${repo} main main" > /etc/apt/sources.list.d/digitalocean-agent.list
	echo -n "Installing gpg key..."
	curl -sL "${REPO_GPG_KEY}" | apt-key add -
	curl -sL "${REPO_GPG_KEY_CURRENT}" | apt-key add -
	wait_for_apt && apt-get -qq update -o Dir::Etc::SourceParts=/dev/null -o APT::Get::List-Cleanup=no -o Dir::Etc::SourceList="sources.list.d/digitalocean-agent.list"
	wait_for_apt && apt-get -qq install -y do-agent
}

function install_rpm() {
	echo "Installing yum repository..."

	# forcefully remove any existing installations
	yum remove -y do-agent || :

	yum install -y gpgme ca-certificates

	cat <<-EOF > /etc/yum.repos.d/digitalocean-agent.repo
	[digitalocean-agent]
	name=DigitalOcean Agent
	baseurl=${REPO_HOST}/yum/${repo}/\$basearch
	repo_gpgcheck=0
	gpgcheck=1
	enabled=1
	gpgkey=${REPO_GPG_KEY}
	sslverify=0
	sslcacert=/etc/pki/tls/certs/ca-bundle.crt
	metadata_expire=300
	EOF

	rpm --import "${REPO_GPG_KEY_CURRENT}"

	yum --disablerepo="*" --enablerepo="digitalocean-agent" makecache
	yum install -y do-agent
}

function clean() {
	echo -n "Cleaning up old sources..."
	if [ -f "$deb_list" ]; then
		rm -f "${deb_list}"
	elif [ -f "$rpm_repo" ]; then
		rm -f "${rpm_repo}"
	fi
	echo "OK"
}

function check_dist() {
	echo -n "Verifying compatibility with script..."
	if [  -f /etc/os-release  ]; then
		dist=$(awk -F= '$1 == "ID" {gsub("\"", ""); print$2}' /etc/os-release)
	elif [ -f /etc/redhat-release ]; then
		dist=$(awk '{print tolower($1)}' /etc/redhat-release)
	else
		not_supported
	fi

	dist=$(echo "${dist}" | tr '[:upper:]' '[:lower:]')

	case "${dist}" in
		debian|ubuntu|centos|fedora|rocky)
			echo "OK"
			;;
		cloudlinux|almalinux)
			echo "WARN ${dist} is not officially supported. Attempting RPM install"
			;;
		*)
			not_supported
			;;
	esac
}

function check_do() {
	echo -n "Verifying machine compatibility..."
	# DigitalOcean embedded platform information in the DMI data.
	read -r sys_vendor < /sys/devices/virtual/dmi/id/bios_vendor
	if ! [ "$sys_vendor" = "DigitalOcean" ]; then
		cat <<-EOF

		The DigitalOcean Agent is only supported on DigitalOcean machines.

		If you are seeing this message on an older droplet, you may need to power-off
		and then power-on at http://cloud.digitalocean.com. After power-cycling,
		please re-run this script.

		EOF
		exit 1
	fi
	echo "OK"
}

function not_supported() {
	cat <<-EOF

	This script does not support the OS/Distribution on this machine.
	If you feel that this is an error contact support@digitalocean.com
	or create an issue at https://github.com/digitalocean/do-agent/issues/new.

	EOF
	exit 1
}

# abort with an error message
function abort() {
	read -r line func file <<< "$(caller 0)"
	echo "ERROR in $file:$func:$line: $1" > /dev/stderr
	exit 1
}

# leave this last to prevent any partial execution
main


text:
namespace ui {

WaylandEventWatcherFdWatch::WaylandEventWatcherFdWatch(
    wl_display* display,
    wl_event_queue* event_queue)
    : WaylandEventWatcher(display, event_queue), controller_(FROM_HERE) {}

WaylandEventWatcherFdWatch::~WaylandEventWatcherFdWatch() {
  StopProcessingEvents();
}

bool WaylandEventWatcherFdWatch::StartWatchingFD(int fd) {
  DCHECK(base::CurrentUIThread::IsSet());
  WlDisplayPrepareToRead();
  return base::CurrentUIThread::Get()->WatchFileDescriptor(
      fd, true, base::MessagePumpForUI::WATCH_READ, &controller_, this);
}

void WaylandEventWatcherFdWatch::StopWatchingFD() {
  DCHECK(base::CurrentUIThread::IsSet());
  CHECK(controller_.StopWatchingFileDescriptor())
      << "Unable to stop watching the Wayland display fd.";
}

void WaylandEventWatcherFdWatch::OnFileCanReadWithoutBlocking(int fd) {
  // All the error checking and conditions to read are handled by the base
  // class. See https://bit.ly/3tCjobF to get an idea how it works.
  //
  // TODO(1288181): once libevent is updated to the newest version, use watcher
  // callbacks that notify clients about intention to sleep/poll or about bytes
  // available to be read so that we are able to correctly call all these
  // methods. At the moment, they are constantly called whenever there is
  // something to read, which is inefficient. See WaylandEventWatcherGlib for
  // example.
  WlDisplayReadEvents();
  WlDisplayDispatchPendingQueue();

  // If prepare failed, dispatch the events once again.
  if (!WlDisplayPrepareToRead())
    WlDisplayDispatchPendingQueue();
}

void WaylandEventWatcherFdWatch::OnFileCanWriteWithoutBlocking(int fd) {
  NOTREACHED();
}

// static
std::unique_ptr<WaylandEventWatcher>
WaylandEventWatcher::CreateWaylandEventWatcher(wl_display* display,
                                               wl_event_queue* event_queue) {
  return std::make_unique<WaylandEventWatcherFdWatch>(display, event_queue);
}

}  // namespace ui


text:
set -e

M4_VERSION_FILE='m4/version.m4'
M4_VERSION_SET_FILE='m4/version-set.m4'

# Relocate to the top level project directory.
cd $(dirname ${0})/..

# Try and work out what the new version should be.
version_major=0
version_minor=0
version_patch=0
current_version_string='unknown'
if test -f ${M4_VERSION_SET_FILE}; then
  version_major=$(grep '^VERSION_MAJOR=' ${M4_VERSION_SET_FILE} | cut -d = -f 2)
  version_minor=$(($(grep '^VERSION_MINOR=' ${M4_VERSION_SET_FILE} | cut -d = -f 2) + 1))
  version_patch=0
  current_version_string=$(grep '^VERSION_STRING=' ${M4_VERSION_SET_FILE} | cut -d = -f 2)
fi
if [[ ${#} -ne 0 ]]; then
  version_major=${1}
  shift
fi
if [[ ${#} -ne 0 ]]; then
  version_minor=${1}
  shift
fi
if [[ ${#} -ne 0 ]]; then
  version_patch=${1}
  shift
fi
version_date="$(date +%Y-%m-%d)"
version="${version_major}.${version_minor}.${version_patch}"
version_string="'\"${version} (${version_date})\"'"

# Confirm before going ahead.
echo "Current version: ${current_version_string}"
echo "    New version: ${version_string}"
read -r -p 'Are you sure? [y/N] ' response
if [[ ${response} =~ ^([yY][eE][sS]|[yY])$ ]]; then
  true
else
  exit 0
fi

# Create the release branch.
git checkout -b release-${version} develop

# Bump the version and commit the change.
./dist/bump-version.sh ${version_major} ${version_minor} ${version_patch} "${version_date}"
git commit -a -m "Bumped version to ${version}."

echo "Release branch successfully created and the version has been bumped to ${version}."
echo "Once you're ready to release, call dist/finish-release-branch.sh."


text:
<?php
/* SVN FILE: $Id$ */
/**
 * DispatcherTest file
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
 * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
 *
 *  Licensed under The Open Group Test Suite License
 *  Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright     Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
 * @link          https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
 * @package       cake
 * @subpackage    cake.tests.cases
 * @since         CakePHP(tm) v 1.2.0.4206
 * @version       $Revision$
 * @modifiedby    $LastChangedBy$
 * @lastmodified  $Date$
 * @license       http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
 */
require_once CAKE.'dispatcher.php';
App::import('Core', 'AppController');
/**
 * TestDispatcher class
 *
 * @package       cake
 * @subpackage    cake.tests.cases
 */
class TestDispatcher extends Dispatcher {
/**
 * invoke method
 *
 * @param mixed $controller
 * @param mixed $params
 * @param mixed $missingAction
 * @access protected
 * @return void
 */
	function _invoke(&$controller, $params) {
		restore_error_handler();
		if ($result = parent::_invoke($controller, $params)) {
			if ($result[0] === 'missingAction') {
				return $result;
			}
		}
		set_error_handler('simpleTestErrorHandler');

		return $controller;
	}
/**
 * cakeError method
 *
 * @param mixed $filename
 * @access public
 * @return void
 */
	function cakeError($filename, $params) {
		return array($filename, $params);
	}
/**
 * _stop method
 *
 * @access protected
 * @return void
 */
	function _stop() {
		return true;
	}
}
/**
 * MyPluginAppController class
 *
 * @package       cake
 * @subpackage    cake.tests.cases
 */
class MyPluginAppController extends AppController {
}
/**
 * MyPluginController class
 *
 * @package       cake
 * @subpackage    cake.tests.cases
 */
class MyPluginController extends MyPluginAppController {
/**
 * name property
 *
 * @var string 'MyPlugin'
 * @access public
 */
	var $name = 'MyPlugin';
/**
 * uses property
 *
 * @var array
 * @access public
 */
	var $uses = array();
/**
 * index method
 *
 * @access public
 * @return void
 */
	function index() {
		return true;
	}
/**
 * add method
 *
 * @access public
 * @return void
 */
	function add() {
		return true;
	}
/**
 * admin_add method
 *
 * @param mixed $id
 * @access public
 * @return void
 */
	function admin_add($id = null) {
		return $id;
	}
}
/**
 * SomePagesController class
 *
 * @package       cake
 * @subpackage    cake.tests.cases
 */
class SomePagesController extends AppController {
/**
 * name property
 *
 * @var string 'SomePages'
 * @access public
 */
	var $name = 'SomePages';
/**
 * uses property
 *
 * @var array
 * @access public
 */
	var $uses = array();
/**
 * display method
 *
 * @param mixed $page
 * @access public
 * @return void
 */
	function display($page = null) {
		return $page;
	}
/**
 * index method
 *
 * @access public
 * @return void
 */
	function index() {
		return true;
	}
/**
 * protected method
 *
 * @access protected
 * @return void
 */
	function _protected() {
		return true;
	}
/**
 * redirect method overriding
 *
 * @access public
 * @return void
 */
	function redirect() {
		echo 'this should not be accessible';
	}
}
/**
 * OtherPagesController class
 *
 * @package       cake
 * @subpackage    cake.tests.cases
 */
class OtherPagesController extends MyPluginAppController {
/**
 * name property
 *
 * @var string 'OtherPages'
 * @access public
 */
	var $name = 'OtherPages';
/**
 * uses property
 *
 * @var array
 * @access public
 */
	var $uses = array();
/**
 * display method
 *
 * @param mixed $page
 * @access public
 * @return void
 */
	function display($page = null) {
		return $page;
	}
/**
 * index method
 *
 * @access public
 * @return void
 */
	function index() {
		return true;
	}
}
/**
 * TestDispatchPagesController class
 *
 * @package       cake
 * @subpackage    cake.tests.cases
 */
class TestDispatchPagesController extends AppController {
/**
 * name property
 *
 * @var string 'TestDispatchPages'
 * @access public
 */
	var $name = 'TestDispatchPages';
/**
 * uses property
 *
 * @var array
 * @access public
 */
	var $uses = array();
/**
 * admin_index method
 *
 * @access public
 * @return void
 */
	function admin_index() {
		return true;
	}
/**
 * camelCased method
 *
 * @access public
 * @return void
 */
	function camelCased() {
		return true;
	}
}
/**
 * ArticlesTestAppController class
 *
 * @package       cake
 * @subpackage    cake.tests.cases
 */
class ArticlesTestAppController extends AppController {
}
/**
 * ArticlesTestController class
 *
 * @package       cake
 * @subpackage    cake.tests.cases
 */
class ArticlesTestController extends ArticlesTestAppController {
/**
 * name property
 *
 * @var string 'ArticlesTest'
 * @access public
 */
	var $name = 'ArticlesTest';
/**
 * uses property
 *
 * @var array
 * @access public
 */
	var $uses = array();
/**
 * admin_index method
 *
 * @access public
 * @return void
 */
	function admin_index() {
		return true;
	}
}
/**
 * SomePostsController class
 *
 * @package       cake
 * @subpackage    cake.tests.cases
 */
class SomePostsController extends AppController {
/**
 * name property
 *
 * @var string 'SomePosts'
 * @access public
 */
	var $name = 'SomePosts';
/**
 * uses property
 *
 * @var array
 * @access public
 */
	var $uses = array();
/**
 * autoRender property
 *
 * @var bool false
 * @access public
 */
	var $autoRender = false;
/**
 * beforeFilter method
 *
 * @access public
 * @return void
 */
	function beforeFilter() {
		if ($this->params['action'] == 'index') {
			$this->params['action'] = 'view';
		} else {
			$this->params['action'] = 'change';
		}
		$this->params['pass'] = array('changed');
	}
/**
 * index method
 *
 * @access public
 * @return void
 */
	function index() {
		return true;
	}
/**
 * change method
 *
 * @access public
 * @return void
 */
	function change() {
		return true;
	}
}
/**
 * TestCachedPagesController class
 *
 * @package       cake
 * @subpackage    cake.tests.cases
 */
class TestCachedPagesController extends AppController {
/**
 * name property
 *
 * @var string 'TestCachedPages'
 * @access public
 */
	var $name = 'TestCachedPages';
/**
 * uses property
 *
 * @var array
 * @access public
 */
	var $uses = array();
/**
 * helpers property
 *
 * @var array
 * @access public
 */
	var $helpers = array('Cache');
/**
 * cacheAction property
 *
 * @var array
 * @access public
 */
	var $cacheAction = array(
		'index'=> '+2 sec', 'test_nocache_tags'=>'+2 sec',
		'view/' => '+2 sec'
	);
/**
 * viewPath property
 *
 * @var string 'posts'
 * @access public
 */
	var $viewPath = 'posts';
/**
 * index method
 *
 * @access public
 * @return void
 */
	function index() {
		$this->render();
	}
/**
 * test_nocache_tags method
 *
 * @access public
 * @return void
 */
	function test_nocache_tags() {
		$this->render();
	}
/**
 * view method
 *
 * @access public
 * @return void
 */
	function view($id = null) {
		$this->render('index');
	}
}
/**
 * TimesheetsController class
 *
 * @package       cake
 * @subpackage    cake.tests.cases
 */
class TimesheetsController extends AppController {
/**
 * name property
 *
 * @var string 'Timesheets'
 * @access public
 */
	var $name = 'Timesheets';
/**
 * uses property
 *
 * @var array
 * @access public
 */
	var $uses = array();
/**
 * index method
 *
 * @access public
 * @return void
 */
	function index() {
		return true;
	}
}
/**
 * DispatcherTest class
 *
 * @package       cake
 * @subpackage    cake.tests.cases
 */
class DispatcherTest extends CakeTestCase {
/**
 * setUp method
 *
 * @access public
 * @return void
 */
	function setUp() {
		$this->_get = $_GET;
		$_GET = array();
		Configure::write('App.base', false);
		Configure::write('App.baseUrl', false);
		Configure::write('App.dir', 'app');
		Configure::write('App.webroot', 'webroot');
		Configure::write('Cache.disable', true);
	}
/**
 * tearDown method
 *
 * @access public
 * @return void
 */
	function tearDown() {
		$_GET = $this->_get;
	}
/**
 * testParseParamsWithoutZerosAndEmptyPost method
 *
 * @access public
 * @return void
 */
	function testParseParamsWithoutZerosAndEmptyPost() {
		$Dispatcher =& new Dispatcher();
		$test = $Dispatcher->parseParams("/testcontroller/testaction/params1/params2/params3");
		$this->assertIdentical($test['controller'], 'testcontroller');
		$this->assertIdentical($test['action'], 'testaction');
		$this->assertIdentical($test['pass'][0], 'params1');
		$this->assertIdentical($test['pass'][1], 'params2');
		$this->assertIdentical($test['pass'][2], 'params3');
		$this->assertFalse(!empty($test['form']));
	}
/**
 * testParseParamsReturnsPostedData method
 *
 * @access public
 * @return void
 */
	function testParseParamsReturnsPostedData() {
		$_POST['testdata'] = "My Posted Content";
		$Dispatcher =& new Dispatcher();
		$test = $Dispatcher->parseParams("/");
		$this->assertTrue($test['form'], "Parsed URL not returning post data");
		$this->assertIdentical($test['form']['testdata'], "My Posted Content");
	}
/**
 * testParseParamsWithSingleZero method
 *
 * @access public
 * @return void
 */
	function testParseParamsWithSingleZero() {
		$Dispatcher =& new Dispatcher();
		$test = $Dispatcher->parseParams("/testcontroller/testaction/1/0/23");
		$this->assertIdentical($test['controller'], 'testcontroller');
		$this->assertIdentical($test['action'], 'testaction');
		$this->assertIdentical($test['pass'][0], '1');
		$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][1]);
		$this->assertIdentical($test['pass'][2], '23');
	}
/**
 * testParseParamsWithManySingleZeros method
 *
 * @access public
 * @return void
 */
	function testParseParamsWithManySingleZeros() {
		$Dispatcher =& new Dispatcher();
		$test = $Dispatcher->parseParams("/testcontroller/testaction/0/0/0/0/0/0");
		$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][0]);
		$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][1]);
		$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][2]);
		$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][3]);
		$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][4]);
		$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][5]);
	}
/**
 * testParseParamsWithManyZerosInEachSectionOfUrl method
 *
 * @access public
 * @return void
 */
	function testParseParamsWithManyZerosInEachSectionOfUrl() {
		$Dispatcher =& new Dispatcher();
		$test = $Dispatcher->parseParams("/testcontroller/testaction/000/0000/00000/000000/000000/0000000");
		$this->assertPattern('/\\A(?:000)\\z/', $test['pass'][0]);
		$this->assertPattern('/\\A(?:0000)\\z/', $test['pass'][1]);
		$this->assertPattern('/\\A(?:00000)\\z/', $test['pass'][2]);
		$this->assertPattern('/\\A(?:000000)\\z/', $test['pass'][3]);
		$this->assertPattern('/\\A(?:000000)\\z/', $test['pass'][4]);
		$this->assertPattern('/\\A(?:0000000)\\z/', $test['pass'][5]);
	}
/**
 * testParseParamsWithMixedOneToManyZerosInEachSectionOfUrl method
 *
 * @access public
 * @return void
 */
	function testParseParamsWithMixedOneToManyZerosInEachSectionOfUrl() {
		$Dispatcher =& new Dispatcher();
		$test = $Dispatcher->parseParams("/testcontroller/testaction/01/0403/04010/000002/000030/0000400");
		$this->assertPattern('/\\A(?:01)\\z/', $test['pass'][0]);
		$this->assertPattern('/\\A(?:0403)\\z/', $test['pass'][1]);
		$this->assertPattern('/\\A(?:04010)\\z/', $test['pass'][2]);
		$this->assertPattern('/\\A(?:000002)\\z/', $test['pass'][3]);
		$this->assertPattern('/\\A(?:000030)\\z/', $test['pass'][4]);
		$this->assertPattern('/\\A(?:0000400)\\z/', $test['pass'][5]);
	}
/**
 * testQueryStringOnRoot method
 *
 * @access public
 * @return void
 */
	function testQueryStringOnRoot() {
		Router::reload();
		Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
		Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));

		$_GET = array('coffee' => 'life', 'sleep' => 'sissies');
		$Dispatcher =& new Dispatcher();
		$uri = 'posts/home/?coffee=life&sleep=sissies';
		$result = $Dispatcher->parseParams($uri);
		$this->assertPattern('/posts/', $result['controller']);
		$this->assertPattern('/home/', $result['action']);
		$this->assertTrue(isset($result['url']['sleep']));
		$this->assertTrue(isset($result['url']['coffee']));

		$Dispatcher =& new Dispatcher();
		$uri = '/?coffee=life&sleep=sissy';
		$result = $Dispatcher->parseParams($uri);
		$this->assertPattern('/pages/', $result['controller']);
		$this->assertPattern('/display/', $result['action']);
		$this->assertTrue(isset($result['url']['sleep']));
		$this->assertTrue(isset($result['url']['coffee']));
		$this->assertEqual($result['url']['coffee'], 'life');

		$_GET = $this->_get;
	}
/**
 * testFileUploadArrayStructure method
 *
 * @access public
 * @return void
 */
	function testFileUploadArrayStructure() {
		$_FILES = array('data' => array('name' => array(
			'File' => array(
				array('data' => 'cake_mssql_patch.patch'),
					array('data' => 'controller.diff'),
					array('data' => ''),
					array('data' => ''),
				),
				'Post' => array('attachment' => 'jquery-1.2.1.js'),
			),
			'type' => array(
				'File' => array(
					array('data' => ''),
					array('data' => ''),
					array('data' => ''),
					array('data' => ''),
				),
				'Post' => array('attachment' => 'application/x-javascript'),
			),
			'tmp_name' => array(
				'File' => array(
					array('data' => '/private/var/tmp/phpy05Ywj'),
					array('data' => '/private/var/tmp/php7MBztY'),
					array('data' => ''),
					array('data' => ''),
				),
				'Post' => array('attachment' => '/private/var/tmp/phpEwlrIo'),
			),
			'error' => array(
				'File' => array(
					array('data' => 0),
					array('data' => 0),
					array('data' => 4),
					array('data' => 4)
				),
				'Post' => array('attachment' => 0)
			),
			'size' => array(
				'File' => array(
					array('data' => 6271),
					array('data' => 350),
					array('data' => 0),
					array('data' => 0),
				),
				'Post' => array('attachment' => 80469)
			),
		));

		$Dispatcher =& new Dispatcher();
		$result = $Dispatcher->parseParams('/');

		$expected = array(
			'File' => array(
				array('data' => array(
					'name' => 'cake_mssql_patch.patch',
					'type' => '',
					'tmp_name' => '/private/var/tmp/phpy05Ywj',
					'error' => 0,
					'size' => 6271,
				),
			),
			array('data' => array(
				'name' => 'controller.diff',
				'type' => '',
				'tmp_name' => '/private/var/tmp/php7MBztY',
				'error' => 0,
				'size' => 350,
			)),
			array('data' => array(
				'name' => '',
				'type' => '',
				'tmp_name' => '',
				'error' => 4,
				'size' => 0,
			)),
			array('data' => array(
				'name' => '',
				'type' => '',
				'tmp_name' => '',
				'error' => 4,
				'size' => 0,
			)),
		),
		'Post' => array('attachment' => array(
			'name' => 'jquery-1.2.1.js',
			'type' => 'application/x-javascript',
			'tmp_name' => '/private/var/tmp/phpEwlrIo',
			'error' => 0,
			'size' => 80469,
		)));
		$this->assertEqual($result['data'], $expected);

		$_FILES = array(
			'data' => array(
				'name' => array(
					'Document' => array(
						1 => array(
							'birth_cert' => 'born on.txt',
							'passport' => 'passport.txt',
							'drivers_license' => 'ugly pic.jpg'
						),
						2 => array(
							'birth_cert' => 'aunt betty.txt',
							'passport' => 'betty-passport.txt',
							'drivers_license' => 'betty-photo.jpg'
						),
					),
				),
				'type' => array(
					'Document' => array(
						1 => array(
							'birth_cert' => 'application/octet-stream',
							'passport' => 'application/octet-stream',
							'drivers_license' => 'application/octet-stream',
						),
						2 => array(
							'birth_cert' => 'application/octet-stream',
							'passport' => 'application/octet-stream',
							'drivers_license' => 'application/octet-stream',
						)
					)
				),
				'tmp_name' => array(
					'Document' => array(
						1 => array(
							'birth_cert' => '/private/var/tmp/phpbsUWfH',
							'passport' => '/private/var/tmp/php7f5zLt',
 							'drivers_license' => '/private/var/tmp/phpMXpZgT',
						),
						2 => array(
							'birth_cert' => '/private/var/tmp/php5kHZt0',
 							'passport' => '/private/var/tmp/phpnYkOuM',
 							'drivers_license' => '/private/var/tmp/php9Rq0P3',
						)
					)
				),
				'error' => array(
					'Document' => array(
						1 => array(
							'birth_cert' => 0,
							'passport' => 0,
 							'drivers_license' => 0,
						),
						2 => array(
							'birth_cert' => 0,
 							'passport' => 0,
 							'drivers_license' => 0,
						)
					)
				),
				'size' => array(
					'Document' => array(
						1 => array(
							'birth_cert' => 123,
							'passport' => 458,
 							'drivers_license' => 875,
						),
						2 => array(
							'birth_cert' => 876,
 							'passport' => 976,
 							'drivers_license' => 9783,
						)
					)
				)
			)
		);
		$Dispatcher =& new Dispatcher();
		$result = $Dispatcher->parseParams('/');
		$expected = array(
			'Document' => array(
				1 => array(
					'birth_cert' => array(
						'name' => 'born on.txt',
						'tmp_name' => '/private/var/tmp/phpbsUWfH',
						'error' => 0,
						'size' => 123,
						'type' => 'application/octet-stream',
					),
					'passport' => array(
						'name' => 'passport.txt',
						'tmp_name' => '/private/var/tmp/php7f5zLt',
						'error' => 0,
						'size' => 458,
						'type' => 'application/octet-stream',
					),
					'drivers_license' => array(
						'name' => 'ugly pic.jpg',
						'tmp_name' => '/private/var/tmp/phpMXpZgT',
						'error' => 0,
						'size' => 875,
						'type' => 'application/octet-stream',
					),
				),
				2 => array(
					'birth_cert' => array(
						'name' => 'aunt betty.txt',
						'tmp_name' => '/private/var/tmp/php5kHZt0',
						'error' => 0,
						'size' => 876,
						'type' => 'application/octet-stream',
					),
					'passport' => array(
						'name' => 'betty-passport.txt',
						'tmp_name' => '/private/var/tmp/phpnYkOuM',
						'error' => 0,
						'size' => 976,
						'type' => 'application/octet-stream',
					),
					'drivers_license' => array(
						'name' => 'betty-photo.jpg',
						'tmp_name' => '/private/var/tmp/php9Rq0P3',
						'error' => 0,
						'size' => 9783,
						'type' => 'application/octet-stream',
					),
				),
			)
		);
		$this->assertEqual($result['data'], $expected);

		$_FILES = array();
	}
/**
 * testGetUrl method
 *
 * @access public
 * @return void
 */
	function testGetUrl() {
		$Dispatcher =& new Dispatcher();
		$Dispatcher->base = '/app/webroot/index.php';
		$uri = '/app/webroot/index.php/posts/add';
		$result = $Dispatcher->getUrl($uri);
		$expected = 'posts/add';
		$this->assertEqual($expected, $result);

		Configure::write('App.baseUrl', '/app/webroot/index.php');

		$uri = '/posts/add';
		$result = $Dispatcher->getUrl($uri);
		$expected = 'posts/add';
		$this->assertEqual($expected, $result);

		$_GET['url'] = array();
		Configure::write('App.base', '/control');
		$Dispatcher =& new Dispatcher();
		$Dispatcher->baseUrl();
		$uri = '/control/students/browse';
		$result = $Dispatcher->getUrl($uri);
		$expected = 'students/browse';
		$this->assertEqual($expected, $result);

		$_GET['url'] = array();
		$Dispatcher =& new Dispatcher();
		$Dispatcher->base = '';
		$uri = '/?/home';
		$result = $Dispatcher->getUrl($uri);
		$expected = '?/home';
		$this->assertEqual($expected, $result);

	}
/**
 * testBaseUrlAndWebrootWithModRewrite method
 *
 * @access public
 * @return void
 */
	function testBaseUrlAndWebrootWithModRewrite() {
		$Dispatcher =& new Dispatcher();

		$Dispatcher->base = false;
		$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches';
		$_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php';
		$_SERVER['PHP_SELF'] = '/1.2.x.x/app/webroot/index.php';
		$result = $Dispatcher->baseUrl();
		$expected = '/1.2.x.x';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/1.2.x.x/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);

		$Dispatcher->base = false;
		$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches/1.2.x.x/app/webroot';
		$_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php';
		$_SERVER['PHP_SELF'] = '/index.php';
		$result = $Dispatcher->baseUrl();
		$expected = '';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);

		$Dispatcher->base = false;
		$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches/1.2.x.x/test/';
		$_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/test/webroot/index.php';
		$_SERVER['PHP_SELF'] = '/webroot/index.php';
		$result = $Dispatcher->baseUrl();
		$expected = '';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);

		$Dispatcher->base = false;;
		$_SERVER['DOCUMENT_ROOT'] = '/some/apps/where';
		$_SERVER['SCRIPT_FILENAME'] = '/some/apps/where/app/webroot/index.php';
		$_SERVER['PHP_SELF'] = '/some/apps/where/app/webroot/index.php';
		$result = $Dispatcher->baseUrl();
		$expected = '/some/apps/where';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/some/apps/where/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);

		Configure::write('App.dir', 'auth');

		$Dispatcher->base = false;;
		$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches';
		$_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/demos/auth/webroot/index.php';
		$_SERVER['PHP_SELF'] = '/demos/auth/webroot/index.php';

		$result = $Dispatcher->baseUrl();
		$expected = '/demos/auth';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/demos/auth/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);

		Configure::write('App.dir', 'code');

		$Dispatcher->base = false;;
		$_SERVER['DOCUMENT_ROOT'] = '/Library/WebServer/Documents';
		$_SERVER['SCRIPT_FILENAME'] = '/Library/WebServer/Documents/clients/PewterReport/code/webroot/index.php';
		$_SERVER['PHP_SELF'] = '/clients/PewterReport/code/webroot/index.php';
		$result = $Dispatcher->baseUrl();
		$expected = '/clients/PewterReport/code';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/clients/PewterReport/code/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
	}
/**
 * testBaseUrlwithModRewriteAlias method
 *
 * @access public
 * @return void
 */
	function testBaseUrlwithModRewriteAlias() {
		$_SERVER['DOCUMENT_ROOT'] = '/home/aplusnur/public_html';
		$_SERVER['SCRIPT_FILENAME'] = '/home/aplusnur/cake2/app/webroot/index.php';
		$_SERVER['PHP_SELF'] = '/control/index.php';

		Configure::write('App.base', '/control');

		$Dispatcher =& new Dispatcher();
		$result = $Dispatcher->baseUrl();
		$expected = '/control';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/control/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);

		Configure::write('App.base', false);
		Configure::write('App.dir', 'affiliate');
		Configure::write('App.webroot', 'newaffiliate');

		$_SERVER['DOCUMENT_ROOT'] = '/var/www/abtravaff/html';
		$_SERVER['SCRIPT_FILENAME'] = '/var/www/abtravaff/html/newaffiliate/index.php';
		$_SERVER['PHP_SELF'] = '/newaffiliate/index.php';
		$Dispatcher =& new Dispatcher();
		$result = $Dispatcher->baseUrl();
		$expected = '/newaffiliate';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/newaffiliate/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
	}
/**
 * testBaseUrlAndWebrootWithBaseUrl method
 *
 * @access public
 * @return void
 */
	function testBaseUrlAndWebrootWithBaseUrl() {
		$Dispatcher =& new Dispatcher();

		Configure::write('App.dir', 'app');

		Configure::write('App.baseUrl', '/app/webroot/index.php');
		$result = $Dispatcher->baseUrl();
		$expected = '/app/webroot/index.php';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/app/webroot/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);

		Configure::write('App.baseUrl', '/app/webroot/test.php');
		$result = $Dispatcher->baseUrl();
		$expected = '/app/webroot/test.php';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/app/webroot/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);

		Configure::write('App.baseUrl', '/app/index.php');
		$result = $Dispatcher->baseUrl();
		$expected = '/app/index.php';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/app/webroot/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);

		Configure::write('App.baseUrl', '/index.php');
		$result = $Dispatcher->baseUrl();
		$expected = '/index.php';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/app/webroot/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);

		Configure::write('App.baseUrl', '/CakeBB/app/webroot/index.php');
		$result = $Dispatcher->baseUrl();
		$expected = '/CakeBB/app/webroot/index.php';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/CakeBB/app/webroot/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);

		Configure::write('App.baseUrl', '/CakeBB/app/index.php');
		$result = $Dispatcher->baseUrl();
		$expected = '/CakeBB/app/index.php';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/CakeBB/app/webroot/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);

		Configure::write('App.baseUrl', '/CakeBB/index.php');
		$result = $Dispatcher->baseUrl();
		$expected = '/CakeBB/index.php';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/CakeBB/app/webroot/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);

		Configure::write('App.baseUrl', '/dbhauser/index.php');
		$_SERVER['DOCUMENT_ROOT'] = '/kunden/homepages/4/d181710652/htdocs/joomla';
		$_SERVER['SCRIPT_FILENAME'] = '/kunden/homepages/4/d181710652/htdocs/joomla/dbhauser/index.php';
		$result = $Dispatcher->baseUrl();
		$expected = '/dbhauser/index.php';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/dbhauser/app/webroot/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
	}
/**
 * testBaseUrlAndWebrootWithBase method
 *
 * @access public
 * @return void
 */
	function testBaseUrlAndWebrootWithBase() {
		$Dispatcher =& new Dispatcher();
		$Dispatcher->base = '/app';
		$result = $Dispatcher->baseUrl();
		$expected = '/app';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/app/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);

		$Dispatcher->base = '';
		$result = $Dispatcher->baseUrl();
		$expected = '';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);

		Configure::write('App.dir', 'testbed');
		$Dispatcher->base = '/cake/testbed/webroot';
		$result = $Dispatcher->baseUrl();
		$expected = '/cake/testbed/webroot';
		$this->assertEqual($expected, $result);
		$expectedWebroot = '/cake/testbed/webroot/';
		$this->assertEqual($expectedWebroot, $Dispatcher->webroot);
	}
/**
 * testMissingController method
 *
 * @access public
 * @return void
 */
	function testMissingController() {
		$Dispatcher =& new TestDispatcher();
		Configure::write('App.baseUrl','/index.php');
		$url = 'some_controller/home/param:value/param2:value2';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));
		$expected = array('missingController', array(array(
			'className' => 'SomeControllerController',
			'webroot' => '/app/webroot/',
			'url' => 'some_controller/home/param:value/param2:value2',
			'base' => '/index.php'
		)));
		$this->assertEqual($expected, $controller);
	}
/**
 * testPrivate method
 *
 * @access public
 * @return void
 */
	function testPrivate() {
		$Dispatcher =& new TestDispatcher();
		Configure::write('App.baseUrl','/index.php');
		$url = 'some_pages/_protected/param:value/param2:value2';

		$controller = $Dispatcher->dispatch($url, array('return' => 1));

		$expected = array('privateAction', array(array(
			'className' => 'SomePagesController',
			'action' => '_protected',
			'webroot' => '/app/webroot/',
			'url' => 'some_pages/_protected/param:value/param2:value2',
			'base' => '/index.php'
		)));
		$this->assertEqual($controller, $expected);
	}
/**
 * testMissingAction method
 *
 * @access public
 * @return void
 */
	function testMissingAction() {
		$Dispatcher =& new TestDispatcher();
		Configure::write('App.baseUrl','/index.php');
		$url = 'some_pages/home/param:value/param2:value2';

		$controller = $Dispatcher->dispatch($url, array('return'=> 1));

		$expected = array('missingAction', array(array(
			'className' => 'SomePagesController',
			'action' => 'home',
			'webroot' => '/app/webroot/',
			'url' => '/index.php/some_pages/home/param:value/param2:value2',
			'base' => '/index.php'
		)));
		$this->assertEqual($expected, $controller);

		$Dispatcher =& new TestDispatcher();
		Configure::write('App.baseUrl','/index.php');
		$url = 'some_pages/redirect/param:value/param2:value2';

		$controller = $Dispatcher->dispatch($url, array('return'=> 1));

		$expected = array('missingAction', array(array(
			'className' => 'SomePagesController',
			'action' => 'redirect',
			'webroot' => '/app/webroot/',
			'url' => '/index.php/some_pages/redirect/param:value/param2:value2',
			'base' => '/index.php'
		)));
		$this->assertEqual($expected, $controller);
	}
/**
 * testDispatch method
 *
 * @access public
 * @return void
 */
	function testDispatch() {
		$Dispatcher =& new TestDispatcher();
		Configure::write('App.baseUrl','/index.php');
		$url = 'pages/home/param:value/param2:value2';

		$controller = $Dispatcher->dispatch($url, array('return' => 1));
		$expected = 'Pages';
		$this->assertEqual($expected, $controller->name);

		$expected = array('0' => 'home', 'param' => 'value', 'param2' => 'value2');
		$this->assertIdentical($expected, $controller->passedArgs);

		Configure::write('App.baseUrl','/pages/index.php');

		$url = 'pages/home';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));

		$expected = 'Pages';
		$this->assertEqual($expected, $controller->name);

		$url = 'pages/home/';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));

		$expected = 'Pages';
		$this->assertEqual($expected, $controller->name);

		unset($Dispatcher);

		$Dispatcher =& new TestDispatcher();
		Configure::write('App.baseUrl','/timesheets/index.php');

		$url = 'timesheets';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));

		$expected = 'Timesheets';
		$this->assertEqual($expected, $controller->name);

		$url = 'timesheets/';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));

		$this->assertEqual('Timesheets', $controller->name);
		$this->assertEqual('/timesheets/index.php', $Dispatcher->base);

		$url = 'test_dispatch_pages/camelCased';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));
		$this->assertEqual('TestDispatchPages', $controller->name);
	}
/**
 * testDispatchWithArray method
 *
 * @access public
 * @return void
 */
	function testDispatchWithArray() {
		$Dispatcher =& new TestDispatcher();
		Configure::write('App.baseUrl','/index.php');
		$url = 'pages/home/param:value/param2:value2';

		$url = array('controller' => 'pages', 'action' => 'display');
		$controller = $Dispatcher->dispatch($url, array('pass' => array('home'), 'named' => array('param' => 'value', 'param2' => 'value2'), 'return' => 1));
		$expected = 'Pages';
		$this->assertEqual($expected, $controller->name);

		$expected = array('0' => 'home', 'param' => 'value', 'param2' => 'value2');
		$this->assertIdentical($expected, $controller->passedArgs);
	}
/**
 * testAdminDispatch method
 *
 * @access public
 * @return void
 */
	function testAdminDispatch() {
		$_POST = array();
		$Dispatcher =& new TestDispatcher();
		Configure::write('Routing.admin', 'admin');
		Configure::write('App.baseUrl','/cake/repo/branches/1.2.x.x/index.php');
		$url = 'admin/test_dispatch_pages/index/param:value/param2:value2';

		Router::reload();
		$Router =& Router::getInstance();
		$controller = $Dispatcher->dispatch($url, array('return' => 1));

		$expected = 'TestDispatchPages';
		$this->assertEqual($expected, $controller->name);

		$expected = array('param' => 'value', 'param2' => 'value2');
		$this->assertIdentical($expected, $controller->passedArgs);
		$this->assertTrue($controller->params['admin']);

		$expected = '/cake/repo/branches/1.2.x.x/index.php/admin/test_dispatch_pages/index/param:value/param2:value2';
		$this->assertIdentical($expected, $controller->here);

		$expected = '/cake/repo/branches/1.2.x.x/index.php';
		$this->assertIdentical($expected, $controller->base);
	}
/**
 * testPluginDispatch method
 *
 * @access public
 * @return void
 */
	function testPluginDispatch() {
		$_POST = array();
		$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';

		Router::reload();
		$Dispatcher =& new TestDispatcher();
		Router::connect('/my_plugin/:controller/*', array('plugin'=>'my_plugin', 'controller'=>'pages', 'action'=>'display'));

		$Dispatcher->base = false;
		$url = 'my_plugin/some_pages/home/param:value/param2:value2';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));

		$result = $Dispatcher->parseParams($url);
		$expected = array(
			'pass' => array('home'),
			'named' => array('param'=> 'value', 'param2'=> 'value2'), 'plugin'=> 'my_plugin',
			'controller'=> 'some_pages', 'action'=> 'display', 'form'=> null,
			'url'=> array('url'=> 'my_plugin/some_pages/home/param:value/param2:value2'),
		);
		ksort($expected);
		ksort($result);

		$this->assertEqual($expected, $result);

		$expected = 'my_plugin';
		$this->assertIdentical($expected, $controller->plugin);

		$expected = 'SomePages';
		$this->assertIdentical($expected, $controller->name);

		$expected = 'some_pages';
		$this->assertIdentical($expected, $controller->params['controller']);

		$expected = array('0' => 'home', 'param'=>'value', 'param2'=>'value2');
		$this->assertIdentical($expected, $controller->passedArgs);

		$expected = '/cake/repo/branches/1.2.x.x/my_plugin/some_pages/home/param:value/param2:value2';
		$this->assertIdentical($expected, $controller->here);

		$expected = '/cake/repo/branches/1.2.x.x';
		$this->assertIdentical($expected, $controller->base);
	}
/**
 * testAutomaticPluginDispatch method
 *
 * @access public
 * @return void
 */
	function testAutomaticPluginDispatch() {
		$_POST = array();
		$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';

		Router::reload();
		$Dispatcher =& new TestDispatcher();
		Router::connect('/my_plugin/:controller/:action/*', array('plugin'=>'my_plugin', 'controller'=>'pages', 'action'=>'display'));

		$Dispatcher->base = false;

		$url = 'my_plugin/other_pages/index/param:value/param2:value2';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));

		$expected = 'my_plugin';
		$this->assertIdentical($expected, $controller->plugin);

		$expected = 'OtherPages';
		$this->assertIdentical($expected, $controller->name);

		$expected = 'index';
		$this->assertIdentical($expected, $controller->action);

		$expected = array('param' => 'value', 'param2' => 'value2');
		$this->assertIdentical($expected, $controller->passedArgs);

		$expected = '/cake/repo/branches/1.2.x.x/my_plugin/other_pages/index/param:value/param2:value2';
		$this->assertIdentical($expected, $controller->here);

		$expected = '/cake/repo/branches/1.2.x.x';
		$this->assertIdentical($expected, $controller->base);
	}
/**
 * testAutomaticPluginControllerDispatch method
 *
 * @access public
 * @return void
 */
	function testAutomaticPluginControllerDispatch() {
		$_POST = array();
		$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';

		Router::reload();
		$Dispatcher =& new TestDispatcher();
		$Dispatcher->base = false;

		$url = 'my_plugin/add/param:value/param2:value2';

		$controller = $Dispatcher->dispatch($url, array('return' => 1));

		$expected = 'my_plugin';
		$this->assertIdentical($controller->plugin, $expected);

		$expected = 'MyPlugin';
		$this->assertIdentical($controller->name, $expected);

		$expected = 'add';
		$this->assertIdentical($controller->action, $expected);

		$expected = array('param' => 'value', 'param2' => 'value2');
		$this->assertEqual($controller->params['named'], $expected);

		Router::reload();
		$Dispatcher =& new TestDispatcher();
		$Dispatcher->base = false;

		/* Simulates the Route for a real plugin, installed in APP/plugins */
		Router::connect('/my_plugin/:controller/:action/*', array('plugin' => 'my_plugin'));

		$plugin = 'MyPlugin';
		$pluginUrl = Inflector::underscore($plugin);

		$url = $pluginUrl;
		$controller = $Dispatcher->dispatch($url, array('return' => 1));

		$expected = $pluginUrl;
		$this->assertIdentical($controller->plugin, $expected);

		$expected = $plugin;
		$this->assertIdentical($controller->name, $expected);

		$expected = 'index';
		$this->assertIdentical($controller->action, $expected);

		$expected = $pluginUrl;
		$this->assertEqual($controller->params['controller'], $expected);

		Configure::write('Routing.admin', 'admin');

		Router::reload();
		$Dispatcher =& new TestDispatcher();
		$Dispatcher->base = false;

		$url = 'admin/my_plugin/add/5/param:value/param2:value2';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));

		$expected = 'my_plugin';
		$this->assertIdentical($controller->plugin, $expected);

		$expected = 'MyPlugin';
		$this->assertIdentical($controller->name, $expected);

		$expected = 'admin_add';
		$this->assertIdentical($controller->action, $expected);

		$expected = array(0 => 5, 'param'=>'value', 'param2'=>'value2');
		$this->assertEqual($controller->passedArgs, $expected);

		Router::reload();

		$Dispatcher =& new TestDispatcher();
		$Dispatcher->base = false;

		$controller = $Dispatcher->dispatch('admin/articles_test', array('return' => 1));

		$expected = 'articles_test';
		$this->assertIdentical($controller->plugin, $expected);

		$expected = 'ArticlesTest';
		$this->assertIdentical($controller->name, $expected);

		$expected = 'admin_index';
		$this->assertIdentical($controller->action, $expected);

		$expected = array(
			'pass'=> array(), 'named' => array(), 'controller' => 'articles_test', 'plugin' => 'articles_test', 'action' => 'admin_index',
			'prefix' => 'admin', 'admin' =>  true, 'form' => array(), 'url' => array('url' => 'admin/articles_test'), 'return' => 1
		);
		$this->assertEqual($controller->params, $expected);
	}
/**
 * test Plugin dispatching without controller name and using
 * plugin short form instead.
 *
 * @return void
 **/
	function testAutomaticPluginDispatchWithShortAccess() {
		$_POST = array();
		$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';

		Router::reload();
		Router::connect('/my_plugin/:controller/:action/*', array('plugin'=>'my_plugin'));

		$Dispatcher =& new TestDispatcher();
		$Dispatcher->base = false;

		$url = 'my_plugin/my_plugin/add';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));
		$this->assertFalse(isset($controller->params['pass'][0]));

		$Dispatcher =& new TestDispatcher();
		$Dispatcher->base = false;

		$url = 'my_plugin/my_plugin/add/0';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));
		$this->assertTrue(isset($controller->params['pass'][0]));

		$Dispatcher =& new TestDispatcher();
		$Dispatcher->base = false;

		$url = 'my_plugin/add';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));

		$this->assertFalse(isset($controller->params['pass'][0]));

		$Dispatcher =& new TestDispatcher();
		$Dispatcher->base = false;

		$url = 'my_plugin/add/0';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));
		$this->assertIdentical('0',$controller->params['pass'][0]);

		$Dispatcher =& new TestDispatcher();
		$Dispatcher->base = false;

		$url = 'my_plugin/add/1';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));
		$this->assertIdentical('1',$controller->params['pass'][0]);
	}
/**
 * testAutomaticPluginControllerMissingActionDispatch method
 *
 * @access public
 * @return void
 */
	function testAutomaticPluginControllerMissingActionDispatch() {
		$_POST = array();
		$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';

		Router::reload();
		$Dispatcher =& new TestDispatcher();
		$Dispatcher->base = false;

		$url = 'my_plugin/not_here/param:value/param2:value2';
		$controller = $Dispatcher->dispatch($url, array('return'=> 1));

		$expected = array('missingAction', array(array(
			'className' => 'MyPluginController',
			'action' => 'not_here',
			'webroot' => '/cake/repo/branches/1.2.x.x/',
			'url' => '/cake/repo/branches/1.2.x.x/my_plugin/not_here/param:value/param2:value2',
			'base' => '/cake/repo/branches/1.2.x.x'
		)));
		$this->assertIdentical($expected, $controller);

		Router::reload();
		$Dispatcher =& new TestDispatcher();
		$Dispatcher->base = false;

		$url = 'my_plugin/param:value/param2:value2';
		$controller = $Dispatcher->dispatch($url, array('return'=> 1));

		$expected = array('missingAction', array(array(
			'className' => 'MyPluginController',
			'action' => 'param:value',
			'webroot' => '/cake/repo/branches/1.2.x.x/',
			'url' => '/cake/repo/branches/1.2.x.x/my_plugin/param:value/param2:value2',
			'base' => '/cake/repo/branches/1.2.x.x'
		)));
		$this->assertIdentical($expected, $controller);
	}
/**
 * testPrefixProtection method
 *
 * @access public
 * @return void
 */
	function testPrefixProtection() {
		$_POST = array();
		$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';

		Router::reload();
		Router::connect('/admin/:controller/:action/*', array('prefix'=>'admin'), array('controller', 'action'));

		$Dispatcher =& new TestDispatcher();
		$Dispatcher->base = false;

		$url = 'test_dispatch_pages/admin_index/param:value/param2:value2';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));

		$expected = array('privateAction', array(array(
			'className' => 'TestDispatchPagesController',
			'action' => 'admin_index',
			'webroot' => '/cake/repo/branches/1.2.x.x/',
			'url' => 'test_dispatch_pages/admin_index/param:value/param2:value2',
			'base' => '/cake/repo/branches/1.2.x.x'
		)));
		$this->assertIdentical($expected, $controller);
	}
/**
 * undocumented function
 *
 * @return void
 **/
	function testTestPluginDispatch() {
		$Dispatcher =& new TestDispatcher();
		$_back = Configure::read('pluginPaths');
		Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
		$url = '/test_plugin/tests/index';
		$result = $Dispatcher->dispatch($url, array('return' => 1));
		$this->assertTrue(class_exists('TestsController'));
		$this->assertTrue(class_exists('TestPluginAppController'));
		$this->assertTrue(class_exists('OtherComponentComponent'));
		$this->assertTrue(class_exists('PluginsComponentComponent'));

		Configure::write('pluginPaths', $_back);
	}
/**
 * testChangingParamsFromBeforeFilter method
 *
 * @access public
 * @return void
 */
	function testChangingParamsFromBeforeFilter() {
		$Dispatcher =& new TestDispatcher();
		$url = 'some_posts/index/param:value/param2:value2';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));

		$expected = array('missingAction', array(array(
			'className' => 'SomePostsController',
			'action' => 'view',
			'webroot' => '/cake/repo/branches/1.2.x.x/',
			'url' => '/cake/repo/branches/1.2.x.x/some_posts/index/param:value/param2:value2',
			'base' => '/cake/repo/branches/1.2.x.x'
		)));
		$this->assertEqual($expected, $controller);

		$url = 'some_posts/something_else/param:value/param2:value2';
		$controller = $Dispatcher->dispatch($url, array('return' => 1));

		$expected = 'SomePosts';
		$this->assertEqual($expected, $controller->name);

		$expected = 'change';
		$this->assertEqual($expected, $controller->action);

		$expected = array('changed');
		$this->assertIdentical($expected, $controller->params['pass']);
	}
/**
 * testStaticAssets method
 *
 * @access public
 * @return void
 */
	function testStaticAssets() {
		Router::reload();
		$Configure = Configure::getInstance();
		$Configure->__objects = null;

		Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
		Configure::write('vendorPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS));

		$Dispatcher =& new TestDispatcher();

		Configure::write('debug', 0);
		ob_start();
		$Dispatcher->dispatch('/img/test.jpg');
		$result = ob_get_clean();
		$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS . 'img' . DS . 'test.jpg');
		$this->assertEqual($file, $result);

		Configure::write('debug', 0);
		$Dispatcher->params = $Dispatcher->parseParams('css/test_asset.css');

		ob_start();
		$Dispatcher->cached('css/test_asset.css');
		$result = ob_get_clean();
		$this->assertEqual('this is the test asset css file', $result);

		Configure::write('debug', 0);
		$Dispatcher->params = $Dispatcher->parseParams('test_plugin/css/test_plugin_asset.css');
		ob_start();
		$Dispatcher->cached('test_plugin/css/test_plugin_asset.css');
		$result = ob_get_clean();
		$this->assertEqual('this is the test plugin asset css file', $result);

		Configure::write('debug', 0);
		$Dispatcher->params = $Dispatcher->parseParams('test_plugin/img/cake.icon.gif');
		ob_start();
		$Dispatcher->cached('test_plugin/img/cake.icon.gif');
		$result = ob_get_clean();
		$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' .DS . 'vendors' . DS . 'img' . DS . 'cake.icon.gif');
		$this->assertEqual($file, $result);

		header('Content-type: text/html');//reset the header content-type without page can render as plain text.
	}
/**
 * testFullPageCachingDispatch method
 *
 * @access public
 * @return void
 */
	function testFullPageCachingDispatch() {
		Configure::write('Cache.disable', false);
		Configure::write('Cache.check', true);
		Configure::write('debug', 2);

		$_POST = array();
		$_SERVER['PHP_SELF'] = '/';

		Router::reload();
		Router::connect('/', array('controller' => 'test_cached_pages', 'action' => 'index'));

		Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));

		$dispatcher =& new Dispatcher();
		$dispatcher->base = false;

		$url = '/';

		ob_start();
		$dispatcher->dispatch($url);
		$out = ob_get_clean();

		ob_start();
		$dispatcher->cached($url);
		$cached = ob_get_clean();

		$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
		$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
		$expected =  str_replace(array("\t", "\r\n", "\n"), "", $cached);

		$this->assertEqual($result, $expected);

		$filename = $this->__cachePath($dispatcher->here);
		unlink($filename);

		$dispatcher->base = false;
		$url = 'test_cached_pages/index';

		ob_start();
		$dispatcher->dispatch($url);
		$out = ob_get_clean();

		ob_start();
		$dispatcher->cached($url);
		$cached = ob_get_clean();

		$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
		$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
		$expected =  str_replace(array("\t", "\r\n", "\n"), "", $cached);

		$this->assertEqual($result, $expected);
		$filename = $this->__cachePath($dispatcher->here);
		unlink($filename);

		$url = 'TestCachedPages/index';

		ob_start();
		$dispatcher->dispatch($url);
		$out = ob_get_clean();

		ob_start();
		$dispatcher->cached($url);
		$cached = ob_get_clean();

		$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
		$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
		$expected =  str_replace(array("\t", "\r\n", "\n"), "", $cached);

		$this->assertEqual($result, $expected);
		$filename = $this->__cachePath($dispatcher->here);
		unlink($filename);

		$url = 'TestCachedPages/test_nocache_tags';

		ob_start();
		$dispatcher->dispatch($url);
		$out = ob_get_clean();

		ob_start();
		$dispatcher->cached($url);
		$cached = ob_get_clean();

		$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
		$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
		$expected =  str_replace(array("\t", "\r\n", "\n"), "", $cached);

		$this->assertEqual($result, $expected);
		$filename = $this->__cachePath($dispatcher->here);
		unlink($filename);

		$url = 'test_cached_pages/view/param/param';

		ob_start();
		$dispatcher->dispatch($url);
		$out = ob_get_clean();

		ob_start();
		$dispatcher->cached($url);
		$cached = ob_get_clean();

		$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
		$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
		$expected =  str_replace(array("\t", "\r\n", "\n"), "", $cached);

		$this->assertEqual($result, $expected);
		$filename = $this->__cachePath($dispatcher->here);
		unlink($filename);

		$url = 'test_cached_pages/view/foo:bar/value:goo';

		ob_start();
		$dispatcher->dispatch($url);
		$out = ob_get_clean();

		ob_start();
		$dispatcher->cached($url);
		$cached = ob_get_clean();

		$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
		$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
		$expected =  str_replace(array("\t", "\r\n", "\n"), "", $cached);

		$this->assertEqual($result, $expected);
		$filename = $this->__cachePath($dispatcher->here);
		$this->assertTrue(file_exists($filename));
		unlink($filename);
	}
/**
 * testHttpMethodOverrides method
 *
 * @access public
 * @return void
 */
	function testHttpMethodOverrides() {
		Router::reload();
		Router::mapResources('Posts');

		$_SERVER['REQUEST_METHOD'] = 'POST';
		$dispatcher =& new Dispatcher();
		$dispatcher->base = false;

		$result = $dispatcher->parseParams('/posts');
		$expected = array('pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'add', '[method]' => 'POST', 'form' => array(), 'url' => array());
		$this->assertEqual($result, $expected);

		$_SERVER['REQUEST_METHOD'] = 'GET';
		$_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'PUT';

		$result = $dispatcher->parseParams('/posts/5');
		$expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT', 'form' => array(), 'url' => array());
		$this->assertEqual($result, $expected);

		unset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
		$_SERVER['REQUEST_METHOD'] = 'GET';

		$result = $dispatcher->parseParams('/posts/5');
		$expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'view', '[method]' => 'GET', 'form' => array(), 'url' => array());
		$this->assertEqual($result, $expected);

		$_POST['_method'] = 'PUT';

		$result = $dispatcher->parseParams('/posts/5');
		$expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT', 'form' => array(), 'url' => array());
		$this->assertEqual($result, $expected);

		$_POST['_method'] = 'POST';
		$_POST['data'] = array('Post' => array('title' => 'New Post'));
		$_POST['extra'] = 'data';
		$_SERVER = array();

		$result = $dispatcher->parseParams('/posts');
		$expected = array(
			'pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'add',
			'[method]' => 'POST', 'form' => array('extra' => 'data'), 'data' => array('Post' => array('title' => 'New Post')),
			'url' => array()
		);
		$this->assertEqual($result, $expected);

		unset($_POST['_method']);
	}
/**
 * testEnvironmentDetection method
 *
 * @access public
 * @return void
 */
	function testEnvironmentDetection() {
		$dispatcher =& new Dispatcher();

		$environments = array(
			'IIS' => array(
				'No rewrite base path' => array(
					'App' => array('base' => false, 'baseUrl' => '/index.php?', 'server' => 'IIS'),
					'SERVER' => array('HTTPS' => 'off', 'SCRIPT_NAME' => '/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '', 'REMOTE_ADDR' => '127.0.0.1', 'REMOTE_HOST' => '127.0.0.1', 'REQUEST_METHOD' => 'GET', 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => '80', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'SERVER_SOFTWARE' => 'Microsoft-IIS/5.1', 'APPL_PHYSICAL_PATH' => 'C:\\Inetpub\\wwwroot\\', 'REQUEST_URI' => '/index.php', 'URL' => '/index.php', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', 'ORIG_PATH_INFO' => '/index.php', 'PATH_INFO' => '', 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/index.php', 'HTTP_ACCEPT' => '*/*', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_CONNECTION' => 'Keep-Alive', 'HTTP_HOST' => 'localhost', 'HTTP_USER_AGENT' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'argv' => array(), 'argc' => 0),
					'reload' => true,
					'path' => ''
				),
				'No rewrite with path' => array(
					'SERVER' => array('QUERY_STRING' => '/posts/add', 'REQUEST_URI' => '/index.php?/posts/add', 'URL' => '/index.php?/posts/add', 'argv' => array('/posts/add'), 'argc' => 1),
					'reload' => false,
					'path' => '/posts/add'
				),
				'No rewrite sub dir 1' => array(
					'GET' => array(),
					'SERVER' => array('QUERY_STRING' => '',  'REQUEST_URI' => '/index.php', 'URL' => '/index.php', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', 'ORIG_PATH_INFO' => '/index.php', 'PATH_INFO' => '', 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/index.php', 'argv' => array(), 'argc' => 0),
					'reload' => false,
					'path' => ''
				),
				'No rewrite sub dir 1 with path' => array(
					'GET' => array('/posts/add' => ''),
					'SERVER' => array('QUERY_STRING' => '/posts/add', 'REQUEST_URI' => '/index.php?/posts/add', 'URL' => '/index.php?/posts/add', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', 'argv' => array('/posts/add'), 'argc' => 1),
					'reload' => false,
					'path' => '/posts/add'
				),
				'No rewrite sub dir 2' => array(
					'App' => array('base' => false, 'baseUrl' => '/site/index.php?', 'dir' => 'app', 'webroot' => 'webroot', 'server' => 'IIS'),
					'GET' => array(),
					'POST' => array(),
					'SERVER' => array('SCRIPT_NAME' => '/site/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '', 'REQUEST_URI' => '/site/index.php', 'URL' => '/site/index.php', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\site\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/site/index.php', 'argv' => array(), 'argc' => 0),
					'reload' => false,
					'path' => ''
				),
				'No rewrite sub dir 2 with path' => array(
					'GET' => array('/posts/add' => ''),
					'SERVER' => array('SCRIPT_NAME' => '/site/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '/posts/add', 'REQUEST_URI' => '/site/index.php?/posts/add', 'URL' => '/site/index.php?/posts/add', 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\site\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/site/index.php', 'argv' => array('/posts/add'), 'argc' => 1),
					'reload' => false,
					'path' => '/posts/add'
				)
			),
			'Apache' => array(
				'No rewrite base path' => array(
					'App' => array('base' => false, 'baseUrl' => '/index.php', 'dir' => 'app', 'webroot' => 'webroot'),
					'SERVER' => array('SERVER_NAME' => 'localhost', 'SERVER_ADDR' => '::1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '::1', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => '', 'REQUEST_URI' => '/', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php', 'argv' => array(), 'argc' => 0),
					'reload' => true,
					'path' => ''
				),
				'No rewrite with path' => array(
					'SERVER' => array('UNIQUE_ID' => 'VardGqn@17IAAAu7LY8AAAAK', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-us) AppleWebKit/523.10.5 (KHTML, like Gecko) Version/3.0.4 Safari/523.10.6', 'HTTP_ACCEPT' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_CONNECTION' => 'keep-alive', 'HTTP_HOST' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/officespace/app/webroot/index.php', 'QUERY_STRING' => '', 'REQUEST_URI' => '/index.php/posts/add', 'SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '/posts/add', 'PHP_SELF' => '/index.php/posts/add', 'argv' => array(), 'argc' => 0),
					'reload' => false,
					'path' => '/posts/add'
				),
				'GET Request at base domain' => array(
					'App' => array('base' => false, 'baseUrl' => null, 'dir' => 'app', 'webroot' => 'webroot'),
					'SERVER'	=> array('UNIQUE_ID' => '2A-v8sCoAQ8AAAc-2xUAAAAB', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_COOKIE' => 'CAKEPHP=jcbv51apn84kd9ucv5aj2ln3t3', 'HTTP_CONNECTION' => 'keep-alive', 'HTTP_HOST' => 'cake.1.2', 'SERVER_NAME' => 'cake.1.2', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '127.0.0.1', 'DOCUMENT_ROOT' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot', 'SERVER_ADMIN' => 'you@example.com', 'SCRIPT_FILENAME' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot/index.php', 'REMOTE_PORT' => '53550', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => 'a=b', 'REQUEST_URI' => '/?a=b', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php'),
					'GET' => array('a' => 'b'),
					'POST' => array(),
					'reload' => true,
					'path' => '',
					'urlParams' => array('a' => 'b'),
					'environment' => array('CGI_MODE' => false)
				),
				'New CGI no mod_rewrite' => array(
					'App' => array('base' => false, 'baseUrl' => '/limesurvey20/index.php', 'dir' => 'app', 'webroot' => 'webroot'),
					'SERVER' => array('DOCUMENT_ROOT' => '/home/.sites/110/site313/web', 'PATH_INFO' => '/installations', 'PATH_TRANSLATED' => '/home/.sites/110/site313/web/limesurvey20/index.php', 'PHPRC' => '/home/.sites/110/site313', 'QUERY_STRING' => '', 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/limesurvey20/index.php/installations', 'SCRIPT_FILENAME' => '/home/.sites/110/site313/web/limesurvey20/index.php', 'SCRIPT_NAME' => '/limesurvey20/index.php', 'SCRIPT_URI' => 'http://www.gisdat-umfragen.at/limesurvey20/index.php/installations', 'PHP_SELF' => '/limesurvey20/index.php/installations', 'CGI_MODE' => true),
					'GET' => array(),
					'POST' => array(),
					'reload' => true,
					'path' => '/installations',
					'urlParams' => array(),
					'environment' => array('CGI_MODE' => true)
				)
			)
		);
		$backup = $this->__backupEnvironment();

		foreach ($environments as $name => $env) {
			foreach ($env as $descrip => $settings) {
				if ($settings['reload']) {
					$this->__reloadEnvironment();
				}
				$this->__loadEnvironment($settings);
				$this->assertEqual($dispatcher->uri(), $settings['path'], "%s on environment: {$name}, on setting: {$descrip}");

				if (isset($settings['urlParams'])) {
					$this->assertEqual($_GET, $settings['urlParams'], "%s on environment: {$name}, on setting: {$descrip}");
				}
				if (isset($settings['environment'])) {
					foreach ($settings['environment'] as $key => $val) {
						$this->assertEqual(env($key), $val, "%s on key {$key} on environment: {$name}, on setting: {$descrip}");
					}
				}
			}
		}
		$this->__loadEnvironment(array_merge(array('reload' => true), $backup));
	}
/**
 * Tests that the Dispatcher does not return an empty action
 *
 * @access private
 * @return void
 */
	function testTrailingSlash() {
		$_POST = array();
		$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';

		Router::reload();
		$Dispatcher =& new TestDispatcher();
		Router::connect('/myalias/:action/*', array('controller' => 'my_controller', 'action' => null));

		$Dispatcher->base = false;
		$url = 'myalias/'; //Fails
		$controller = $Dispatcher->dispatch($url, array('return' => 1));
		$result = $Dispatcher->parseParams($url);
		$this->assertEqual('index', $result['action']);

		$url = 'myalias'; //Passes
		$controller = $Dispatcher->dispatch($url, array('return' => 1));
		$result = $Dispatcher->parseParams($url);
		$this->assertEqual('index', $result['action']);
	}
/**
 * backupEnvironment method
 *
 * @access private
 * @return void
 */
	function __backupEnvironment() {
		return array(
			'App'	=> Configure::read('App'),
			'GET'	=> $_GET,
			'POST'	=> $_POST,
			'SERVER'=> $_SERVER
		);
	}
/**
 * reloadEnvironment method
 *
 * @access private
 * @return void
 */
	function __reloadEnvironment() {
		foreach ($_GET as $key => $val) {
			unset($_GET[$key]);
		}
		foreach ($_POST as $key => $val) {
			unset($_POST[$key]);
		}
		foreach ($_SERVER as $key => $val) {
			unset($_SERVER[$key]);
		}
		Configure::write('App', array());
	}
/**
 * loadEnvironment method
 *
 * @param mixed $env
 * @access private
 * @return void
 */
	function __loadEnvironment($env) {
		if ($env['reload']) {
			$this->__reloadEnvironment();
		}

		if (isset($env['App'])) {
			Configure::write('App', $env['App']);
		}

		if (isset($env['GET'])) {
			foreach ($env['GET'] as $key => $val) {
				$_GET[$key] = $val;
			}
		}

		if (isset($env['POST'])) {
			foreach ($env['POST'] as $key => $val) {
				$_POST[$key] = $val;
			}
		}

		if (isset($env['SERVER'])) {
			foreach ($env['SERVER'] as $key => $val) {
				$_SERVER[$key] = $val;
			}
		}
	}
/**
 * cachePath method
 *
 * @param mixed $her
 * @access private
 * @return string
 */
	function __cachePath($here) {
		$path = $here;
		if ($here == '/') {
			$path = 'home';
		}
		$path = strtolower(Inflector::slug($path));

		$filename = CACHE . 'views' . DS . $path . '.php';

		if (!file_exists($filename)) {
			$filename = CACHE . 'views' . DS . $path . '_index.php';
		}
		return $filename;
	}
}
?>


text: NDAs = new Mongo.Collection('ndas');