content_type
stringclasses 8
values | main_lang
stringclasses 7
values | message
stringlengths 1
50
| sha
stringlengths 40
40
| patch
stringlengths 52
962k
| file_count
int64 1
300
|
---|---|---|---|---|---|
Text | Text | add 3.26.1 to changelog.md | 3b9eee2e6e08885ab6f93b0ce81f0e6be5a870c7 | <ide><path>CHANGELOG.md
<ide> - [#19441](https://github.com/emberjs/ember.js/pull/19441) Add automated publishing of weekly alpha releases to NPM
<ide> - [#19462](https://github.com/emberjs/ember.js/pull/19462) Use `positional` and `named` as the argument names in `ember g helper` blueprint
<ide>
<add>### v3.26.1 (March 24, 2021)
<add>
<add>- [#19473](https://github.com/emberjs/ember.js/pull/19473) Update Glimmer VM to latest.
<add>
<ide> ### v3.26.0 (March 22, 2021)
<ide>
<ide> - [#19255](https://github.com/emberjs/ember.js/pull/19255) [DEPRECATION] Deprecate transition methods of controller and route per [RFC #674](https://github.com/emberjs/rfcs/blob/master/text/0674-deprecate-transition-methods-of-controller-and-route.md). | 1 |
Javascript | Javascript | improve a comment explaining ie11 fullscreen bug | 8e4aac8cb03ffb88373ea99629165d82ff5eccdd | <ide><path>src/css.js
<ide> function getWidthOrHeight( elem, name, extra ) {
<ide> isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
<ide>
<ide> // Support: IE11 only
<del> // Fix for edge case in IE 11. See gh-1764
<add> // In IE 11 fullscreen elements inside of an iframe have
<add> // 100x too small dimensions (gh-1764).
<ide> if ( document.msFullscreenElement && window.top !== window ) {
<ide> // Support: IE11 only
<ide> // Running getBoundingClientRect on a disconnected node | 1 |
Text | Text | add commsworld logo | 745f5abc55fccdf7fb27b7ac4889bf8c8bcb5187 | <ide><path>README.md
<ide> Our Jenkins CI installation is hosted by [DigitalOcean](https://m.do.co/c/7e39c3
<ide>
<ide> 
<ide>
<add>Our physical hardware is hosted by [Commsworld](https://www.commsworld.com).
<add>
<add>
<add>
<ide> Our bottles (binary packages) are hosted by [Bintray](https://bintray.com/homebrew).
<ide>
<ide> [](https://bintray.com/homebrew) | 1 |
Text | Text | add guide section about events and the emitter | e3eadc310de43a0debed49e0a9bcc4ad67cb27d9 | <ide><path>docs/upgrading/upgrading-your-package.md
<ide> atom.commands.dispatch workspaceElement, 'a-package:toggle'
<ide> atom.commands.dispatch editorElement, 'find-and-replace:show'
<ide> ```
<ide>
<add>## Eventing and Disposables
<add>
<add>A couple large things changed with respect to events:
<add>
<add>1. All model events are now methods that return a [`Disposable`][disposable] object
<add>1. The `subscribe()` method is no longer available on `space-pen` `View` objects
<add>1. An Emitter is now provided from `require 'atom'`
<add>
<add>### Consuming Events
<add>
<add>All events from the Atom API are now methods that return a [`Disposable`][disposable] object, on which you can call `dispose()` to unsubscribe.
<add>
<add>```coffee
<add># Old!
<add>editor.on 'changed', ->
<add>```
<add>
<add>```coffee
<add># New!
<add>disposable = editor.onDidChange ->
<add>
<add># You can unsubscribe at some point in the future via `dispose()`
<add>disposable.dispose()
<add>```
<add>
<add>Deprecation warnings will guide you toward the correct methods.
<add>
<add>#### Using a CompositeDisposable
<add>
<add>You can group multiple disposables into a single disposable with a `CompositeDisposable`.
<add>
<add>```coffee
<add>{CompositeDisposable} = require 'atom'
<add>
<add>class Something
<add> constructor: ->
<add> @disposables.add editor.onDidChange ->
<add> @disposables.add editor.onDidChangePath ->
<add>
<add> destroy: ->
<add> @disposables.dispose()
<add>```
<add>
<add>### Removing View::subscribe calls
<add>
<add>There were a couple permutations of `subscribe()`. In these examples, a `CompositeDisposable` is used as it will commonly be useful where conversion is necessary.
<add>
<add>#### subscribe(unsubscribable)
<add>
<add>This one is very straight forward.
<add>
<add>```coffee
<add># Old!
<add>@subscribe editor.on 'changed', ->
<add>```
<add>
<add>```coffee
<add># New!
<add>disposables = new CompositeDisposable
<add>disposables.add editor.onDidChange ->
<add>```
<add>
<add>#### subscribe(modelObject, event, method)
<add>
<add>When the modelObject is an Atom model object, the change is very simple. Just use the correct event method, and add it to your CompositeDisposable.
<add>
<add>```coffee
<add># Old!
<add>@subscribe editor, 'changed', ->
<add>```
<add>
<add>```coffee
<add># New!
<add>disposables = new CompositeDisposable
<add>disposables.add editor.onDidChange ->
<add>```
<add>
<add>#### subscribe(jQueryObject, selector(optional), event, method)
<add>
<add>Things are a little more complicated when subscribing to a DOM or jQuery element. Atom no longer provides helpers for subscribing to elements. You can use jQuery or the native DOM APIs, whichever you prefer.
<add>
<add>```coffee
<add># Old!
<add>@subscribe $(window), 'focus', ->
<add>```
<add>
<add>```coffee
<add># New!
<add>{Disposable, CompositeDisposable} = require 'atom'
<add>disposables = new CompositeDisposable
<add>
<add># New with jQuery
<add>focusCallback = ->
<add>$(window).on 'focus', focusCallback
<add>disposables.add new Disposable ->
<add> $(window).off 'focus', focusCallback
<add>
<add># New with native APIs
<add>focusCallback = ->
<add>window.addEventListener 'focus', focusCallback
<add>disposables.add new Disposable ->
<add> window.removeEventListener 'focus', focusCallback
<add>```
<add>
<add>### Providing Events: Using the Emitter
<add>
<add>You no longer need to require emissary to get an emitter. We now provide an `Emitter` class from `require 'atom'`. We have a specific pattern for use of the `Emitter`. Rather than mixing it in, we instantiate a member variable, and create explicit subscription methods. For more information see the [`Emitter` docs][emitter].
<add>
<add>```coffee
<add># New!
<add>{Emitter} = require 'atom'
<add>
<add>class Something
<add> constructor: ->
<add> @emitter = new Emitter
<add>
<add> destroy: ->
<add> @emitter.dispose()
<add>
<add> onDidChange: (callback) ->
<add> @emitter.on 'did-change', callback
<add>
<add> methodThatFiresAChange: ->
<add> @emitter.emit 'did-change'
<add>```
<add>
<add>## Subscribing To Commands
<ide>
<ide> [texteditorview]:https://github.com/atom/atom-space-pen-views#texteditorview
<ide> [scrollview]:https://github.com/atom/atom-space-pen-views#scrollview
<ide> [selectlistview]:https://github.com/atom/atom-space-pen-views#selectlistview
<ide> [selectlistview-example]:https://github.com/atom/command-palette/pull/19/files
<add>[emitter]:https://atom.io/docs/api/latest/Emitter
<add>[disposable]:https://atom.io/docs/api/latest/Disposable | 1 |
Javascript | Javascript | add mouseover method to the ngscenario dsl | 2f437e89781cb2b449abb685e36b26ca1cf0fff5 | <ide><path>src/ngScenario/dsl.js
<ide> angular.scenario.dsl('select', function() {
<ide> * Usage:
<ide> * element(selector, label).count() get the number of elements that match selector
<ide> * element(selector, label).click() clicks an element
<add> * element(selector, label).mouseover() mouseover an element
<ide> * element(selector, label).query(fn) executes fn(selectedElements, done)
<ide> * element(selector, label).{method}() gets the value (as defined by jQuery, ex. val)
<ide> * element(selector, label).{method}(value) sets the value (as defined by jQuery, ex. val)
<ide> angular.scenario.dsl('element', function() {
<ide> });
<ide> };
<ide>
<add> chain.mouseover = function() {
<add> return this.addFutureAction("element '" + this.label + "' mouseover", function($window, $document, done) {
<add> var elements = $document.elements();
<add> elements.trigger('mouseover');
<add> done();
<add> });
<add> };
<add>
<ide> chain.query = function(fn) {
<ide> return this.addFutureAction('element ' + this.label + ' custom query', function($window, $document, done) {
<ide> fn.call(this, $document.elements(), done);
<ide><path>test/ngScenario/dslSpec.js
<ide> describe("angular.scenario.dsl", function() {
<ide> dealoc(elm);
<ide> });
<ide>
<add> it('should execute mouseover', function() {
<add> var mousedOver;
<add> doc.append('<div></div>');
<add> doc.find('div').mouseover(function() {
<add> mousedOver = true;
<add> });
<add> $root.dsl.element('div').mouseover();
<add> expect(mousedOver).toBe(true);
<add> });
<add>
<add> it('should bubble up the mouseover event', function() {
<add> var mousedOver;
<add> doc.append('<div id="outer"><div id="inner"></div></div>');
<add> doc.find('#outer').mouseover(function() {
<add> mousedOver = true;
<add> });
<add> $root.dsl.element('#inner').mouseover();
<add> expect(mousedOver).toBe(true);
<add> });
<add>
<ide> it('should count matching elements', function() {
<ide> doc.append('<span></span><span></span>');
<ide> $root.dsl.element('span').count(); | 2 |
Text | Text | fix typos in docs/templates/datasets.md | d3f4397797e566cd2ee1c9c6c1abadc67082a64d | <ide><path>docs/templates/datasets.md
<ide> from keras.datasets import imdb
<ide>
<ide> - __Arguments:__
<ide>
<del> - __path__: if you do have the data locally (at `'~/.keras/datasets/' + path`), if will be downloaded to this location (in cPickle format).
<add> - __path__: if you do not have the data locally (at `'~/.keras/datasets/' + path`), it will be
<add> ed to this location.
<ide> - __num_words__: integer or None. Top most frequent words to consider. Any less frequent word will appear as 0 in the sequence data.
<ide> - __skip_top__: integer. Top most frequent words to ignore (they will appear as 0s in the sequence data).
<ide> - __maxlen__: int. Maximum sequence length. Any longer sequence will be truncated.
<ide> word_index = reuters.get_word_index(path="reuters_word_index.pkl")
<ide>
<ide> - __Arguments:__
<ide>
<del> - __path__: if you do have the index file locally (at `'~/.keras/datasets/' + path`), if will be downloaded to this location (in cPickle format).
<add> - __path__: if you do not have the index file locally (at `'~/.keras/datasets/' + path`), it will be downloaded to this location.
<ide>
<ide> ## MNIST database of handwritten digits
<ide>
<ide> from keras.datasets import mnist
<ide>
<ide> - __Arguments:__
<ide>
<del> - __path__: if you do have the index file locally (at `'~/.keras/datasets/' + path`), if will be downloaded to this location (in cPickle format).
<add> - __path__: if you do not have the index file locally (at `'~/.keras/datasets/' + path`), it will be downloaded to this location. | 1 |
Java | Java | add simpleannotationmeta classes and readers | 7fbf3f97cdeffd7e60a7dc9b19ca59ce73cd1cea | <ide><path>spring-core/src/main/java/org/springframework/core/type/classreading/AbstractRecursiveAnnotationVisitor.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2019 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> * @author Sam Brannen
<ide> * @since 3.1.1
<ide> */
<add>@Deprecated
<ide> abstract class AbstractRecursiveAnnotationVisitor extends AnnotationVisitor {
<ide>
<ide> protected final Log logger = LogFactory.getLog(getClass());
<ide><path>spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2019 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> * @author Sam Brannen
<ide> * @since 3.0
<ide> */
<add>@Deprecated
<ide> final class AnnotationAttributesReadingVisitor extends RecursiveAnnotationAttributesVisitor {
<ide>
<ide> private final MultiValueMap<String, AnnotationAttributes> attributesMap;
<ide><path>spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java
<ide> * @author Sam Brannen
<ide> * @since 2.5
<ide> */
<add>@Deprecated
<ide> public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisitor implements AnnotationMetadata {
<ide>
<ide> @Nullable
<ide><path>spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationReadingVisitorUtils.java
<ide> * @author Sam Brannen
<ide> * @since 4.0
<ide> */
<add>@Deprecated
<ide> abstract class AnnotationReadingVisitorUtils {
<ide>
<ide> public static AnnotationAttributes convertClassValues(Object annotatedElement,
<ide><path>spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java
<ide> /*
<del> * Copyright 2002-2017 the original author or authors.
<add> * Copyright 2002-2019 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> * @author Chris Beams
<ide> * @since 2.5
<ide> */
<add>@Deprecated
<ide> class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata {
<ide>
<ide> private String className = "";
<ide><path>spring-core/src/main/java/org/springframework/core/type/classreading/MergedAnnotationReadingVisitor.java
<add>/*
<add> * Copyright 2002-2019 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * https://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<add>package org.springframework.core.type.classreading;
<add>
<add>import java.lang.annotation.Annotation;
<add>import java.lang.reflect.Array;
<add>import java.util.ArrayList;
<add>import java.util.LinkedHashMap;
<add>import java.util.List;
<add>import java.util.Map;
<add>import java.util.function.Consumer;
<add>import java.util.function.Supplier;
<add>
<add>import org.springframework.asm.AnnotationVisitor;
<add>import org.springframework.asm.SpringAsmInfo;
<add>import org.springframework.asm.Type;
<add>import org.springframework.core.annotation.AnnotationFilter;
<add>import org.springframework.core.annotation.MergedAnnotation;
<add>import org.springframework.lang.Nullable;
<add>import org.springframework.util.ClassUtils;
<add>
<add>/**
<add> * {@link AnnotationVisitor} that can be used to construct a
<add> * {@link MergedAnnotation}.
<add> *
<add> * @author Phillip Webb
<add> * @since 5.2
<add> * @param <A> the annotation type
<add> */
<add>class MergedAnnotationReadingVisitor<A extends Annotation> extends AnnotationVisitor {
<add>
<add> @Nullable
<add> private final ClassLoader classLoader;
<add>
<add> @Nullable
<add> private final Object source;
<add>
<add> private final Class<A> annotationType;
<add>
<add> private final Consumer<MergedAnnotation<A>> consumer;
<add>
<add> private final Map<String, Object> attributes = new LinkedHashMap<>(4);
<add>
<add> public MergedAnnotationReadingVisitor(ClassLoader classLoader,
<add> @Nullable Object source, Class<A> annotationType,
<add> Consumer<MergedAnnotation<A>> consumer) {
<add> super(SpringAsmInfo.ASM_VERSION);
<add> this.classLoader = classLoader;
<add> this.source = source;
<add> this.annotationType = annotationType;
<add> this.consumer = consumer;
<add> }
<add>
<add> @Override
<add> public void visit(String name, Object value) {
<add> if (value instanceof Type) {
<add> value = ((Type) value).getClassName();
<add> }
<add> this.attributes.put(name, value);
<add> }
<add>
<add> @Override
<add> public void visitEnum(String name, String descriptor, String value) {
<add> visitEnum(descriptor, value, enumValue -> this.attributes.put(name, enumValue));
<add> }
<add>
<add> @Override
<add> public AnnotationVisitor visitAnnotation(String name, String descriptor) {
<add> return visitAnnotation(descriptor,
<add> annotation -> this.attributes.put(name, annotation));
<add> }
<add>
<add> @Override
<add> public AnnotationVisitor visitArray(String name) {
<add> return new ArrayVisitor(value -> this.attributes.put(name, value));
<add> }
<add>
<add> @Override
<add> public void visitEnd() {
<add> MergedAnnotation<A> annotation = MergedAnnotation.of(this.classLoader,
<add> this.source, this.annotationType, this.attributes);
<add> this.consumer.accept(annotation);
<add> }
<add>
<add> @SuppressWarnings("unchecked")
<add> public <E extends Enum<E>> void visitEnum(String descriptor, String value,
<add> Consumer<E> consumer) {
<add>
<add> String className = Type.getType(descriptor).getClassName();
<add> Class<E> type = (Class<E>) ClassUtils.resolveClassName(className, this.classLoader);
<add> E enumValue = Enum.valueOf(type, value);
<add> if (enumValue != null) {
<add> consumer.accept(enumValue);
<add> }
<add> }
<add>
<add> @SuppressWarnings("unchecked")
<add> private <T extends Annotation> AnnotationVisitor visitAnnotation(String descriptor,
<add> Consumer<MergedAnnotation<T>> consumer) {
<add>
<add> String className = Type.getType(descriptor).getClassName();
<add> if (AnnotationFilter.PLAIN.matches(className)) {
<add> return null;
<add> }
<add> Class<T> type = (Class<T>) ClassUtils.resolveClassName(className,
<add> this.classLoader);
<add> return new MergedAnnotationReadingVisitor<>(this.classLoader, this.source, type,
<add> consumer);
<add> }
<add>
<add> @Nullable
<add> @SuppressWarnings("unchecked")
<add> static <A extends Annotation> AnnotationVisitor get(@Nullable ClassLoader classLoader,
<add> @Nullable Supplier<Object> sourceSupplier, String descriptor, boolean visible,
<add> Consumer<MergedAnnotation<A>> consumer) {
<add> if (!visible) {
<add> return null;
<add> }
<add> String typeName = Type.getType(descriptor).getClassName();
<add> if (AnnotationFilter.PLAIN.matches(typeName)) {
<add> return null;
<add> }
<add> Object source = sourceSupplier != null ? sourceSupplier.get() : null;
<add> try {
<add> Class<A> annotationType = (Class<A>) ClassUtils.forName(typeName,
<add> classLoader);
<add> return new MergedAnnotationReadingVisitor<>(classLoader, source,
<add> annotationType, consumer);
<add> }
<add> catch (ClassNotFoundException | LinkageError ex) {
<add> return null;
<add> }
<add> }
<add>
<add> /**
<add> * {@link AnnotationVisitor} to deal with array attributes.
<add> */
<add> private class ArrayVisitor extends AnnotationVisitor {
<add>
<add> private final List<Object> elements = new ArrayList<>();
<add>
<add> private final Consumer<Object[]> consumer;
<add>
<add> ArrayVisitor(Consumer<Object[]> consumer) {
<add> super(SpringAsmInfo.ASM_VERSION);
<add> this.consumer = consumer;
<add> }
<add>
<add> @Override
<add> public void visit(String name, Object value) {
<add> if (value instanceof Type) {
<add> value = ((Type) value).getClassName();
<add> }
<add> this.elements.add(value);
<add> }
<add>
<add> @Override
<add> public void visitEnum(String name, String descriptor, String value) {
<add> MergedAnnotationReadingVisitor.this.visitEnum(descriptor, value,
<add> enumValue -> this.elements.add(enumValue));
<add> }
<add>
<add> @Override
<add> public AnnotationVisitor visitAnnotation(String name, String descriptor) {
<add> return MergedAnnotationReadingVisitor.this.visitAnnotation(descriptor,
<add> annotation -> this.elements.add(annotation));
<add> }
<add>
<add> @Override
<add> public void visitEnd() {
<add> Class<?> componentType = getComponentType();
<add> Object[] array = (Object[]) Array.newInstance(componentType,
<add> this.elements.size());
<add> this.consumer.accept(this.elements.toArray(array));
<add> }
<add>
<add> private Class<?> getComponentType() {
<add> if (this.elements.isEmpty()) {
<add> return Object.class;
<add> }
<add> Object firstElement = this.elements.get(0);
<add> if(firstElement instanceof Enum) {
<add> return ((Enum<?>) firstElement).getDeclaringClass();
<add> }
<add> return firstElement.getClass();
<add> }
<add>
<add> }
<add>
<add>}
<ide><path>spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java
<ide> * @author Phillip Webb
<ide> * @since 3.0
<ide> */
<add>@Deprecated
<ide> public class MethodMetadataReadingVisitor extends MethodVisitor implements MethodMetadata {
<ide>
<ide> protected final String methodName;
<ide><path>spring-core/src/main/java/org/springframework/core/type/classreading/RecursiveAnnotationArrayVisitor.java
<ide> * @author Juergen Hoeller
<ide> * @since 3.1.1
<ide> */
<add>@Deprecated
<ide> class RecursiveAnnotationArrayVisitor extends AbstractRecursiveAnnotationVisitor {
<ide>
<ide> private final String attributeName;
<ide><path>spring-core/src/main/java/org/springframework/core/type/classreading/RecursiveAnnotationAttributesVisitor.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2019 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> * @author Juergen Hoeller
<ide> * @since 3.1.1
<ide> */
<add>@Deprecated
<ide> class RecursiveAnnotationAttributesVisitor extends AbstractRecursiveAnnotationVisitor {
<ide>
<ide> protected final String annotationType;
<ide><path>spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadata.java
<add>/*
<add> * Copyright 2002-2019 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * https://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<add>package org.springframework.core.type.classreading;
<add>
<add>import java.util.Collections;
<add>import java.util.LinkedHashSet;
<add>import java.util.Set;
<add>
<add>import org.springframework.asm.Opcodes;
<add>import org.springframework.core.annotation.MergedAnnotations;
<add>import org.springframework.core.type.AnnotationMetadata;
<add>import org.springframework.core.type.MethodMetadata;
<add>import org.springframework.lang.Nullable;
<add>
<add>/**
<add> * {@link AnnotationMetadata} created from a
<add> * {@link SimpleAnnotationMetadataReadingVistor}.
<add> *
<add> * @author Phillip Webb
<add> * @since 5.2
<add> */
<add>final class SimpleAnnotationMetadata implements AnnotationMetadata {
<add>
<add> private final String className;
<add>
<add> private final int access;
<add>
<add> private final String enclosingClassName;
<add>
<add> private final String superClassName;
<add>
<add> private final boolean independentInnerClass;
<add>
<add> private final String[] interfaceNames;
<add>
<add> private final String[] memberClassNames;
<add>
<add> private final MethodMetadata[] annotatedMethods;
<add>
<add> private final MergedAnnotations annotations;
<add>
<add> private Set<String> annotationTypes;
<add>
<add> SimpleAnnotationMetadata(String className, int access, String enclosingClassName,
<add> String superClassName, boolean independentInnerClass, String[] interfaceNames,
<add> String[] memberClassNames, MethodMetadata[] annotatedMethods,
<add> MergedAnnotations annotations) {
<add> this.className = className;
<add> this.access = access;
<add> this.enclosingClassName = enclosingClassName;
<add> this.superClassName = superClassName;
<add> this.independentInnerClass = independentInnerClass;
<add> this.interfaceNames = interfaceNames;
<add> this.memberClassNames = memberClassNames;
<add> this.annotatedMethods = annotatedMethods;
<add> this.annotations = annotations;
<add> }
<add>
<add> @Override
<add> public String getClassName() {
<add> return this.className;
<add> }
<add>
<add> @Override
<add> public boolean isInterface() {
<add> return (this.access & Opcodes.ACC_INTERFACE) != 0;
<add> }
<add>
<add> @Override
<add> public boolean isAnnotation() {
<add> return (this.access & Opcodes.ACC_ANNOTATION) != 0;
<add> }
<add>
<add> @Override
<add> public boolean isAbstract() {
<add> return (this.access & Opcodes.ACC_ABSTRACT) != 0;
<add> }
<add>
<add> @Override
<add> public boolean isFinal() {
<add> return (this.access & Opcodes.ACC_FINAL) != 0;
<add> }
<add>
<add> @Override
<add> public boolean isIndependent() {
<add> return this.enclosingClassName == null || this.independentInnerClass;
<add> }
<add>
<add> @Override
<add> @Nullable
<add> public String getEnclosingClassName() {
<add> return this.enclosingClassName;
<add> }
<add>
<add> @Override
<add> @Nullable
<add> public String getSuperClassName() {
<add> return this.superClassName;
<add> }
<add>
<add> @Override
<add> public String[] getInterfaceNames() {
<add> return this.interfaceNames.clone();
<add> }
<add>
<add> @Override
<add> public String[] getMemberClassNames() {
<add> return this.memberClassNames.clone();
<add> }
<add>
<add> @Override
<add> public Set<String> getAnnotationTypes() {
<add> Set<String> annotationTypes = this.annotationTypes;
<add> if (annotationTypes == null) {
<add> annotationTypes = Collections.unmodifiableSet(
<add> AnnotationMetadata.super.getAnnotationTypes());
<add> this.annotationTypes = annotationTypes;
<add> }
<add> return annotationTypes;
<add> }
<add>
<add> @Override
<add> public Set<MethodMetadata> getAnnotatedMethods(String annotationName) {
<add> Set<MethodMetadata> annotatedMethods = null;
<add> for (int i = 0; i < this.annotatedMethods.length; i++) {
<add> if (this.annotatedMethods[i].isAnnotated(annotationName)) {
<add> if (annotatedMethods == null) {
<add> annotatedMethods = new LinkedHashSet<>(4);
<add> }
<add> annotatedMethods.add(this.annotatedMethods[i]);
<add> }
<add> }
<add> return annotatedMethods != null ? annotatedMethods : Collections.emptySet();
<add> }
<add>
<add> @Override
<add> public MergedAnnotations getAnnotations() {
<add> return this.annotations;
<add> }
<add>
<add>
<add>
<add>}
<ide><path>spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataReadingVistor.java
<add>/*
<add> * Copyright 2002-2019 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * https://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<add>package org.springframework.core.type.classreading;
<add>
<add>import java.util.ArrayList;
<add>import java.util.LinkedHashSet;
<add>import java.util.List;
<add>import java.util.Set;
<add>
<add>import org.springframework.asm.AnnotationVisitor;
<add>import org.springframework.asm.ClassVisitor;
<add>import org.springframework.asm.MethodVisitor;
<add>import org.springframework.asm.Opcodes;
<add>import org.springframework.asm.SpringAsmInfo;
<add>import org.springframework.core.annotation.MergedAnnotation;
<add>import org.springframework.core.annotation.MergedAnnotations;
<add>import org.springframework.core.type.MethodMetadata;
<add>import org.springframework.lang.Nullable;
<add>import org.springframework.util.ClassUtils;
<add>import org.springframework.util.StringUtils;
<add>
<add>/**
<add> * ASM class visitor to create {@link SimpleAnnotationMetadata}.
<add> *
<add> * @author Phillip Webb
<add> * @since 5.2
<add> */
<add>class SimpleAnnotationMetadataReadingVistor extends ClassVisitor {
<add>
<add> @Nullable
<add> private final ClassLoader classLoader;
<add>
<add> private String className = "";
<add>
<add> private int access;
<add>
<add> private String superClassName;
<add>
<add> private String[] interfaceNames;
<add>
<add> private String enclosingClassName;
<add>
<add> private boolean independentInnerClass;
<add>
<add> private Set<String> memberClassNames = new LinkedHashSet<>(4);
<add>
<add> private List<MergedAnnotation<?>> annotations = new ArrayList<>();
<add>
<add> private List<SimpleMethodMetadata> annotatedMethods = new ArrayList<>();
<add>
<add> private SimpleAnnotationMetadata metadata;
<add>
<add> private Source source;
<add>
<add> SimpleAnnotationMetadataReadingVistor(@Nullable ClassLoader classLoader) {
<add> super(SpringAsmInfo.ASM_VERSION);
<add> this.classLoader = classLoader;
<add> }
<add>
<add> @Override
<add> public void visit(int version, int access, String name, String signature,
<add> @Nullable String supername, String[] interfaces) {
<add> this.className = toClassName(name);
<add> this.access = access;
<add> if (supername != null && !isInterface(access)) {
<add> this.superClassName = toClassName(supername);
<add> }
<add> this.interfaceNames = new String[interfaces.length];
<add> for (int i = 0; i < interfaces.length; i++) {
<add> this.interfaceNames[i] = toClassName(interfaces[i]);
<add> }
<add> }
<add>
<add> @Override
<add> public void visitOuterClass(String owner, String name, String desc) {
<add> this.enclosingClassName = toClassName(owner);
<add> }
<add>
<add> @Override
<add> public void visitInnerClass(String name, @Nullable String outerName, String innerName,
<add> int access) {
<add> if (outerName != null) {
<add> String className = toClassName(name);
<add> String outerClassName = toClassName(outerName);
<add> if (this.className.equals(className)) {
<add> this.enclosingClassName = outerClassName;
<add> this.independentInnerClass = ((access & Opcodes.ACC_STATIC) != 0);
<add> }
<add> else if (this.className.equals(outerClassName)) {
<add> this.memberClassNames.add(className);
<add> }
<add> }
<add> }
<add>
<add> @Override
<add> public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
<add> return MergedAnnotationReadingVisitor.get(this.classLoader, this::getSource,
<add> descriptor, visible, this.annotations::add);
<add> }
<add>
<add> @Override
<add> public MethodVisitor visitMethod(int access, String name, String descriptor,
<add> String signature, String[] exceptions) {
<add> // Skip bridge methods - we're only interested in original
<add> // annotation-defining user methods. On JDK 8, we'd otherwise run into
<add> // double detection of the same annotated method...
<add> if (isBridge(access)) {
<add> return null;
<add> }
<add> return new SimpleMethodMetadataReadingVistor(this.classLoader, this.className,
<add> access, name, descriptor, this.annotatedMethods::add);
<add> }
<add>
<add> @Override
<add> public void visitEnd() {
<add> String[] memberClassNames = StringUtils.toStringArray(this.memberClassNames);
<add> MethodMetadata[] annotatedMethods = this.annotatedMethods.toArray(new MethodMetadata[0]);
<add> MergedAnnotations annotations = MergedAnnotations.of(this.annotations);
<add> this.metadata = new SimpleAnnotationMetadata(this.className, this.access,
<add> this.enclosingClassName, this.superClassName, this.independentInnerClass,
<add> this.interfaceNames, memberClassNames, annotatedMethods, annotations);
<add> }
<add>
<add> public SimpleAnnotationMetadata getMetadata() {
<add> return this.metadata;
<add> }
<add>
<add> private Source getSource() {
<add> Source source = this.source;
<add> if (source == null) {
<add> source = new Source(this.className);
<add> this.source = source;
<add> }
<add> return source;
<add> }
<add>
<add> private String toClassName(String name) {
<add> return ClassUtils.convertResourcePathToClassName(name);
<add> }
<add>
<add> private boolean isBridge(int access) {
<add> return (access & Opcodes.ACC_BRIDGE) != 0;
<add> }
<add>
<add> private boolean isInterface(int access) {
<add> return (access & Opcodes.ACC_INTERFACE) != 0;
<add> }
<add>
<add> /**
<add> * {@link MergedAnnotation} source.
<add> */
<add> private static final class Source {
<add>
<add> private final String className;
<add>
<add> Source(String className) {
<add> this.className = className;
<add> }
<add>
<add> @Override
<add> public int hashCode() {
<add> return this.className.hashCode();
<add> }
<add>
<add> @Override
<add> public boolean equals(Object obj) {
<add> if (this == obj) {
<add> return true;
<add> }
<add> if (obj == null || getClass() != obj.getClass()) {
<add> return false;
<add> }
<add> return this.className.equals(((Source) obj).className);
<add> }
<add>
<add> @Override
<add> public String toString() {
<add> return this.className;
<add> }
<add>
<add> }
<add>
<add>}
<ide><path>spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMetadataReader.java
<ide> /*
<del> * Copyright 2002-2017 the original author or authors.
<add> * Copyright 2002-2019 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> * {@link MetadataReader} implementation based on an ASM
<ide> * {@link org.springframework.asm.ClassReader}.
<ide> *
<del> * <p>Package-visible in order to allow for repackaging the ASM library
<del> * without effect on users of the {@code core.type} package.
<del> *
<ide> * @author Juergen Hoeller
<ide> * @author Costin Leau
<ide> * @since 2.5
<ide> */
<ide> final class SimpleMetadataReader implements MetadataReader {
<ide>
<del> private final Resource resource;
<add> private static final int PARSING_OPTIONS = ClassReader.SKIP_DEBUG
<add> | ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES;
<ide>
<del> private final ClassMetadata classMetadata;
<add> private final Resource resource;
<ide>
<ide> private final AnnotationMetadata annotationMetadata;
<ide>
<ide>
<ide> SimpleMetadataReader(Resource resource, @Nullable ClassLoader classLoader) throws IOException {
<del> InputStream is = new BufferedInputStream(resource.getInputStream());
<del> ClassReader classReader;
<del> try {
<del> classReader = new ClassReader(is);
<del> }
<del> catch (IllegalArgumentException ex) {
<del> throw new NestedIOException("ASM ClassReader failed to parse class file - " +
<del> "probably due to a new Java class file version that isn't supported yet: " + resource, ex);
<del> }
<del> finally {
<del> is.close();
<del> }
<del>
<del> AnnotationMetadataReadingVisitor visitor = new AnnotationMetadataReadingVisitor(classLoader);
<del> classReader.accept(visitor, ClassReader.SKIP_DEBUG);
<del>
<del> this.annotationMetadata = visitor;
<del> // (since AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisitor)
<del> this.classMetadata = visitor;
<add> SimpleAnnotationMetadataReadingVistor visitor = new SimpleAnnotationMetadataReadingVistor(classLoader);
<add> getClassReader(resource).accept(visitor, PARSING_OPTIONS);
<ide> this.resource = resource;
<add> this.annotationMetadata = visitor.getMetadata();
<ide> }
<ide>
<add> private ClassReader getClassReader(Resource resource)
<add> throws IOException, NestedIOException {
<add> try (InputStream is = new BufferedInputStream(resource.getInputStream())) {
<add> try {
<add> return new ClassReader(is);
<add> }
<add> catch (IllegalArgumentException ex) {
<add> throw new NestedIOException("ASM ClassReader failed to parse class file - " +
<add> "probably due to a new Java class file version that isn't supported yet: " + resource, ex);
<add> }
<add> }
<add> }
<ide>
<ide> @Override
<ide> public Resource getResource() {
<ide> public Resource getResource() {
<ide>
<ide> @Override
<ide> public ClassMetadata getClassMetadata() {
<del> return this.classMetadata;
<add> return this.annotationMetadata;
<ide> }
<ide>
<ide> @Override
<ide><path>spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMethodMetadata.java
<add>/*
<add> * Copyright 2002-2019 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * https://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<add>package org.springframework.core.type.classreading;
<add>
<add>import org.springframework.asm.Opcodes;
<add>import org.springframework.core.annotation.MergedAnnotations;
<add>import org.springframework.core.type.MethodMetadata;
<add>
<add>/**
<add> * {@link MethodMetadata} created from a
<add> * {@link SimpleMethodMetadataReadingVistor}.
<add> *
<add> * @author Phillip Webb
<add> * @since 5.2
<add> */
<add>final class SimpleMethodMetadata implements MethodMetadata {
<add>
<add> private final String methodName;
<add>
<add> private final int access;
<add>
<add> private final String declaringClassName;
<add>
<add> private final String returnTypeName;
<add>
<add> private final MergedAnnotations annotations;
<add>
<add> public SimpleMethodMetadata(String methodName, int access, String declaringClassName,
<add> String returnTypeName, MergedAnnotations annotations) {
<add> this.methodName = methodName;
<add> this.access = access;
<add> this.declaringClassName = declaringClassName;
<add> this.returnTypeName = returnTypeName;
<add> this.annotations = annotations;
<add> }
<add>
<add> @Override
<add> public String getMethodName() {
<add> return this.methodName;
<add> }
<add>
<add> @Override
<add> public String getDeclaringClassName() {
<add> return this.declaringClassName;
<add> }
<add>
<add> @Override
<add> public String getReturnTypeName() {
<add> return this.returnTypeName;
<add> }
<add>
<add> @Override
<add> public boolean isAbstract() {
<add> return (this.access & Opcodes.ACC_ABSTRACT) != 0;
<add> }
<add>
<add> @Override
<add> public boolean isStatic() {
<add> return (this.access & Opcodes.ACC_STATIC) != 0;
<add> }
<add>
<add> @Override
<add> public boolean isFinal() {
<add> return (this.access & Opcodes.ACC_FINAL) != 0;
<add> }
<add>
<add> @Override
<add> public boolean isOverridable() {
<add> return !isStatic() && !isFinal() && !isPrivate();
<add> }
<add>
<add> public boolean isPrivate() {
<add> return (this.access & Opcodes.ACC_PRIVATE) != 0;
<add> }
<add>
<add> @Override
<add> public MergedAnnotations getAnnotations() {
<add> return this.annotations;
<add> }
<add>
<add>}
<ide><path>spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMethodMetadataReadingVistor.java
<add>/*
<add> * Copyright 2002-2019 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * https://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<add>package org.springframework.core.type.classreading;
<add>
<add>import java.util.ArrayList;
<add>import java.util.List;
<add>import java.util.function.Consumer;
<add>
<add>import org.springframework.asm.AnnotationVisitor;
<add>import org.springframework.asm.MethodVisitor;
<add>import org.springframework.asm.SpringAsmInfo;
<add>import org.springframework.asm.Type;
<add>import org.springframework.core.annotation.MergedAnnotation;
<add>import org.springframework.core.annotation.MergedAnnotations;
<add>import org.springframework.core.type.MethodMetadata;
<add>import org.springframework.lang.Nullable;
<add>
<add>/**
<add> * {@link MethodMetadata} returned from a {@link SimpleMetadataReader}.
<add> *
<add> * @author Phillip Webb
<add> * @since 5.2
<add> */
<add>class SimpleMethodMetadataReadingVistor extends MethodVisitor {
<add>
<add> @Nullable
<add> private final ClassLoader classLoader;
<add>
<add> private final String declaringClassName;
<add>
<add> private final int access;
<add>
<add> private final String name;
<add>
<add> private final String descriptor;
<add>
<add> private final List<MergedAnnotation<?>> annotations = new ArrayList<MergedAnnotation<?>>(
<add> 4);
<add>
<add> private final Consumer<SimpleMethodMetadata> consumer;
<add>
<add> private Source source;
<add>
<add> SimpleMethodMetadataReadingVistor(@Nullable ClassLoader classLoader,
<add> String declaringClassName, int access, String name, String descriptor,
<add> Consumer<SimpleMethodMetadata> consumer) {
<add> super(SpringAsmInfo.ASM_VERSION);
<add> this.classLoader = classLoader;
<add> this.declaringClassName = declaringClassName;
<add> this.access = access;
<add> this.name = name;
<add> this.descriptor = descriptor;
<add> this.consumer = consumer;
<add> }
<add>
<add> @Override
<add> public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
<add> return MergedAnnotationReadingVisitor.get(this.classLoader, this::getSource,
<add> descriptor, visible, this.annotations::add);
<add> }
<add>
<add> @Override
<add> public void visitEnd() {
<add> if (!this.annotations.isEmpty()) {
<add> String returnTypeName = Type.getReturnType(this.descriptor).getClassName();
<add> MergedAnnotations annotations = MergedAnnotations.of(this.annotations);
<add> SimpleMethodMetadata metadata = new SimpleMethodMetadata(this.name,
<add> this.access, this.declaringClassName, returnTypeName, annotations);
<add> this.consumer.accept(metadata);
<add> }
<add> }
<add>
<add> private Object getSource() {
<add> Source source = this.source;
<add> if (source == null) {
<add> source = new Source(this.declaringClassName, this.name, this.descriptor);
<add> this.source = source;
<add> }
<add> return source;
<add> }
<add>
<add> /**
<add> * {@link MergedAnnotation} source.
<add> */
<add> static final class Source {
<add>
<add> private final String declaringClassName;
<add>
<add> private final String name;
<add>
<add> private final String descriptor;
<add>
<add> private String string;
<add>
<add> Source(String declaringClassName, String name, String descriptor) {
<add> this.declaringClassName = declaringClassName;
<add> this.name = name;
<add> this.descriptor = descriptor;
<add> }
<add>
<add> @Override
<add> public int hashCode() {
<add> int result = 1;
<add> result = 31 * result + this.declaringClassName.hashCode();
<add> result = 31 * result + this.name.hashCode();
<add> result = 31 * result + this.descriptor.hashCode();
<add> return result;
<add> }
<add>
<add> @Override
<add> public boolean equals(Object obj) {
<add> if (this == obj) {
<add> return true;
<add> }
<add> if (obj == null || getClass() != obj.getClass()) {
<add> return false;
<add> }
<add> Source other = (Source) obj;
<add> boolean result = true;
<add> result = result &= this.declaringClassName.equals(other.declaringClassName);
<add> result = result &= this.name.equals(other.name);
<add> result = result &= this.descriptor.equals(other.descriptor);
<add> return result;
<add> }
<add>
<add> @Override
<add> public String toString() {
<add> String string = this.string;
<add> if (string == null) {
<add> StringBuilder builder = new StringBuilder();
<add> builder.append(this.declaringClassName);
<add> builder.append(".");
<add> builder.append(this.name);
<add> Type[] argumentTypes = Type.getArgumentTypes(this.descriptor);
<add> builder.append("(");
<add> for (Type type : argumentTypes) {
<add> builder.append(type.getClassName());
<add> }
<add> builder.append(")");
<add> string = builder.toString();
<add> this.string = string;
<add> }
<add> return string;
<add> }
<add>
<add> }
<add>
<add>}
<ide><path>spring-core/src/test/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitorTests.java
<ide> *
<ide> * @author Phillip Webb
<ide> */
<add>@SuppressWarnings("deprecation")
<ide> public class AnnotationMetadataReadingVisitorTests
<ide> extends AbstractAnnotationMetadataTests {
<ide>
<ide><path>spring-core/src/test/java/org/springframework/core/type/classreading/MergedAnnotationMetadataVisitorTests.java
<add>/*
<add> * Copyright 2002-2019 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * http://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<add>package org.springframework.core.type.classreading;
<add>
<add>import java.io.IOException;
<add>import java.io.InputStream;
<add>import java.io.OutputStream;
<add>import java.lang.annotation.Retention;
<add>import java.lang.annotation.RetentionPolicy;
<add>
<add>import org.junit.Test;
<add>
<add>import org.springframework.asm.AnnotationVisitor;
<add>import org.springframework.asm.ClassReader;
<add>import org.springframework.asm.ClassVisitor;
<add>import org.springframework.asm.SpringAsmInfo;
<add>import org.springframework.core.annotation.MergedAnnotation;
<add>
<add>import static org.assertj.core.api.Assertions.*;
<add>
<add>/**
<add> * Tests for {@link MergedAnnotationReadingVisitor}.
<add> *
<add> * @author Phillip Webb
<add> */
<add>public class MergedAnnotationMetadataVisitorTests {
<add>
<add> private MergedAnnotation<?> annotation;
<add>
<add> @Test
<add> public void visitWhenHasSimpleTypesCreatesAnnotation() {
<add> loadFrom(WithSimpleTypesAnnotation.class);
<add> assertThat(this.annotation.getType()).isEqualTo(SimpleTypesAnnotation.class);
<add> assertThat(this.annotation.getValue("stringValue")).contains("string");
<add> assertThat(this.annotation.getValue("byteValue")).contains((byte) 1);
<add> assertThat(this.annotation.getValue("shortValue")).contains((short) 2);
<add> assertThat(this.annotation.getValue("intValue")).contains(3);
<add> assertThat(this.annotation.getValue("longValue")).contains(4L);
<add> assertThat(this.annotation.getValue("booleanValue")).contains(true);
<add> assertThat(this.annotation.getValue("charValue")).contains('c');
<add> assertThat(this.annotation.getValue("doubleValue")).contains(5.0);
<add> assertThat(this.annotation.getValue("floatValue")).contains(6.0f);
<add> }
<add>
<add> @Test
<add> public void visitWhenHasSimpleArrayTypesCreatesAnnotation() {
<add> loadFrom(WithSimpleArrayTypesAnnotation.class);
<add> assertThat(this.annotation.getType()).isEqualTo(SimpleArrayTypesAnnotation.class);
<add> assertThat(this.annotation.getValue("stringValue")).contains(
<add> new String[] { "string" });
<add> assertThat(this.annotation.getValue("byteValue")).contains(new byte[] { 1 });
<add> assertThat(this.annotation.getValue("shortValue")).contains(new short[] { 2 });
<add> assertThat(this.annotation.getValue("intValue")).contains(new int[] { 3 });
<add> assertThat(this.annotation.getValue("longValue")).contains(new long[] { 4 });
<add> assertThat(this.annotation.getValue("booleanValue")).contains(
<add> new boolean[] { true });
<add> assertThat(this.annotation.getValue("charValue")).contains(new char[] { 'c' });
<add> assertThat(this.annotation.getValue("doubleValue")).contains(
<add> new double[] { 5.0 });
<add> assertThat(this.annotation.getValue("floatValue")).contains(new float[] { 6.0f });
<add> }
<add>
<add> @Test
<add> public void visitWhenHasEmptySimpleArrayTypesCreatesAnnotation() {
<add> loadFrom(WithSimpleEmptyArrayTypesAnnotation.class);
<add> assertThat(this.annotation.getType()).isEqualTo(SimpleArrayTypesAnnotation.class);
<add> assertThat(this.annotation.getValue("stringValue")).contains(new String[] {});
<add> assertThat(this.annotation.getValue("byteValue")).contains(new byte[] {});
<add> assertThat(this.annotation.getValue("shortValue")).contains(new short[] {});
<add> assertThat(this.annotation.getValue("intValue")).contains(new int[] {});
<add> assertThat(this.annotation.getValue("longValue")).contains(new long[] {});
<add> assertThat(this.annotation.getValue("booleanValue")).contains(new boolean[] {});
<add> assertThat(this.annotation.getValue("charValue")).contains(new char[] {});
<add> assertThat(this.annotation.getValue("doubleValue")).contains(new double[] {});
<add> assertThat(this.annotation.getValue("floatValue")).contains(new float[] {});
<add> }
<add>
<add> @Test
<add> public void visitWhenHasEnumAttributesCreatesAnnotation() {
<add> loadFrom(WithEnumAnnotation.class);
<add> assertThat(this.annotation.getType()).isEqualTo(EnumAnnotation.class);
<add> assertThat(this.annotation.getValue("enumValue")).contains(ExampleEnum.ONE);
<add> assertThat(this.annotation.getValue("enumArrayValue")).contains(
<add> new ExampleEnum[] { ExampleEnum.ONE, ExampleEnum.TWO });
<add> }
<add>
<add> @Test
<add> public void visitWhenHasAnnotationAttributesCreatesAnnotation() {
<add> loadFrom(WithAnnotationAnnotation.class);
<add> assertThat(this.annotation.getType()).isEqualTo(AnnotationAnnotation.class);
<add> MergedAnnotation<NestedAnnotation> value = this.annotation.getAnnotation(
<add> "annotationValue", NestedAnnotation.class);
<add> assertThat(value.isPresent()).isTrue();
<add> assertThat(value.getString(MergedAnnotation.VALUE)).isEqualTo("a");
<add> MergedAnnotation<NestedAnnotation>[] arrayValue = this.annotation.getAnnotationArray(
<add> "annotationArrayValue", NestedAnnotation.class);
<add> assertThat(arrayValue).hasSize(2);
<add> assertThat(arrayValue[0].getString(MergedAnnotation.VALUE)).isEqualTo("b");
<add> assertThat(arrayValue[1].getString(MergedAnnotation.VALUE)).isEqualTo("c");
<add> }
<add>
<add> @Test
<add> public void visitWhenHasClassAttributesCreatesAnnotation() {
<add> loadFrom(WithClassAnnotation.class);
<add> assertThat(this.annotation.getType()).isEqualTo(ClassAnnotation.class);
<add> assertThat(this.annotation.getString("classValue")).isEqualTo(InputStream.class.getName());
<add> assertThat(this.annotation.getClass("classValue")).isEqualTo(InputStream.class);
<add> assertThat(this.annotation.getValue("classValue")).contains(InputStream.class);
<add> assertThat(this.annotation.getStringArray("classArrayValue")).containsExactly(OutputStream.class.getName());
<add> assertThat(this.annotation.getValue("classArrayValue")).contains(new Class<?>[] {OutputStream.class});
<add> }
<add>
<add> private void loadFrom(Class<?> type) {
<add> ClassVisitor visitor = new ClassVisitor(SpringAsmInfo.ASM_VERSION) {
<add>
<add> @Override
<add> public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
<add> return MergedAnnotationReadingVisitor.get(getClass().getClassLoader(),
<add> null, descriptor, visible,
<add> annotation -> MergedAnnotationMetadataVisitorTests.this.annotation = annotation);
<add> }
<add>
<add> };
<add> try {
<add> new ClassReader(type.getName()).accept(visitor, ClassReader.SKIP_DEBUG
<add> | ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES);
<add> }
<add> catch (IOException ex) {
<add> throw new IllegalStateException(ex);
<add> }
<add> }
<add>
<add> @SimpleTypesAnnotation(stringValue = "string", byteValue = 1, shortValue = 2, intValue = 3, longValue = 4, booleanValue = true, charValue = 'c', doubleValue = 5.0, floatValue = 6.0f)
<add> static class WithSimpleTypesAnnotation {
<add>
<add> }
<add>
<add> @Retention(RetentionPolicy.RUNTIME)
<add> @interface SimpleTypesAnnotation {
<add>
<add> String stringValue();
<add>
<add> byte byteValue();
<add>
<add> short shortValue();
<add>
<add> int intValue();
<add>
<add> long longValue();
<add>
<add> boolean booleanValue();
<add>
<add> char charValue();
<add>
<add> double doubleValue();
<add>
<add> float floatValue();
<add>
<add> }
<add>
<add> @SimpleArrayTypesAnnotation(stringValue = "string", byteValue = 1, shortValue = 2, intValue = 3, longValue = 4, booleanValue = true, charValue = 'c', doubleValue = 5.0, floatValue = 6.0f)
<add> static class WithSimpleArrayTypesAnnotation {
<add>
<add> }
<add>
<add> @SimpleArrayTypesAnnotation(stringValue = {}, byteValue = {}, shortValue = {}, intValue = {}, longValue = {}, booleanValue = {}, charValue = {}, doubleValue = {}, floatValue = {})
<add> static class WithSimpleEmptyArrayTypesAnnotation {
<add>
<add> }
<add>
<add> @Retention(RetentionPolicy.RUNTIME)
<add> @interface SimpleArrayTypesAnnotation {
<add>
<add> String[] stringValue();
<add>
<add> byte[] byteValue();
<add>
<add> short[] shortValue();
<add>
<add> int[] intValue();
<add>
<add> long[] longValue();
<add>
<add> boolean[] booleanValue();
<add>
<add> char[] charValue();
<add>
<add> double[] doubleValue();
<add>
<add> float[] floatValue();
<add>
<add> }
<add>
<add> @EnumAnnotation(enumValue = ExampleEnum.ONE, enumArrayValue = { ExampleEnum.ONE,
<add> ExampleEnum.TWO })
<add> static class WithEnumAnnotation {
<add>
<add> }
<add>
<add> @Retention(RetentionPolicy.RUNTIME)
<add> @interface EnumAnnotation {
<add>
<add> ExampleEnum enumValue();
<add>
<add> ExampleEnum[] enumArrayValue();
<add>
<add> }
<add>
<add> enum ExampleEnum {
<add> ONE, TWO, THREE
<add> }
<add>
<add> @AnnotationAnnotation(annotationValue = @NestedAnnotation("a"), annotationArrayValue = {
<add> @NestedAnnotation("b"), @NestedAnnotation("c") })
<add> static class WithAnnotationAnnotation {
<add>
<add> }
<add>
<add> @Retention(RetentionPolicy.RUNTIME)
<add> @interface AnnotationAnnotation {
<add>
<add> NestedAnnotation annotationValue();
<add>
<add> NestedAnnotation[] annotationArrayValue();
<add>
<add> }
<add>
<add> @Retention(RetentionPolicy.RUNTIME)
<add> @interface NestedAnnotation {
<add>
<add> String value() default "";
<add>
<add> }
<add>
<add> @ClassAnnotation(classValue = InputStream.class, classArrayValue = OutputStream.class)
<add> static class WithClassAnnotation {
<add>
<add> }
<add>
<add>
<add> @Retention(RetentionPolicy.RUNTIME)
<add> @interface ClassAnnotation {
<add>
<add> Class<?> classValue();
<add>
<add> Class<?>[] classArrayValue();
<add>
<add> }
<add>
<add>}
<ide><path>spring-core/src/test/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataTests.java
<add>/*
<add> * Copyright 2002-2019 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * http://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<add>package org.springframework.core.type.classreading;
<add>
<add>import org.springframework.core.type.AbstractAnnotationMetadataTests;
<add>import org.springframework.core.type.AnnotationMetadata;
<add>import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
<add>
<add>/**
<add> * Tests for {@link SimpleAnnotationMetadata} and
<add> * {@link SimpleAnnotationMetadataReadingVistor}.
<add> *
<add> * @author Phillip Webb
<add> */
<add>public class SimpleAnnotationMetadataTests extends AbstractAnnotationMetadataTests {
<add>
<add> @Override
<add> protected AnnotationMetadata get(Class<?> source) {
<add> try {
<add> return new SimpleMetadataReaderFactory(
<add> source.getClassLoader()).getMetadataReader(
<add> source.getName()).getAnnotationMetadata();
<add> }
<add> catch (Exception ex) {
<add> throw new IllegalStateException(ex);
<add> }
<add> }
<add>
<add>}
<ide><path>spring-core/src/test/java/org/springframework/core/type/classreading/SimpleMethodMetadataTests.java
<add>/*
<add> * Copyright 2002-2019 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * http://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<add>package org.springframework.core.type.classreading;
<add>
<add>import org.springframework.core.type.AbstractMethodMetadataTests;
<add>import org.springframework.core.type.AnnotationMetadata;
<add>import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
<add>
<add>/**
<add> * Tests for {@link SimpleMethodMetadata} and
<add> * {@link SimpleMethodMetadataReadingVistor}.
<add> *
<add> * @author Phillip Webb
<add> */
<add>public class SimpleMethodMetadataTests extends AbstractMethodMetadataTests {
<add>
<add> @Override
<add> protected AnnotationMetadata get(Class<?> source) {
<add> try {
<add> return new SimpleMetadataReaderFactory(
<add> source.getClassLoader()).getMetadataReader(
<add> source.getName()).getAnnotationMetadata();
<add> }
<add> catch (Exception ex) {
<add> throw new IllegalStateException(ex);
<add> }
<add> }
<add>
<add>} | 18 |
Ruby | Ruby | add documentation to generated routes | bfafa999ddaa203224ac0222203517a0d2a3f6bf | <ide><path>guides/code/getting_started/config/routes.rb
<ide> # just remember to delete public/index.html.
<ide> root :to => "welcome#index"
<ide>
<del> # See how all your routes lay out with "rake routes"
<add> # See how all your routes lay out by running `$ rake routes`
<add> # or by visiting `/rails/info/routes` in your browser
<ide>
<ide> # This is a legacy wild controller route that's not recommended for RESTful applications.
<ide> # Note: This route will make all actions in every controller accessible via GET requests.
<ide><path>railties/lib/rails/generators/rails/app/templates/config/routes.rb
<ide> # end
<ide>
<ide>
<del> # See how all your routes lay out with "rake routes".
<add> # See how all your routes lay out by running `$ rake routes`
<add> # or by visiting `/rails/info/routes` in your browser
<ide> end | 2 |
Text | Text | post about 0.11.1 | 223f22a30d097e1c878d14cf666858e3bb3046c9 | <ide><path>doc/blog/release/v0.11.1.md
<add>date: Fri Apr 19 09:11:40 PDT 2013
<add>version: 0.11.1
<add>category: release
<add>title: Node v0.11.1 (Unstable)
<add>slug: node-v0-11-1-unstable
<add>
<add>2013.04.19, Version 0.11.1 (Unstable)
<add>
<add>* V8: upgrade to 3.18.0
<add>
<add>* uv: Upgrade to v0.11.1
<add>
<add>* http: split into multiple separate modules (Timothy J Fontaine)
<add>
<add>* http: escape unsafe characters in request path (Ben Noordhuis)
<add>
<add>* url: Escape all unwise characters (isaacs)
<add>
<add>* build: depend on v8 postmortem-metadata if enabled (Paddy Byers)
<add>
<add>* etw: update prototypes to match dtrace provider (Timothy J Fontaine)
<add>
<add>* buffer: change output of Buffer.prototype.toJSON() (David Braun)
<add>
<add>* dtrace: actually use the _handle.fd value (Timothy J Fontaine)
<add>
<add>* dtrace: pass more arguments to probes (Dave Pacheco)
<add>
<add>* build: allow building with dtrace on osx (Dave Pacheco)
<add>
<add>* zlib: allow passing options to convenience methods (Kyle Robinson Young)
<add>
<add>
<add>Source Code: http://nodejs.org/dist/v0.11.1/node-v0.11.1.tar.gz
<add>
<add>Macintosh Installer (Universal): http://nodejs.org/dist/v0.11.1/node-v0.11.1.pkg
<add>
<add>Windows Installer: http://nodejs.org/dist/v0.11.1/node-v0.11.1-x86.msi
<add>
<add>Windows x64 Installer: http://nodejs.org/dist/v0.11.1/x64/node-v0.11.1-x64.msi
<add>
<add>Windows x64 Files: http://nodejs.org/dist/v0.11.1/x64/
<add>
<add>Linux 32-bit Binary: http://nodejs.org/dist/v0.11.1/node-v0.11.1-linux-x86.tar.gz
<add>
<add>Linux 64-bit Binary: http://nodejs.org/dist/v0.11.1/node-v0.11.1-linux-x64.tar.gz
<add>
<add>Solaris 32-bit Binary: http://nodejs.org/dist/v0.11.1/node-v0.11.1-sunos-x86.tar.gz
<add>
<add>Solaris 64-bit Binary: http://nodejs.org/dist/v0.11.1/node-v0.11.1-sunos-x64.tar.gz
<add>
<add>Other release files: http://nodejs.org/dist/v0.11.1/
<add>
<add>Website: http://nodejs.org/docs/v0.11.1/
<add>
<add>Documentation: http://nodejs.org/docs/v0.11.1/api/
<add>
<add>Shasums:
<add>
<add>```
<add>83f440046d64619b974487e3445d541fa1310ec6 node-v0.11.1-darwin-x64.tar.gz
<add>684118ba684d21f07bf1095727a15457d301edf9 node-v0.11.1-darwin-x86.tar.gz
<add>2c71490f3664421f58145f2945018efeb4d43652 node-v0.11.1-linux-x64.tar.gz
<add>07b7ed48a50792605229efb2c256a3681d242b0e node-v0.11.1-linux-x86.tar.gz
<add>bbe383ba0954f47812ff5d853069069901d8160d node-v0.11.1-sunos-x64.tar.gz
<add>6782ff3bdd3af79d8ba8c8b0f352ca2106fcfafc node-v0.11.1-sunos-x86.tar.gz
<add>47bf9b530d662f67b7b07729d83cd4f5575846b8 node-v0.11.1-x86.msi
<add>b98e549850355be6a107044ca6a000518599a982 node-v0.11.1.pkg
<add>fe13c36f4d9116ed718af9894aab989d74a9d91c node-v0.11.1.tar.gz
<add>655ab3f0ce8227ffd68714491c2dd5aa7bdc0d10 node.exe
<add>43a8f8a9cf53c0a2318b2288b6ba0e0f2a052858 node.exp
<add>d54e5b303a0568f803ad09aa802b7f95b676180c node.lib
<add>08098d40b362018f5df09f302d85c5834f127292 node.pdb
<add>e930572aa6c4ab761de2de80b208f01ce829bee1 x64/node-v0.11.1-x64.msi
<add>e60d1b60628c0be38c05293a03dcef5e2454fb55 x64/node.exe
<add>774cca135c53ec4045728c08fbf9231230f953d9 x64/node.exp
<add>b9e34979c4275f9ee0f0d87b698ae323905314d6 x64/node.lib
<add>34dbcf9662876a395166370027c6d374b99f85e7 x64/node.pdb
<add>``` | 1 |
Javascript | Javascript | add namedchunkgroups tests | e85d9d84478da447d93634832c780debed5d8d21 | <ide><path>test/Stats.test.js
<ide> const webpack = require("..");
<ide> const MemoryFs = require("memory-fs");
<ide>
<del>describe("Stats", () => {
<del> it("should print env string in stats", done => {
<del> const compiler = webpack({
<del> context: __dirname,
<del> entry: "./fixtures/a"
<del> });
<add>const compile = options => {
<add> return new Promise((resolve, reject) => {
<add> const compiler = webpack(options);
<ide> compiler.outputFileSystem = new MemoryFs();
<ide> compiler.run((err, stats) => {
<del> if (err) return done(err);
<del> try {
<del> expect(
<del> stats.toString({
<del> all: false,
<del> env: true,
<del> _env: "production"
<del> })
<del> ).toBe('Environment (--env): "production"');
<del> expect(
<del> stats.toString({
<del> all: false,
<del> env: true,
<del> _env: {
<del> prod: ["foo", "bar"],
<del> baz: true
<del> }
<del> })
<del> ).toBe(
<del> "Environment (--env): {\n" +
<del> ' "prod": [\n' +
<del> ' "foo",\n' +
<del> ' "bar"\n' +
<del> " ],\n" +
<del> ' "baz": true\n' +
<del> "}"
<del> );
<del> done();
<del> } catch (e) {
<del> done(e);
<add> if (err) {
<add> reject(err);
<add> } else {
<add> resolve(stats);
<ide> }
<ide> });
<ide> });
<del> it("should omit all properties with all false", done => {
<del> const compiler = webpack({
<add>};
<add>
<add>describe("Stats", () => {
<add> it("should print env string in stats", async () => {
<add> const stats = await compile({
<ide> context: __dirname,
<ide> entry: "./fixtures/a"
<ide> });
<del> compiler.outputFileSystem = new MemoryFs();
<del> compiler.run((err, stats) => {
<del> if (err) return done(err);
<del> try {
<del> expect(
<del> stats.toJson({
<del> all: false
<del> })
<del> ).toEqual({
<del>
<del> });
<del> done();
<del> } catch (e) {
<del> done(e);
<del> }
<add> expect(
<add> stats.toString({
<add> all: false,
<add> env: true,
<add> _env: "production"
<add> })
<add> ).toBe('Environment (--env): "production"');
<add> expect(
<add> stats.toString({
<add> all: false,
<add> env: true,
<add> _env: {
<add> prod: ["foo", "bar"],
<add> baz: true
<add> }
<add> })
<add> ).toBe(
<add> "Environment (--env): {\n" +
<add> ' "prod": [\n' +
<add> ' "foo",\n' +
<add> ' "bar"\n' +
<add> " ],\n" +
<add> ' "baz": true\n' +
<add> "}"
<add> );
<add> });
<add> it("should omit all properties with all false", async () => {
<add> const stats = await compile({
<add> context: __dirname,
<add> entry: "./fixtures/a"
<add> });
<add> expect(
<add> stats.toJson({
<add> all: false
<add> })
<add> ).toEqual({});
<add> });
<add> describe("chunkGroups", () => {
<add> it("should be empty when there is no additional chunks", async () => {
<add> const stats = await compile({
<add> context: __dirname,
<add> entry: {
<add> entryA: "./fixtures/a",
<add> entryB: "./fixtures/b"
<add> }
<add> });
<add> expect(
<add> stats.toJson({
<add> all: false,
<add> chunkGroups: true
<add> })
<add> ).toMatchInlineSnapshot(`
<add>Object {
<add> "namedChunkGroups": Object {},
<add>}
<add>`);
<add> });
<add> it("should contain additional chunks", async () => {
<add> const stats = await compile({
<add> context: __dirname,
<add> entry: {
<add> entryA: "./fixtures/a",
<add> entryB: "./fixtures/chunk-b"
<add> }
<add> });
<add> expect(
<add> stats.toJson({
<add> all: false,
<add> chunkGroups: true
<add> })
<add> ).toMatchInlineSnapshot(`
<add>Object {
<add> "namedChunkGroups": Object {
<add> "chunkB": Object {
<add> "assets": Array [
<add> "chunkB.js",
<add> ],
<add> "childAssets": Object {},
<add> "children": Object {},
<add> "chunks": Array [
<add> 787,
<add> ],
<add> "name": "chunkB",
<add> },
<add> },
<add>}
<add>`);
<ide> });
<ide> });
<ide> });
<ide><path>test/fixtures/chunk-b.js
<add>module.exports = () => {
<add> return import(/* webpackChunkName: "chunkB" */ "./b");
<add>}; | 2 |
PHP | PHP | add space between lines of code | 4a38f403c75208cecab46ae2f05410cf351e741a | <ide><path>src/Illuminate/Validation/Validator.php
<ide> protected function validateRequiredIf($attribute, $value, $parameters)
<ide> $this->requireParameterCount(2, $parameters, 'required_if');
<ide>
<ide> $data = array_get($this->data, $parameters[0]);
<add>
<ide> $values = array_slice($parameters, 1);
<ide>
<ide> if (in_array($data, $values)) | 1 |
Ruby | Ruby | dry actionmailer code | 971f4ff829f7ead6381e0fead93b33104b037cdd | <ide><path>actionmailer/lib/action_mailer/base.rb
<ide> class Base < AbstractController::Base
<ide> # Alias controller_path to mailer_name so render :partial in views work.
<ide> alias :controller_path :mailer_name
<ide>
<del> # Add a part to a multipart message, with the given content-type. The
<del> # part itself is yielded to the block so that other properties (charset,
<del> # body, headers, etc.) can be set on it.
<del> def part(params)
<del> params = {:content_type => params} if String === params
<del> if custom_headers = params.delete(:headers)
<del> ActiveSupport::Deprecation.warn('Passing custom headers with :headers => {} is deprecated. ' <<
<del> 'Please just pass in custom headers directly.', caller[0,10])
<del> params.merge!(custom_headers)
<del> end
<del> part = Mail::Part.new(params)
<del> yield part if block_given?
<del> @parts << part
<del> end
<del>
<del> # Add an attachment to a multipart message. This is simply a part with the
<del> # content-disposition set to "attachment".
<del> def attachment(params, &block)
<del> super # Run deprecation hooks
<del>
<del> params = { :content_type => params } if String === params
<del> params = { :content_disposition => "attachment",
<del> :content_transfer_encoding => "base64" }.merge(params)
<del>
<del> part(params, &block)
<del> end
<del>
<ide> class << self
<ide> attr_writer :mailer_name
<ide>
<ide> def matches_dynamic_method?(method_name) #:nodoc:
<ide> superclass_delegating_reader :delivery_method
<ide> self.delivery_method = :smtp
<ide>
<add> # Add a part to a multipart message, with the given content-type. The
<add> # part itself is yielded to the block so that other properties (charset,
<add> # body, headers, etc.) can be set on it.
<add> def part(params)
<add> params = {:content_type => params} if String === params
<add> if custom_headers = params.delete(:headers)
<add> ActiveSupport::Deprecation.warn('Passing custom headers with :headers => {} is deprecated. ' <<
<add> 'Please just pass in custom headers directly.', caller[0,10])
<add> params.merge!(custom_headers)
<add> end
<add> part = Mail::Part.new(params)
<add> yield part if block_given?
<add> @parts << part
<add> end
<add>
<add> # Add an attachment to a multipart message. This is simply a part with the
<add> # content-disposition set to "attachment".
<add> def attachment(params, &block)
<add> super # Run deprecation hooks
<add>
<add> params = { :content_type => params } if String === params
<add> params = { :content_disposition => "attachment",
<add> :content_transfer_encoding => "base64" }.merge(params)
<add>
<add> part(params, &block)
<add> end
<add>
<ide> # Instantiate a new mailer object. If +method_name+ is not +nil+, the mailer
<ide> # will be initialized according to the named method. If not, the mailer will
<ide> # remain uninitialized (useful when you only need to invoke the "receive"
<ide> # method, for instance).
<del> def initialize(method_name=nil, *args) #:nodoc:
<add> def initialize(method_name=nil, *args)
<ide> super()
<ide> process(method_name, *args) if method_name
<ide> end
<ide>
<ide> # Process the mailer via the given +method_name+. The body will be
<del> # rendered and a new TMail::Mail object created.
<del> def process(method_name, *args) #:nodoc:
<add> # rendered and a new Mail object created.
<add> def process(method_name, *args)
<ide> initialize_defaults(method_name)
<ide> super
<ide>
<ide> def deliver!(mail = @mail)
<ide> # Set up the default values for the various instance variables of this
<ide> # mailer. Subclasses may override this method to provide different
<ide> # defaults.
<del> def initialize_defaults(method_name)
<add> def initialize_defaults(method_name) #:nodoc:
<ide> @charset ||= @@default_charset.dup
<ide> @content_type ||= @@default_content_type.dup
<ide> @implicit_parts_order ||= @@default_implicit_parts_order.dup
<ide> def initialize_defaults(method_name)
<ide> super # Run deprecation hooks
<ide> end
<ide>
<del> def create_parts
<add> def create_parts #:nodoc:
<ide> super # Run deprecation hooks
<ide>
<ide> if String === response_body
<del> @parts.unshift Mail::Part.new(
<del> :content_type => ["text", "plain", {:charset => charset}],
<del> :content_disposition => "inline",
<del> :body => response_body
<del> )
<add> @parts.unshift create_inline_part(response_body)
<ide> else
<ide> self.class.template_root.find_all(@template, {}, mailer_name).each do |template|
<del> ct = template.mime_type ? template.mime_type.to_s : "text/plain"
<del> main_type, sub_type = ct.split("/")
<del> @parts << Mail::Part.new(
<del> :content_type => [main_type, sub_type, {:charset => charset}],
<del> :content_disposition => "inline",
<del> :body => render_to_body(:_template => template)
<del> )
<add> @parts << create_inline_part(render_to_body(:_template => template), template.mime_type)
<ide> end
<ide>
<ide> if @parts.size > 1
<ide> def create_parts
<ide> end
<ide> end
<ide>
<del> def sort_parts(parts, order = [])
<add> def create_inline_part(body, mime_type=nil) #:nodoc:
<add> ct = mime_type || "text/plain"
<add> main_type, sub_type = split_content_type(ct.to_s)
<add>
<add> Mail::Part.new(
<add> :content_type => [main_type, sub_type, {:charset => charset}],
<add> :content_disposition => "inline",
<add> :body => body
<add> )
<add> end
<add>
<add> def sort_parts(parts, order = []) #:nodoc:
<ide> order = order.collect { |s| s.downcase }
<ide>
<ide> parts = parts.sort do |a, b|
<ide> def sort_parts(parts, order = [])
<ide> parts
<ide> end
<ide>
<del> def create_mail
<add> def create_mail #:nodoc:
<ide> m = Mail.new
<ide>
<ide> m.subject, = quote_any_if_necessary(charset, subject)
<ide> def create_mail
<ide> headers.each { |k, v| m[k] = v }
<ide>
<ide> real_content_type, ctype_attrs = parse_content_type
<add> main_type, sub_type = split_content_type(real_content_type)
<ide>
<ide> if @parts.empty?
<del> main_type, sub_type = split_content_type(real_content_type)
<ide> m.content_type([main_type, sub_type, ctype_attrs])
<ide> m.body = body
<ide> elsif @parts.size == 1 && @parts.first.parts.empty?
<del> main_type, sub_type = split_content_type(real_content_type)
<ide> m.content_type([main_type, sub_type, ctype_attrs])
<ide> m.body = @parts.first.body.encoded
<ide> else
<ide> def create_mail
<ide>
<ide> if real_content_type =~ /multipart/
<ide> ctype_attrs.delete "charset"
<del> main_type, sub_type = split_content_type(real_content_type)
<ide> m.content_type([main_type, sub_type, ctype_attrs])
<ide> end
<ide> end
<ide>
<ide> @mail = m
<ide> end
<ide>
<del> def split_content_type(ct)
<add> def split_content_type(ct) #:nodoc:
<ide> ct.to_s.split("/")
<ide> end
<ide>
<del> def parse_content_type(defaults=nil)
<del> if content_type.blank?
<del> return defaults ?
<del> [ defaults.content_type, { 'charset' => defaults.charset } ] :
<del> [ nil, {} ]
<del> end
<del> ctype, *attrs = content_type.split(/;\s*/)
<del> attrs = attrs.inject({}) { |h,s| k,v = s.split(/=/, 2); h[k] = v; h }
<del> [ctype, {"charset" => charset || defaults && defaults.charset}.merge(attrs)]
<add> def parse_content_type(defaults=nil) #:nodoc:
<add> if content_type.blank?
<add> if defaults
<add> [ defaults.content_type, { 'charset' => defaults.charset } ]
<add> else
<add> [ nil, {} ]
<add> end
<add> else
<add> ctype, *attrs = content_type.split(/;\s*/)
<add> attrs = attrs.inject({}) { |h,s| k,v = s.split(/\=/, 2); h[k] = v; h }
<add> [ctype, {"charset" => charset || defaults && defaults.charset}.merge(attrs)]
<add> end
<ide> end
<ide>
<del>
<ide> end
<ide> end | 1 |
Go | Go | remove unused id field from builder | a6abd57b83dc0aaf0cedeeb488c8a41262e46b7d | <ide><path>api/types/backend/backend.go
<ide> type ContainerCommitConfig struct {
<ide> Changes []string
<ide> }
<ide>
<del>// ProgressWriter is an interface
<del>// to transport progress streams.
<add>// ProgressWriter is a data object to transport progress streams to the client
<ide> type ProgressWriter struct {
<ide> Output io.Writer
<ide> StdoutFormatter *streamformatter.StdoutFormatter
<ide><path>builder/dockerfile/builder.go
<ide> type Builder struct {
<ide> buildArgs *buildArgs
<ide> directive parser.Directive
<ide>
<del> // TODO: remove once docker.Commit can receive a tag
<del> id string
<del>
<ide> imageCache builder.ImageCache
<ide> from builder.Image
<ide> }
<ide> func NewBuilder(clientCtx context.Context, config *types.ImageBuildOptions, back
<ide> context: buildContext,
<ide> runConfig: new(container.Config),
<ide> tmpContainers: map[string]struct{}{},
<del> id: stringid.GenerateNonCryptoID(),
<ide> buildArgs: newBuildArgs(config.BuildArgs),
<ide> directive: parser.Directive{
<ide> EscapeSeen: false, | 2 |
Ruby | Ruby | avoid shadowed variable | 310918f6a194bf5752fe1025930881756f5d8a8e | <ide><path>actionview/lib/action_view/helpers/asset_tag_helper.rb
<ide> def image_tag(source, options = {})
<ide> end
<ide>
<ide> if options[:srcset] && !options[:srcset].is_a?(String)
<del> options[:srcset] = options[:srcset].map do |src, size|
<del> src_path = path_to_image(src, skip_pipeline: skip_pipeline)
<add> options[:srcset] = options[:srcset].map do |src_path, size|
<add> src_path = path_to_image(src_path, skip_pipeline: skip_pipeline)
<ide> "#{src_path} #{size}"
<ide> end.join(", ")
<ide> end | 1 |
Ruby | Ruby | move `shared_examples` and `matcher` into specs | b7135eec493c1b2cad69b934bbf0d1aefbcbf8ab | <ide><path>Library/Homebrew/cask/spec/cask/audit_spec.rb
<ide> describe Hbc::Audit do
<del> include AuditMatchers
<add> def include_msg?(messages, msg)
<add> if msg.is_a?(Regexp)
<add> Array(messages).any? { |m| m =~ msg }
<add> else
<add> Array(messages).include?(msg)
<add> end
<add> end
<add>
<add> matcher :pass do
<add> match do |audit|
<add> !audit.errors? && !audit.warnings?
<add> end
<add> end
<add>
<add> matcher :fail do
<add> match(&:errors?)
<add> end
<add>
<add> matcher :warn do
<add> match do |audit|
<add> audit.warnings? && !audit.errors?
<add> end
<add> end
<add>
<add> matcher :fail_with do |error_msg|
<add> match do |audit|
<add> include_msg?(audit.errors, error_msg)
<add> end
<add> end
<add>
<add> matcher :warn_with do |warning_msg|
<add> match do |audit|
<add> include_msg?(audit.warnings, warning_msg)
<add> end
<add> end
<ide>
<ide> let(:cask) { instance_double(Hbc::Cask) }
<ide> let(:download) { false }
<ide><path>Library/Homebrew/cask/spec/cask/dsl/version_spec.rb
<ide> describe Hbc::DSL::Version do
<del> include ExpectationsHashHelper
<del>
<del> let(:version) { described_class.new(raw_version) }
<add> shared_examples "expectations hash" do |input_name, expectations|
<add> expectations.each do |input_value, expected_output|
<add> context "when #{input_name} is #{input_value.inspect}" do
<add> let(input_name.to_sym) { input_value }
<add> it { is_expected.to eq expected_output }
<add> end
<add> end
<add> end
<ide>
<ide> shared_examples "version equality" do
<ide> let(:raw_version) { "1.2.3" }
<ide> end
<ide> end
<ide>
<add> let(:version) { described_class.new(raw_version) }
<add>
<ide> describe "#==" do
<ide> subject { version == other }
<ide> include_examples "version equality"
<ide><path>Library/Homebrew/cask/spec/support/audit_matchers.rb
<del>module AuditMatchers
<del> extend RSpec::Matchers::DSL
<del>
<del> matcher :pass do
<del> match do |audit|
<del> !audit.errors? && !audit.warnings?
<del> end
<del> end
<del>
<del> matcher :fail do
<del> match(&:errors?)
<del> end
<del>
<del> matcher :warn do
<del> match do |audit|
<del> audit.warnings? && !audit.errors?
<del> end
<del> end
<del>
<del> matcher :fail_with do |error_msg|
<del> match do |audit|
<del> include_msg?(audit.errors, error_msg)
<del> end
<del> end
<del>
<del> matcher :warn_with do |warning_msg|
<del> match do |audit|
<del> include_msg?(audit.warnings, warning_msg)
<del> end
<del> end
<del>
<del> def include_msg?(messages, msg)
<del> if msg.is_a?(Regexp)
<del> Array(messages).any? { |m| m =~ msg }
<del> else
<del> Array(messages).include?(msg)
<del> end
<del> end
<del>end
<ide><path>Library/Homebrew/cask/spec/support/expectations_hash_helper.rb
<del>module ExpectationsHashHelper
<del> shared_examples "expectations hash" do |input_name, expectations|
<del> expectations.each do |input_value, expected_output|
<del> context "when #{input_name} is #{input_value.inspect}" do
<del> let(input_name.to_sym) { input_value }
<del> it { is_expected.to eq expected_output }
<del> end
<del> end
<del> end
<del>end | 4 |
Python | Python | add tests for deprecation warnings | 830126cd7c5853daf50a9bf4bd3ac649096182b6 | <ide><path>numpy/core/tests/test_deprecations.py
<add>"""
<add>"Tests related to deprecation warnings. Also a convenient place
<add>to document how deprecations should eventually be turned into errors.
<add>"""
<add>import numpy as np
<add>import warnings
<add>
<add>
<add>def check_for_warning(f, category):
<add> raised = False
<add> try:
<add> f()
<add> except category:
<add> raised = True
<add> print np.__file__
<add> np.testing.assert_(raised)
<add>
<add>
<add>def check_does_not_raise(f, category):
<add> raised = False
<add> try:
<add> f()
<add> except category:
<add> raised = True
<add> np.testing.assert_(not raised)
<add>
<add>
<add>class TestFloatIndexDeprecation(object):
<add> """
<add> These test that DeprecationWarnings get raised when you
<add> try to use scalar indices that are not integers e.g. a[0.0],
<add> a[1.5, 0].
<add>
<add> grep PyIndex_Check_Or_Unsupported numpy/core/src/multiarray/* for
<add> all the calls to DEPRECATE().
<add>
<add> When 2.4 support is dropped PyIndex_Check_Or_Unsupported should
<add> be removed from npy_pycompat.h and changed to just PyIndex_Check.
<add> """
<add> def setUp(self):
<add> warnings.filterwarnings("error", message="non-integer",
<add> category=DeprecationWarning)
<add>
<add> def tearDown(self):
<add> warnings.filterwarnings("default", message="non-integer",
<add> category=DeprecationWarning)
<add>
<add> def test_deprecations(self):
<add> a = np.array([[[5]]])
<add> yield check_for_warning, lambda: a[0.0], DeprecationWarning
<add> yield check_for_warning, lambda: a[0, 0.0], DeprecationWarning
<add> yield check_for_warning, lambda: a[0.0, 0], DeprecationWarning
<add> yield check_for_warning, lambda: a[0.0, :], DeprecationWarning
<add> yield check_for_warning, lambda: a[:, 0.0], DeprecationWarning
<add> yield check_for_warning, lambda: a[:, 0.0, :], DeprecationWarning
<add> yield check_for_warning, lambda: a[0.0, :, :], DeprecationWarning
<add> # XXX: These do issue DeprecationWarnings but for some reason the
<add> # warning filter does not turn them into exceptions. I thought
<add> # there was an overzealous PyExc_Clear to blame, but after redefining
<add> # it with a macro and making it print, there seems to be none taking
<add> # place after that warning state is set. The relevant code is in
<add> # _tuple_of_integers in numpy/core/src/multiarray/mapping.c.
<add>
<add> # yield check_for_warning, lambda: a[0, 0, 0.0], DeprecationWarning
<add> # yield check_for_warning, lambda: a[0.0, 0, 0], DeprecationWarning
<add> # yield check_for_warning, lambda: a[0, 0.0, 0], DeprecationWarning
<add>
<add> def test_valid_not_deprecated(self):
<add> a = np.array([[[5]]])
<add> yield (check_does_not_raise, lambda: a[np.array([0])],
<add> DeprecationWarning)
<add> yield (check_does_not_raise, lambda: a[[0, 0]],
<add> DeprecationWarning)
<add> yield (check_does_not_raise, lambda: a[:, [0, 0]],
<add> DeprecationWarning)
<add> yield (check_does_not_raise, lambda: a[:, 0, :],
<add> DeprecationWarning)
<add> yield (check_does_not_raise, lambda: a[:, :, :],
<add> DeprecationWarning) | 1 |
Text | Text | add kontent example to preview section | 7aa397f32ed9a22c83d477b2dc441ce9e5f96afd | <ide><path>docs/advanced-features/preview-mode.md
<ide> description: Next.js has the preview mode for statically generated pages. You ca
<ide> <li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-buttercms">ButterCMS Example</a> (<a href="https://next-blog-buttercms.now.sh/">Demo</a>)</li>
<ide> <li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-storyblok">Storyblok Example</a> (<a href="https://next-blog-storyblok.now.sh/">Demo</a>)</li>
<ide> <li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-graphcms">GraphCMS Example</a> (<a href="https://next-blog-graphcms.now.sh/">Demo</a>)</li>
<add> <li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-kontent">Kontent Example</a> (<a href="https://next-blog-kontent.vercel.app//">Demo</a>)</li>
<ide> </ul>
<ide> </details>
<ide> | 1 |
Go | Go | allow spaces in network names | 85b22fabbe2d3a961eec8d7c999ead041450734b | <ide><path>libnetwork/config/config.go
<ide> import (
<ide> "github.com/docker/libnetwork/osl"
<ide> )
<ide>
<del>// RestrictedNameChars collects the characters allowed to represent a network or endpoint name.
<del>const restrictedNameChars = `[a-zA-Z0-9][a-zA-Z0-9_.-]`
<add>// restrictedNameRegex represents the regular expression which regulates the allowed network or endpoint names.
<add>const restrictedNameRegex = `^[\w]+[\w-. ]*[\w]+$`
<ide>
<ide> // RestrictedNamePattern is a regular expression to validate names against the collection of restricted characters.
<del>var restrictedNamePattern = regexp.MustCompile(`^/?` + restrictedNameChars + `+$`)
<add>var restrictedNamePattern = regexp.MustCompile(restrictedNameRegex)
<ide>
<ide> // Config encapsulates configurations of various Libnetwork components
<ide> type Config struct {
<ide> func (c *Config) ProcessOptions(options ...Option) {
<ide> // ValidateName validates configuration objects supported by libnetwork
<ide> func ValidateName(name string) error {
<ide> if !restrictedNamePattern.MatchString(name) {
<del> return fmt.Errorf("%s includes invalid characters, only %q are allowed", name, restrictedNameChars)
<add> return fmt.Errorf("%q includes invalid characters, resource name has to conform to %q", name, restrictedNameRegex)
<ide> }
<ide> return nil
<ide> }
<ide><path>libnetwork/config/config_test.go
<ide> func TestOptionsLabels(t *testing.T) {
<ide> }
<ide>
<ide> func TestValidName(t *testing.T) {
<del> if err := ValidateName("test"); err != nil {
<del> t.Fatal("Name validation fails for a name that must be accepted")
<del> }
<del> if err := ValidateName(""); err == nil {
<del> t.Fatal("Name validation succeeds for a case when it is expected to fail")
<del> }
<del> if err := ValidateName(" "); err == nil {
<del> t.Fatal("Name validation succeeds for a case when it is expected to fail")
<del> }
<del> if err := ValidateName("<>$$^"); err == nil {
<del> t.Fatal("Name validation succeeds for a case when it is expected to fail")
<add> assertName(t, "test", true)
<add> assertName(t, "test1", true)
<add> assertName(t, "test1.2_3", true)
<add> assertName(t, "_test", true)
<add> assertName(t, "test_", true)
<add> assertName(t, "looks-good", true)
<add> assertName(t, " test", false)
<add> assertName(t, "test ", false)
<add> assertName(t, "test.", false)
<add> assertName(t, ".test", false)
<add> assertName(t, "", false)
<add> assertName(t, " ", false)
<add> assertName(t, "<>$$^", false)
<add> assertName(t, "this is a good network name", true)
<add> assertName(t, "this is also-good", true)
<add> assertName(t, " this is a not good network name", false)
<add> assertName(t, "this is a not either ", false)
<add> assertName(t, "this one\nis not good", false)
<add> assertName(t, "this one\tis not good", false)
<add> assertName(t, "this one\ris not good", false)
<add> assertName(t, "this one\vis not good", false)
<add> assertName(t, "this one\fis not good", false)
<add>}
<add>func assertName(t *testing.T, name string, mustSucceed bool) {
<add> msg := "Name validation succeeds for a case when it is expected to fail"
<add> if mustSucceed {
<add> msg = "Name validation fails for a name that must be accepted"
<add> }
<add> err := ValidateName(name)
<add> if (err == nil) != mustSucceed {
<add> t.Fatalf("%s: %s", msg, name)
<ide> }
<ide> }
<ide> | 2 |
Javascript | Javascript | add setin to record | 8f4dabb1301e9ec4e3cb1db6d6d54314d5b9a4d0 | <ide><path>dist/immutable.js
<ide> RecordPrototype.merge = MapPrototype.merge;
<ide> RecordPrototype.mergeWith = MapPrototype.mergeWith;
<ide> RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
<ide> RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
<add>RecordPrototype.setIn = MapPrototype.setIn;
<ide> RecordPrototype.update = MapPrototype.update;
<ide> RecordPrototype.updateIn = MapPrototype.updateIn;
<ide> RecordPrototype.withMutations = MapPrototype.withMutations;
<ide><path>dist/immutable.min.js
<ide> if(null===t||void 0===t)return e;if(Pe(t))return t;t=Zr(t);var r=t.size;return 0
<ide> },set:function(t,e){return ir(this,t,e)},remove:function(t){return ir(this,t,Ir)},wasAltered:function(){return this._map.wasAltered()||this._list.wasAltered()},__iterate:function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},__iterator:function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},__ensureOwner:function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?rr(e,r,t,this.__hash):(this.__ownerID=t,this._map=e,this._list=r,this)}},{of:function(){return this(arguments)}},zn),Gn.isOrderedMap=er,Gn.prototype[Qr]=!0,Gn.prototype[mr]=Gn.prototype.remove;var Zn,$n=function(t){return null===t||void 0===t?or():ur(t)?t:or().unshiftAll(t)},ti=$n;gr.createClass($n,{toString:function(){return this.__toString("Stack [","]")},get:function(t,e){for(var r=this._head;r&&t--;)r=r.next;return r?r.value:e},peek:function(){return this._head&&this._head.value},push:function(){if(0===arguments.length)return this;for(var t=this.size+arguments.length,e=this._head,r=arguments.length-1;r>=0;r--)e={value:arguments[r],next:e};return this.__ownerID?(this.size=t,this._head=e,this.__hash=void 0,this.__altered=!0,this):sr(t,e)},pushAll:function(t){if(t=Zr(t),0===t.size)return this;var e=this.size,r=this._head;return t.reverse().forEach(function(t){e++,r={value:t,next:r}}),this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):sr(e,r)},pop:function(){return this.slice(1)},unshift:function(){return this.push.apply(this,arguments)},unshiftAll:function(t){return this.pushAll(t)},shift:function(){return this.pop.apply(this,arguments)},clear:function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):or()},slice:function(t,e){if(l(t,e,this.size))return this;var r=v(t,this.size),n=p(e,this.size);if(n!==this.size)return gr.superCall(this,ti.prototype,"slice",[t,e]);for(var i=this.size-r,u=this._head;r--;)u=u.next;return this.__ownerID?(this.size=i,this._head=u,this.__hash=void 0,this.__altered=!0,this):sr(i,u)
<ide> },__ensureOwner:function(t){return t===this.__ownerID?this:t?sr(this.size,this._head,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},__iterate:function(t,e){if(e)return this.toSeq().cacheResult.__iterate(t,e);for(var r=0,n=this._head;n&&t(n.value,r++,this)!==!1;)n=n.next;return r},__iterator:function(t,e){if(e)return this.toSeq().cacheResult().__iterator(t,e);var r=0,n=this._head;return new Wr(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return I()})}},{of:function(){return this(arguments)}},gn),$n.isStack=ur;var ei="",ri=$n.prototype;ri[ei]=!0,ri.withMutations=bn.withMutations,ri.asMutable=bn.asMutable,ri.asImmutable=bn.asImmutable,ri.wasAltered=bn.wasAltered;var ni,ii=function(t){return null===t||void 0===t?fr():ar(t)?t:fr().union($r(t))};gr.createClass(ii,{toString:function(){return this.__toString("Set {","}")},has:function(t){return this._map.has(t)},add:function(t){return hr(this,this._map.set(t,!0))},remove:function(t){return hr(this,this._map.remove(t))},clear:function(){return hr(this,this._map.clear())},union:function(){var t=arguments;return 0===t.length?this:this.withMutations(function(e){for(var r=0;t.length>r;r++)$r(t[r]).forEach(function(t){return e.add(t)})})},intersect:function(){for(var t=[],e=0;arguments.length>e;e++)t[e]=arguments[e];if(0===t.length)return this;t=t.map(function(t){return $r(t)});var r=this;return this.withMutations(function(e){r.forEach(function(r){t.every(function(t){return t.contains(r)})||e.remove(r)})})},subtract:function(){for(var t=[],e=0;arguments.length>e;e++)t[e]=arguments[e];if(0===t.length)return this;t=t.map(function(t){return $r(t)});var r=this;return this.withMutations(function(e){r.forEach(function(r){t.some(function(t){return t.contains(r)})&&e.remove(r)})})},merge:function(){return this.union.apply(this,arguments)},mergeWith:function(){for(var t=[],e=1;arguments.length>e;e++)t[e-1]=arguments[e];return this.union.apply(this,t)},sort:function(t){return ai(je(this,t))},sortBy:function(t,e){return ai(je(this,e,t))},wasAltered:function(){return this._map.wasAltered()
<ide> },__iterate:function(t,e){var r=this;return this._map.__iterate(function(e,n){return t(n,n,r)},e)},__iterator:function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},__ensureOwner:function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):(this.__ownerID=t,this._map=e,this)}},{of:function(){return this(arguments)},fromKeys:function(t){return this(Fr(t).keySeq())}},wn),ii.isSet=ar;var ui="",si=ii.prototype;si[ui]=!0,si[mr]=si.remove,si.mergeDeep=si.merge,si.mergeDeepWith=si.mergeWith,si.withMutations=bn.withMutations,si.asMutable=bn.asMutable,si.asImmutable=bn.asImmutable,si.__empty=fr,si.__make=cr;var oi,ai=function(t){return null===t||void 0===t?vr():_r(t)?t:vr().union($r(t))};gr.createClass(ai,{toString:function(){return this.__toString("OrderedSet {","}")}},{of:function(){return this(arguments)},fromKeys:function(t){return this(Fr(t).keySeq())}},ii),ai.isOrderedSet=_r;var hi=ai.prototype;hi[Qr]=!0,hi.__empty=vr,hi.__make=lr;var ci,fi=function(t,e){var r=function(t){return this instanceof r?void(this._map=zn(t)):new r(t)},n=Object.keys(t),u=r.prototype=Object.create(_i);u.constructor=r,e&&(u._name=e),u._defaultValues=t,u._keys=n,u.size=n.length;try{n.forEach(function(t){Object.defineProperty(r.prototype,t,{get:function(){return this.get(t)},set:function(e){i(this.__ownerID,"Cannot set on an immutable record."),this.set(t,e)}})})}catch(s){}return r};gr.createClass(fi,{toString:function(){return this.__toString(dr(this)+" {","}")},has:function(t){return this._defaultValues.hasOwnProperty(t)},get:function(t,e){if(!this.has(t))return e;var r=this._defaultValues[t];return this._map?this._map.get(t,r):r},clear:function(){if(this.__ownerID)return this._map&&this._map.clear(),this;var t=Object.getPrototypeOf(this).constructor;return t._empty||(t._empty=pr(this,ie()))},set:function(t,e){if(!this.has(t))throw Error('Cannot set unknown key "'+t+'" on '+dr(this));var r=this._map&&this._map.set(t,e);return this.__ownerID||r===this._map?this:pr(this,r)
<del>},remove:function(t){if(!this.has(t))return this;var e=this._map&&this._map.remove(t);return this.__ownerID||e===this._map?this:pr(this,e)},wasAltered:function(){return this._map.wasAltered()},__iterator:function(t,e){var r=this;return Fr(this._defaultValues).map(function(t,e){return r.get(e)}).__iterator(t,e)},__iterate:function(t,e){var r=this;return Fr(this._defaultValues).map(function(t,e){return r.get(e)}).__iterate(t,e)},__ensureOwner:function(t){if(t===this.__ownerID)return this;var e=this._map&&this._map.__ensureOwner(t);return t?pr(this,e,t):(this.__ownerID=t,this._map=e,this)}},{},dn);var _i=fi.prototype;_i[mr]=_i.remove,_i.merge=bn.merge,_i.mergeWith=bn.mergeWith,_i.mergeDeep=bn.mergeDeep,_i.mergeDeepWith=bn.mergeDeepWith,_i.update=bn.update,_i.updateIn=bn.updateIn,_i.withMutations=bn.withMutations,_i.asMutable=bn.asMutable,_i.asImmutable=bn.asImmutable;var li=function(t,e,r){return this instanceof vi?(i(0!==r,"Cannot step a Range by 0"),t=t||0,void 0===e&&(e=1/0),t===e&&di?di:(r=void 0===r?1:Math.abs(r),t>e&&(r=-r),this._start=t,this._end=e,this._step=r,void(this.size=Math.max(0,Math.ceil((e-t)/r-1)+1)))):new vi(t,e,r)},vi=li;gr.createClass(li,{toString:function(){return 0===this.size?"Range []":"Range [ "+this._start+"..."+this._end+(this._step>1?" by "+this._step:"")+" ]"},get:function(t,e){return this.has(t)?this._start+f(this,t)*this._step:e},contains:function(t){var e=(t-this._start)/this._step;return e>=0&&this.size>e&&e===Math.floor(e)},slice:function(t,e){return l(t,e,this.size)?this:(t=v(t,this.size),e=p(e,this.size),t>=e?di:new vi(this.get(t,this._end),this.get(e,this._end),this._step))},indexOf:function(t){var e=t-this._start;if(e%this._step===0){var r=e/this._step;if(r>=0&&this.size>r)return r}return-1},lastIndexOf:function(t){return this.indexOf(t)},take:function(t){return this.slice(0,Math.max(0,t))},skip:function(t){return this.slice(Math.max(0,t))},__iterate:function(t,e){for(var r=this.size-1,n=this._step,i=e?this._start+r*n:this._start,u=0;r>=u;u++){if(t(i,u,this)===!1)return u+1;i+=e?-n:n
<del>}return u},__iterator:function(t,e){var r=this.size-1,n=this._step,i=e?this._start+r*n:this._start,u=0;return new Wr(function(){var s=i;return i+=e?-n:n,u>r?I():z(t,u++,s)})},__deepEquals:function(t){return t instanceof vi?this._start===t._start&&this._end===t._end&&this._step===t._step:T(this,t)}},{},un);var pi=li.prototype;pi.__toJS=pi.toArray,pi.first=Nn.first,pi.last=Nn.last;var di=li(0,0),yi=function(t,e){return 0>=e&&wi?wi:this instanceof gi?(this._value=t,this.size=void 0===e?1/0:Math.max(0,e),void(0===this.size&&(wi=this))):new gi(t,e)},gi=yi;gr.createClass(yi,{toString:function(){return 0===this.size?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},get:function(t,e){return this.has(t)?this._value:e},contains:function(t){return n(this._value,t)},slice:function(t,e){var r=this.size;return l(t,e,r)?this:new gi(this._value,p(e,r)-v(t,r))},reverse:function(){return this},indexOf:function(t){return n(this._value,t)?0:-1},lastIndexOf:function(t){return n(this._value,t)?this.size:-1},__iterate:function(t){for(var e=0;this.size>e;e++)if(t(this._value,e,this)===!1)return e+1;return e},__iterator:function(t){var e=this,r=0;return new Wr(function(){return e.size>r?z(t,r++,e._value):I()})},__deepEquals:function(t){return t instanceof gi?n(this._value,t._value):T(t)}},{},un);var mi=yi.prototype;mi.last=mi.first,mi.has=pi.has,mi.take=pi.take,mi.skip=pi.skip,mi.__toJS=pi.__toJS;var wi,Si={Iterable:Pr,Seq:tn,Collection:pn,Map:zn,OrderedMap:Gn,List:Hn,Stack:$n,Set:ii,OrderedSet:ai,Record:fi,Range:li,Repeat:yi,is:n,fromJS:F};return Si}"object"==typeof exports?module.exports=t():"function"==typeof define&&define.amd?define(t):Immutable=t();
<ide>\ No newline at end of file
<add>},remove:function(t){if(!this.has(t))return this;var e=this._map&&this._map.remove(t);return this.__ownerID||e===this._map?this:pr(this,e)},wasAltered:function(){return this._map.wasAltered()},__iterator:function(t,e){var r=this;return Fr(this._defaultValues).map(function(t,e){return r.get(e)}).__iterator(t,e)},__iterate:function(t,e){var r=this;return Fr(this._defaultValues).map(function(t,e){return r.get(e)}).__iterate(t,e)},__ensureOwner:function(t){if(t===this.__ownerID)return this;var e=this._map&&this._map.__ensureOwner(t);return t?pr(this,e,t):(this.__ownerID=t,this._map=e,this)}},{},dn);var _i=fi.prototype;_i[mr]=_i.remove,_i.merge=bn.merge,_i.mergeWith=bn.mergeWith,_i.mergeDeep=bn.mergeDeep,_i.mergeDeepWith=bn.mergeDeepWith,_i.setIn=bn.setIn,_i.update=bn.update,_i.updateIn=bn.updateIn,_i.withMutations=bn.withMutations,_i.asMutable=bn.asMutable,_i.asImmutable=bn.asImmutable;var li=function(t,e,r){return this instanceof vi?(i(0!==r,"Cannot step a Range by 0"),t=t||0,void 0===e&&(e=1/0),t===e&&di?di:(r=void 0===r?1:Math.abs(r),t>e&&(r=-r),this._start=t,this._end=e,this._step=r,void(this.size=Math.max(0,Math.ceil((e-t)/r-1)+1)))):new vi(t,e,r)},vi=li;gr.createClass(li,{toString:function(){return 0===this.size?"Range []":"Range [ "+this._start+"..."+this._end+(this._step>1?" by "+this._step:"")+" ]"},get:function(t,e){return this.has(t)?this._start+f(this,t)*this._step:e},contains:function(t){var e=(t-this._start)/this._step;return e>=0&&this.size>e&&e===Math.floor(e)},slice:function(t,e){return l(t,e,this.size)?this:(t=v(t,this.size),e=p(e,this.size),t>=e?di:new vi(this.get(t,this._end),this.get(e,this._end),this._step))},indexOf:function(t){var e=t-this._start;if(e%this._step===0){var r=e/this._step;if(r>=0&&this.size>r)return r}return-1},lastIndexOf:function(t){return this.indexOf(t)},take:function(t){return this.slice(0,Math.max(0,t))},skip:function(t){return this.slice(Math.max(0,t))},__iterate:function(t,e){for(var r=this.size-1,n=this._step,i=e?this._start+r*n:this._start,u=0;r>=u;u++){if(t(i,u,this)===!1)return u+1;
<add>i+=e?-n:n}return u},__iterator:function(t,e){var r=this.size-1,n=this._step,i=e?this._start+r*n:this._start,u=0;return new Wr(function(){var s=i;return i+=e?-n:n,u>r?I():z(t,u++,s)})},__deepEquals:function(t){return t instanceof vi?this._start===t._start&&this._end===t._end&&this._step===t._step:T(this,t)}},{},un);var pi=li.prototype;pi.__toJS=pi.toArray,pi.first=Nn.first,pi.last=Nn.last;var di=li(0,0),yi=function(t,e){return 0>=e&&wi?wi:this instanceof gi?(this._value=t,this.size=void 0===e?1/0:Math.max(0,e),void(0===this.size&&(wi=this))):new gi(t,e)},gi=yi;gr.createClass(yi,{toString:function(){return 0===this.size?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},get:function(t,e){return this.has(t)?this._value:e},contains:function(t){return n(this._value,t)},slice:function(t,e){var r=this.size;return l(t,e,r)?this:new gi(this._value,p(e,r)-v(t,r))},reverse:function(){return this},indexOf:function(t){return n(this._value,t)?0:-1},lastIndexOf:function(t){return n(this._value,t)?this.size:-1},__iterate:function(t){for(var e=0;this.size>e;e++)if(t(this._value,e,this)===!1)return e+1;return e},__iterator:function(t){var e=this,r=0;return new Wr(function(){return e.size>r?z(t,r++,e._value):I()})},__deepEquals:function(t){return t instanceof gi?n(this._value,t._value):T(t)}},{},un);var mi=yi.prototype;mi.last=mi.first,mi.has=pi.has,mi.take=pi.take,mi.skip=pi.skip,mi.__toJS=pi.__toJS;var wi,Si={Iterable:Pr,Seq:tn,Collection:pn,Map:zn,OrderedMap:Gn,List:Hn,Stack:$n,Set:ii,OrderedSet:ai,Record:fi,Range:li,Repeat:yi,is:n,fromJS:F};return Si}"object"==typeof exports?module.exports=t():"function"==typeof define&&define.amd?define(t):Immutable=t();
<ide>\ No newline at end of file
<ide><path>src/Record.js
<ide> RecordPrototype.merge = MapPrototype.merge;
<ide> RecordPrototype.mergeWith = MapPrototype.mergeWith;
<ide> RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
<ide> RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
<add>RecordPrototype.setIn = MapPrototype.setIn;
<ide> RecordPrototype.update = MapPrototype.update;
<ide> RecordPrototype.updateIn = MapPrototype.updateIn;
<ide> RecordPrototype.withMutations = MapPrototype.withMutations; | 3 |
Javascript | Javascript | fix linting errors | 9ba7a10f85302d10ea36a2dbe8bdfd8efb45a2ba | <ide><path>examples/with-refnux/helpers/getStore.js
<ide> let storeMemoized = null
<ide>
<ide> const getStore = (initialState) => {
<ide> let store = null
<del> if (typeof window == 'undefined') {
<add> if (typeof window === 'undefined') {
<ide> store = createStore(initialState)
<ide> } else {
<ide> if (!storeMemoized) {
<ide> const getStore = (initialState) => {
<ide> return store
<ide> }
<ide>
<del>export default getStore
<ide>\ No newline at end of file
<add>export default getStore
<ide><path>examples/with-refnux/helpers/withRefnux.js
<del>import { Provider} from 'refnux'
<del>
<add>import {Provider} from 'refnux'
<ide> import getStore from './getStore'
<ide>
<ide> // The `withRefnux` "decorator"
<ide> import getStore from './getStore'
<ide> // - passes `store` to Component's `getInitialProps` so that it can dispatch actions
<ide>
<ide> const withRefnux = (getInitialState, Component) => {
<del>
<ide> const Wrapper = (props) => {
<ide> var store = props.store
<ide> // if getInitialProps was executed on the server we get a store
<ide> // that's missing non-serializable functions.
<del> // Because of this we need to recreate the store based on the
<add> // Because of this we need to recreate the store based on the
<ide> // state coming from the server.
<ide> if (!store.dispatch) {
<ide> store = getStore(props.store.state)
<ide> const withRefnux = (getInitialState, Component) => {
<ide> return Wrapper
<ide> }
<ide>
<del>
<del>export default withRefnux
<ide>\ No newline at end of file
<add>export default withRefnux
<ide><path>examples/with-refnux/pages/page1.js
<ide> const Page1 = connect(
<ide> <h3>{state.title}</h3>
<ide> <p>Current state: {JSON.stringify(state, null, 2)}</p>
<ide> <button onClick={() => dispatch(counterIncrement)} >Increment</button>
<del> <Link href="/page2"><button>go to page 2</button></Link>
<add> <Link href='/page2'><button>go to page 2</button></Link>
<ide> </div>
<ide> )
<ide>
<ide> Page1.getInitialProps = async function (context) {
<ide> return {} // we have a store, we don't need props!
<ide> }
<ide>
<del>export default withRefnux(getInitialState, Page1)
<ide>\ No newline at end of file
<add>export default withRefnux(getInitialState, Page1)
<ide><path>examples/with-refnux/pages/page2.js
<ide> const Page2 = connect(
<ide> <h3>{state.title}</h3>
<ide> <p>Current state: {JSON.stringify(state, null, 2)}</p>
<ide> <button onClick={() => dispatch(counterIncrement)} >Increment</button>
<del> <Link href="/page1"><button>go to page 2</button></Link>
<add> <Link href='/page1'><button>go to page 2</button></Link>
<ide> </div>
<ide> )
<ide>
<ide> Page2.getInitialProps = async function (context) {
<ide> return {}
<ide> }
<ide>
<del>
<del>export default withRefnux(getInitialState, Page2)
<ide>\ No newline at end of file
<add>export default withRefnux(getInitialState, Page2)
<ide><path>examples/with-refnux/store/counterIncrement.js
<ide> const counterIncrement = ({counter}, dispatch) => {
<ide> return { counter: counter + 1 }
<ide> }
<ide>
<del>export default counterIncrement
<ide>\ No newline at end of file
<add>export default counterIncrement
<ide><path>examples/with-refnux/store/getInitialState.js
<ide> const getInitialState = () => {
<ide> title: '',
<ide> counter: 0
<ide> }
<del>}
<add>}
<ide>
<del>export default getInitialState
<ide>\ No newline at end of file
<add>export default getInitialState
<ide><path>examples/with-refnux/store/getStore.js
<ide> const storeInitialState = { counter: 0, key: 'value' }
<ide>
<ide> const getStore = () => {
<ide> let store = null
<del> if (typeof window == 'undefined') {
<add> if (typeof window === 'undefined') {
<ide> store = createStore(storeInitialState)
<ide> } else {
<ide> store = window.store || createStore(storeInitialState)
<ide> const getStore = () => {
<ide> return store
<ide> }
<ide>
<del>export default getStore
<ide>\ No newline at end of file
<add>export default getStore
<ide><path>examples/with-refnux/store/setTitle.js
<ide> const setTitle = (newTitle) => ({title}) => {
<ide> return { title: newTitle }
<ide> }
<ide>
<del>export default setTitle
<ide>\ No newline at end of file
<add>export default setTitle | 8 |
Javascript | Javascript | remove async transitions | b5ff0edb41f50e1f55446c14605fb566aa419ed4 | <ide><path>packages/ember-states/lib/state_manager.js
<ide> require('ember-states/state');
<ide> robotManager.send('beginExtermination', allHumans)
<ide> robotManager.getPath('currentState.name') // 'rampaging'
<ide>
<del> ## Async transitions
<del> When a state's `enter` and `exit` methods are called they passed a argument representing
<del> the transition. By calling `async()` and `resume()` on the transition object, the
<del> transition can be delayed. This can be useful to account for an animation between states.
<del>
<del> robotManager = Ember.StateManager.create({
<del> poweredUp: Ember.State.create({
<del> exit: function(stateManager, transition){
<del> console.log("beginning exit of the poweredUp state");
<del> transition.async();
<del> asyncStartShutdownDanceMoves().done(function(){
<del> console.log("completing exit of the poweredUp state");
<del> transition.resume();
<del> });
<del> }
<del> });
<del> });
<del>
<ide> **/
<ide> Ember.StateManager = Ember.State.extend(
<ide> /** @scope Ember.StateManager.prototype */ {
<ide> Ember.StateManager = Ember.State.extend(
<ide> }
<ide> },
<ide>
<del> asyncEach: function(list, callback, doneCallback) {
<del> var async = false,
<del> self = this;
<del>
<del> if (!list.length) {
<del> if (doneCallback) { doneCallback.call(this); }
<del> return;
<del> }
<del>
<del> var head = list[0],
<del> tail = list.slice(1);
<del>
<del> var transition = {
<del> async: function() { async = true; },
<del> resume: function() {
<del> self.asyncEach(tail, callback, doneCallback);
<del> }
<del> };
<del>
<del> callback.call(this, head, transition);
<del>
<del> if (!async) { transition.resume(); }
<del> },
<del>
<ide> enterState: function(exitStates, enterStates, state) {
<ide> var log = this.enableLogging,
<ide> stateManager = this;
<ide>
<ide> exitStates = exitStates.slice(0).reverse();
<del> this.asyncEach(exitStates, function(state, transition) {
<del> state.fire('exit', stateManager, transition);
<del> }, function() {
<del> this.asyncEach(enterStates, function(state, transition) {
<del> if (log) { Ember.Logger.log("STATEMANAGER: Entering " + get(state, 'path')); }
<del> state.fire('enter', stateManager, transition);
<del> }, function() {
<del> var startState = state,
<del> enteredState,
<del> initialState = get(startState, 'initialState');
<del>
<del> if (!initialState) {
<del> initialState = 'start';
<del> }
<add> exitStates.forEach(function(state) {
<add> state.fire('exit', stateManager);
<add> });
<ide>
<del> // right now, start states cannot be entered asynchronously
<del> while (startState = get(get(startState, 'states'), initialState)) {
<del> enteredState = startState;
<add> enterStates.forEach(function(state) {
<add> if (log) { Ember.Logger.log("STATEMANAGER: Entering " + get(state, 'path')); }
<add> state.fire('enter', stateManager);
<add> });
<ide>
<del> if (log) { Ember.Logger.log("STATEMANAGER: Entering " + get(startState, 'path')); }
<del> startState.fire('enter', stateManager);
<add> var startState = state,
<add> enteredState,
<add> initialState = get(startState, 'initialState');
<ide>
<del> initialState = get(startState, 'initialState');
<add> if (!initialState) {
<add> initialState = 'start';
<add> }
<ide>
<del> if (!initialState) {
<del> initialState = 'start';
<del> }
<del> }
<add> while (startState = get(get(startState, 'states'), initialState)) {
<add> enteredState = startState;
<ide>
<del> set(this, 'currentState', enteredState || state);
<del> });
<del> });
<add> if (log) { Ember.Logger.log("STATEMANAGER: Entering " + get(startState, 'path')); }
<add> startState.fire('enter', stateManager);
<add>
<add> initialState = get(startState, 'initialState');
<add>
<add> if (!initialState) {
<add> initialState = 'start';
<add> }
<add> }
<add>
<add> set(this, 'currentState', enteredState || state);
<ide> }
<ide> });
<ide><path>packages/ember-states/tests/state_manager_test.js
<ide> test("it sends enter and exit events during state transitions", function() {
<ide> equal(loadedState.exited, 1, "sibling state should receive one exit event");
<ide> });
<ide>
<del>test("a transition can be asynchronous", function() {
<del> expect(1);
<del>
<del> var counter = 0;
<del> var stateManager = Ember.StateManager.create({
<del> start: Ember.State.create({
<del> finish: function(manager) {
<del> manager.transitionTo('finished');
<del> },
<del>
<del> exit: function(manager, transition) {
<del> // pause QUnit while we test some async functionality
<del> stop();
<del>
<del> transition.async();
<del>
<del> setTimeout(function() {
<del> counter++;
<del> transition.resume();
<del> }, 50);
<del> }
<del> }),
<del>
<del> finished: Ember.State.create({
<del> enter: function() {
<del> equal(counter, 1, "increments counter and executes transition after specified timeout");
<del> start();
<del> },
<del>
<del> exit: function() {
<del> equal(arguments.length, 0, "does not pass transition object if arguments are empty");
<del> }
<del> })
<del> });
<del>
<del> stateManager.send('finish');
<del>});
<del>
<ide> test("it accepts absolute paths when changing states", function() {
<ide> var emptyState = loadedState.empty;
<ide> | 2 |
Javascript | Javascript | add queue microtask to host configs | aa736a0fa6e22f902bd7a98dcb9b24d8c4310e35 | <ide><path>packages/react-art/src/ReactARTHostConfig.js
<ide> export function getChildHostContext() {
<ide> export const scheduleTimeout = setTimeout;
<ide> export const cancelTimeout = clearTimeout;
<ide> export const noTimeout = -1;
<add>export function queueMicrotask(callback: Function) {
<add> invariant(false, 'Not implemented.');
<add>}
<ide>
<ide> export function shouldSetTextContent(type, props) {
<ide> return (
<ide><path>packages/react-dom/src/client/ReactDOMHostConfig.js
<ide> export const scheduleTimeout: any =
<ide> export const cancelTimeout: any =
<ide> typeof clearTimeout === 'function' ? clearTimeout : (undefined: any);
<ide> export const noTimeout = -1;
<add>export const queueMicrotask: any =
<add> typeof global.queueMicrotask === 'function'
<add> ? global.queueMicrotask
<add> : typeof Promise !== 'undefined'
<add> ? callback =>
<add> Promise.resolve(null)
<add> .then(callback)
<add> .catch(handleErrorInNextTick)
<add> : scheduleTimeout;
<add>
<add>function handleErrorInNextTick(error) {
<add> setTimeout(() => {
<add> throw error;
<add> });
<add>}
<ide>
<ide> // -------------------
<ide> // Mutation
<ide><path>packages/react-native-renderer/src/ReactFabricHostConfig.js
<ide> export const warnsIfNotActing = false;
<ide> export const scheduleTimeout = setTimeout;
<ide> export const cancelTimeout = clearTimeout;
<ide> export const noTimeout = -1;
<add>export function queueMicrotask(callback: Function) {
<add> invariant(false, 'Not implemented.');
<add>}
<ide>
<ide> // -------------------
<ide> // Persistence
<ide><path>packages/react-native-renderer/src/ReactNativeHostConfig.js
<ide> export const warnsIfNotActing = true;
<ide> export const scheduleTimeout = setTimeout;
<ide> export const cancelTimeout = clearTimeout;
<ide> export const noTimeout = -1;
<add>export function queueMicrotask(callback: Function) {
<add> invariant(false, 'Not implemented.');
<add>}
<ide>
<ide> export function shouldSetTextContent(type: string, props: Props): boolean {
<ide> // TODO (bvaughn) Revisit this decision.
<ide><path>packages/react-noop-renderer/src/createReactNoop.js
<ide> function createReactNoop(reconciler: Function, useMutation: boolean) {
<ide> scheduleTimeout: setTimeout,
<ide> cancelTimeout: clearTimeout,
<ide> noTimeout: -1,
<add> queueMicrotask:
<add> typeof queueMicrotask === 'function'
<add> ? queueMicrotask
<add> : typeof Promise !== 'undefined'
<add> ? callback =>
<add> Promise.resolve(null)
<add> .then(callback)
<add> .catch(error => {
<add> setTimeout(() => {
<add> throw error;
<add> });
<add> })
<add> : setTimeout,
<ide>
<ide> prepareForCommit(): null | Object {
<ide> return null;
<ide><path>packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js
<ide> export const shouldSetTextContent = $$$hostConfig.shouldSetTextContent;
<ide> export const createTextInstance = $$$hostConfig.createTextInstance;
<ide> export const scheduleTimeout = $$$hostConfig.scheduleTimeout;
<ide> export const cancelTimeout = $$$hostConfig.cancelTimeout;
<add>export const queueMicrotask = $$$hostConfig.queueMicrotask;
<ide> export const noTimeout = $$$hostConfig.noTimeout;
<ide> export const now = $$$hostConfig.now;
<ide> export const isPrimaryRenderer = $$$hostConfig.isPrimaryRenderer;
<ide><path>packages/react-test-renderer/src/ReactTestHostConfig.js
<ide> export const warnsIfNotActing = true;
<ide>
<ide> export const scheduleTimeout = setTimeout;
<ide> export const cancelTimeout = clearTimeout;
<add>export const queueMicrotask =
<add> typeof global.queueMicrotask === 'function'
<add> ? global.queueMicrotask
<add> : typeof Promise !== 'undefined'
<add> ? (callback: Function) =>
<add> Promise.resolve(null)
<add> .then(callback)
<add> .catch(handleErrorInNextTick)
<add> : scheduleTimeout;
<add>
<add>function handleErrorInNextTick(error) {
<add> setTimeout(() => {
<add> throw error;
<add> });
<add>}
<ide> export const noTimeout = -1;
<ide>
<ide> // ------------------- | 7 |
Python | Python | add assertinhtml method to testcase | dc704516c240011a9aeda17f631ade35c65cda58 | <ide><path>django/test/testcases.py
<ide> def assertHTMLNotEqual(self, html1, html2, msg=None):
<ide> safe_repr(dom1, True), safe_repr(dom2, True))
<ide> self.fail(self._formatMessage(msg, standardMsg))
<ide>
<add> def assertInHTML(self, needle, haystack, count = None, msg_prefix=''):
<add> needle = assert_and_parse_html(self, needle, None,
<add> 'First argument is not valid HTML:')
<add> haystack = assert_and_parse_html(self, haystack, None,
<add> 'Second argument is not valid HTML:')
<add> real_count = haystack.count(needle)
<add> if count is not None:
<add> self.assertEqual(real_count, count,
<add> msg_prefix + "Found %d instances of '%s' in response"
<add> " (expected %d)" % (real_count, needle, count))
<add> else:
<add> self.assertTrue(real_count != 0,
<add> msg_prefix + "Couldn't find '%s' in response" % needle)
<add>
<ide> def assertXMLEqual(self, xml1, xml2, msg=None):
<ide> """
<ide> Asserts that two XML snippets are semantically the same. | 1 |
Javascript | Javascript | add issue link in deprecation message | 8b85100ff34a67de5dac37a0b0c06d330be3006e | <ide><path>moment.js
<ide> },
<ide>
<ide> min: deprecate(
<del> "moment().min is deprecated, use moment.min instead",
<add> "moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",
<ide> function (other) {
<ide> other = moment.apply(null, arguments);
<ide> return other < this ? this : other;
<ide> }
<ide> ),
<ide>
<ide> max: deprecate(
<del> "moment().max is deprecated, use moment.max instead",
<add> "moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",
<ide> function (other) {
<ide> other = moment.apply(null, arguments);
<ide> return other > this ? this : other; | 1 |
Python | Python | fix broken test introduced by r17526 | 06da2be00fb371a27e10ce37821643914c93adc6 | <ide><path>django/contrib/auth/tests/tokens.py
<ide> def test_date_length(self):
<ide> p0 = PasswordResetTokenGenerator()
<ide>
<ide> # This will put a 14-digit base36 timestamp into the token, which is too large.
<del> tk1 = p0._make_token_with_timestamp(user, 175455491841851871349)
<del> self.assertFalse(p0.check_token(user, tk1))
<add> self.assertRaises(ValueError,
<add> p0._make_token_with_timestamp,
<add> user, 175455491841851871349) | 1 |
Text | Text | add changelog entry for "rendering ..." logging | 82aa20adc080ad705fc4a7643bca9e40fb6a6b9a | <ide><path>actionview/CHANGELOG.md
<add>* Added log "Rendering ...", when starting to render a template to log that
<add> we have started rendering something. This helps to easily identify the origin
<add> of queries in the log whether they came from controller or views.
<add>
<add> *Vipul A M and Prem Sichanugrist*
<add>
<ide> ## Rails 5.0.0.beta3 (February 24, 2016) ##
<ide>
<ide> * Collection rendering can cache and fetch multiple partials at once. | 1 |
Python | Python | fix data_utils.py when name ends with `.tar.gz` | 2f1149dbdb96c10c9839f0d909876aef2e362c02 | <ide><path>keras/utils/data_utils.py
<ide> import hashlib
<ide> import multiprocessing.dummy
<ide> import os
<add>import pathlib
<ide> import queue
<ide> import random
<ide> import shutil
<ide> def get_file(fname=None,
<ide> raise ValueError("Invalid origin '{}'".format(origin))
<ide>
<ide> if untar:
<add> if fname.endswith('.tar.gz'):
<add> fname = pathlib.Path(fname)
<add> # The 2 `.with_suffix()` are because of `.tar.gz` as pathlib
<add> # considers it as 2 suffixes.
<add> fname = fname.with_suffix('').with_suffix('')
<add> fname = str(fname)
<ide> untar_fpath = os.path.join(datadir, fname)
<del> if not untar_fpath.endswith('.tar.gz'):
<del> fpath = untar_fpath + '.tar.gz'
<add> fpath = untar_fpath + '.tar.gz'
<ide> else:
<ide> fpath = os.path.join(datadir, fname)
<ide>
<ide><path>keras/utils/data_utils_test.py
<ide> from keras.utils import data_utils
<ide>
<ide>
<del>class TestGetFileAndValidateIt(tf.test.TestCase):
<add>class TestGetFile(tf.test.TestCase):
<ide>
<ide> def test_get_file_and_validate_it(self):
<ide> """Tests get_file from a url, plus extraction and validation.
<ide> def test_get_file_and_validate_it(self):
<ide> with self.assertRaisesRegexp(ValueError, 'Please specify the "origin".*'):
<ide> _ = keras.utils.data_utils.get_file()
<ide>
<add> def test_get_file_with_tgz_extension(self):
<add> """Tests get_file from a url, plus extraction and validation."""
<add> dest_dir = self.get_temp_dir()
<add> orig_dir = self.get_temp_dir()
<add>
<add> text_file_path = os.path.join(orig_dir, 'test.txt')
<add> tar_file_path = os.path.join(orig_dir, 'test.tar.gz')
<add>
<add> with open(text_file_path, 'w') as text_file:
<add> text_file.write('Float like a butterfly, sting like a bee.')
<add>
<add> with tarfile.open(tar_file_path, 'w:gz') as tar_file:
<add> tar_file.add(text_file_path)
<add>
<add> origin = urllib.parse.urljoin(
<add> 'file://', urllib.request.pathname2url(os.path.abspath(tar_file_path)))
<add>
<add> path = keras.utils.data_utils.get_file(
<add> 'test.txt.tar.gz', origin, untar=True, cache_subdir=dest_dir)
<add> self.assertEndsWith(path, '.txt')
<add> self.assertTrue(os.path.exists(path))
<add>
<ide>
<ide> class TestSequence(keras.utils.data_utils.Sequence):
<ide> | 2 |
Java | Java | fix layout animations for views with a transform | ee737e7d1c2b60d2226bc9fcab372ce98b5976f1 | <ide><path>ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/PositionAndSizeAnimation.java
<ide> public PositionAndSizeAnimation(View view, int x, int y, int width, int height) {
<ide> mView = view;
<ide>
<del> mStartX = view.getX();
<del> mStartY = view.getY();
<add> mStartX = view.getX() - view.getTranslationX();
<add> mStartY = view.getY() - view.getTranslationY();
<ide> mStartWidth = view.getWidth();
<ide> mStartHeight = view.getHeight();
<ide> | 1 |
Javascript | Javascript | fix lint issue | e462d0d29818db75ca5d6897d0e008937e4d57c5 | <ide><path>src/text-editor-component.js
<ide> class TextEditorComponent {
<ide> this.textDecorationBoundaries = []
<ide> this.pendingScrollTopRow = this.props.initialScrollTopRow
<ide> this.pendingScrollLeftColumn = this.props.initialScrollLeftColumn
<del> this.tabIndex = this.props.element && this.props.element.tabIndex ? this.props.element.tabIndex : -1;
<add> this.tabIndex = this.props.element && this.props.element.tabIndex ? this.props.element.tabIndex : -1
<ide>
<ide> this.measuredContent = false
<ide> this.queryGuttersToRender() | 1 |
Ruby | Ruby | remove obsolete code to fix tests | 255e991cc32da3141afc1a50e1f643d8e028a9f6 | <ide><path>Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
<ide> def run
<ide> end
<ide>
<ide> if value.nil? || (value.respond_to?(:to_a) && value.to_a.empty?) ||
<del> (value.respond_to?(:to_h) && value.to_h.empty?) ||
<ide> (value.respond_to?(:to_s) && value.to_s == "{}") ||
<ide> (artifact_name && !value.key?(artifact_name))
<ide> | 1 |
Text | Text | clarify require() os independence | be6596352b2a1b8648dc266b5be81b6a1be180d6 | <ide><path>doc/api/modules.md
<ide> Used to import modules, `JSON`, and local files. Modules can be imported
<ide> from `node_modules`. Local modules and JSON files can be imported using
<ide> a relative path (e.g. `./`, `./foo`, `./bar/baz`, `../foo`) that will be
<ide> resolved against the directory named by [`__dirname`][] (if defined) or
<del>the current working directory.
<add>the current working directory. The relative paths of POSIX style are resolved
<add>in an OS independent fashion, meaning that the examples above will work on
<add>Windows in the same way they would on Unix systems.
<ide>
<ide> ```js
<del>// Importing a local module:
<add>// Importing a local module with a path relative to the `__dirname` or current
<add>// working directory. (On Windows, this would resolve to .\path\myLocalModule.)
<ide> const myLocalModule = require('./path/myLocalModule');
<ide>
<ide> // Importing a JSON file: | 1 |
Go | Go | use strconv instead of fmt.sprintf() | 56e64270f39a17e12abde344e55ab123675b6af5 | <ide><path>daemon/config/config.go
<ide> type CommonConfig struct {
<ide>
<ide> DNSConfig
<ide> LogConfig
<del> BridgeConfig // bridgeConfig holds bridge network specific configuration.
<add> BridgeConfig // BridgeConfig holds bridge network specific configuration.
<ide> NetworkConfig
<ide> registry.ServiceOptions
<ide>
<ide> func GetConflictFreeLabels(labels []string) ([]string, error) {
<ide> if len(stringSlice) > 1 {
<ide> // If there is a conflict we will return an error
<ide> if v, ok := labelMap[stringSlice[0]]; ok && v != stringSlice[1] {
<del> return nil, fmt.Errorf("conflict labels for %s=%s and %s=%s", stringSlice[0], stringSlice[1], stringSlice[0], v)
<add> return nil, errors.Errorf("conflict labels for %s=%s and %s=%s", stringSlice[0], stringSlice[1], stringSlice[0], v)
<ide> }
<ide> labelMap[stringSlice[0]] = stringSlice[1]
<ide> }
<ide> }
<ide>
<ide> newLabels := []string{}
<ide> for k, v := range labelMap {
<del> newLabels = append(newLabels, fmt.Sprintf("%s=%s", k, v))
<add> newLabels = append(newLabels, k+"="+v)
<ide> }
<ide> return newLabels, nil
<ide> }
<ide> func findConfigurationConflicts(config map[string]interface{}, flags *pflag.Flag
<ide> for key := range unknownKeys {
<ide> unknown = append(unknown, key)
<ide> }
<del> return fmt.Errorf("the following directives don't match any configuration option: %s", strings.Join(unknown, ", "))
<add> return errors.Errorf("the following directives don't match any configuration option: %s", strings.Join(unknown, ", "))
<ide> }
<ide>
<ide> var conflicts []string
<ide> func findConfigurationConflicts(config map[string]interface{}, flags *pflag.Flag
<ide> flags.Visit(duplicatedConflicts)
<ide>
<ide> if len(conflicts) > 0 {
<del> return fmt.Errorf("the following directives are specified both as a flag and in the configuration file: %s", strings.Join(conflicts, ", "))
<add> return errors.Errorf("the following directives are specified both as a flag and in the configuration file: %s", strings.Join(conflicts, ", "))
<ide> }
<ide> return nil
<ide> }
<ide> func Validate(config *Config) error {
<ide> // validate log-level
<ide> if config.LogLevel != "" {
<ide> if _, err := logrus.ParseLevel(config.LogLevel); err != nil {
<del> return fmt.Errorf("invalid logging level: %s", config.LogLevel)
<add> return errors.Errorf("invalid logging level: %s", config.LogLevel)
<ide> }
<ide> }
<ide>
<ide> func Validate(config *Config) error {
<ide>
<ide> // TODO(thaJeztah) Validations below should not accept "0" to be valid; see Validate() for a more in-depth description of this problem
<ide> if config.Mtu < 0 {
<del> return fmt.Errorf("invalid default MTU: %d", config.Mtu)
<add> return errors.Errorf("invalid default MTU: %d", config.Mtu)
<ide> }
<ide> if config.MaxConcurrentDownloads < 0 {
<del> return fmt.Errorf("invalid max concurrent downloads: %d", config.MaxConcurrentDownloads)
<add> return errors.Errorf("invalid max concurrent downloads: %d", config.MaxConcurrentDownloads)
<ide> }
<ide> if config.MaxConcurrentUploads < 0 {
<del> return fmt.Errorf("invalid max concurrent uploads: %d", config.MaxConcurrentUploads)
<add> return errors.Errorf("invalid max concurrent uploads: %d", config.MaxConcurrentUploads)
<ide> }
<ide> if config.MaxDownloadAttempts < 0 {
<del> return fmt.Errorf("invalid max download attempts: %d", config.MaxDownloadAttempts)
<add> return errors.Errorf("invalid max download attempts: %d", config.MaxDownloadAttempts)
<ide> }
<ide>
<ide> // validate that "default" runtime is not reset
<ide> if runtimes := config.GetAllRuntimes(); len(runtimes) > 0 {
<ide> if _, ok := runtimes[StockRuntimeName]; ok {
<del> return fmt.Errorf("runtime name '%s' is reserved", StockRuntimeName)
<add> return errors.Errorf("runtime name '%s' is reserved", StockRuntimeName)
<ide> }
<ide> }
<ide>
<ide> func Validate(config *Config) error {
<ide> if !builtinRuntimes[defaultRuntime] {
<ide> runtimes := config.GetAllRuntimes()
<ide> if _, ok := runtimes[defaultRuntime]; !ok && !IsPermissibleC8dRuntimeName(defaultRuntime) {
<del> return fmt.Errorf("specified default runtime '%s' does not exist", defaultRuntime)
<add> return errors.Errorf("specified default runtime '%s' does not exist", defaultRuntime)
<ide> }
<ide> }
<ide> }
<ide><path>daemon/keys.go
<ide> package daemon // import "github.com/docker/docker/daemon"
<ide>
<ide> import (
<del> "fmt"
<ide> "os"
<ide> "strconv"
<ide> "strings"
<ide> func setRootKeyLimit(limit int) error {
<ide> return err
<ide> }
<ide> defer keys.Close()
<del> if _, err := fmt.Fprintf(keys, "%d", limit); err != nil {
<add> _, err = keys.WriteString(strconv.Itoa(limit))
<add> if err != nil {
<ide> return err
<ide> }
<ide> bytes, err := os.OpenFile(rootBytesFile, os.O_WRONLY, 0)
<ide> if err != nil {
<ide> return err
<ide> }
<ide> defer bytes.Close()
<del> _, err = fmt.Fprintf(bytes, "%d", limit*rootKeyByteMultiplier)
<add> _, err = bytes.WriteString(strconv.Itoa(limit * rootKeyByteMultiplier))
<ide> return err
<ide> }
<ide>
<ide><path>daemon/kill.go
<ide> import (
<ide> "context"
<ide> "fmt"
<ide> "runtime"
<add> "strconv"
<ide> "syscall"
<ide> "time"
<ide>
<ide> func (daemon *Daemon) killWithSignal(container *containerpkg.Container, stopSign
<ide> }
<ide> }
<ide>
<del> attributes := map[string]string{
<del> "signal": fmt.Sprintf("%d", stopSignal),
<del> }
<del> daemon.LogContainerEventWithAttributes(container, "kill", attributes)
<add> daemon.LogContainerEventWithAttributes(container, "kill", map[string]string{
<add> "signal": strconv.Itoa(int(stopSignal)),
<add> })
<ide> return nil
<ide> }
<ide>
<ide><path>daemon/links/links_test.go
<ide> package links // import "github.com/docker/docker/daemon/links"
<ide>
<ide> import (
<ide> "fmt"
<add> "strconv"
<ide> "strings"
<ide> "testing"
<ide>
<ide> func TestLinkPortRangeEnv(t *testing.T) {
<ide> if env[tcpaddr] != "172.0.17.2" {
<ide> t.Fatalf("Expected env %s = 172.0.17.2, got %s", tcpaddr, env[tcpaddr])
<ide> }
<del> if env[tcpport] != fmt.Sprintf("%d", i) {
<add> if env[tcpport] != strconv.Itoa(i) {
<ide> t.Fatalf("Expected env %s = %d, got %s", tcpport, i, env[tcpport])
<ide> }
<ide> if env[tcpproto] != "tcp" {
<ide><path>daemon/reload_unix.go
<ide> package daemon // import "github.com/docker/docker/daemon"
<ide>
<ide> import (
<ide> "bytes"
<del> "fmt"
<add> "strconv"
<ide>
<ide> "github.com/docker/docker/api/types"
<ide> "github.com/docker/docker/daemon/config"
<ide> func (daemon *Daemon) reloadPlatform(conf *config.Config, attributes map[string]
<ide> if runtimeList.Len() > 0 {
<ide> runtimeList.WriteRune(' ')
<ide> }
<del> runtimeList.WriteString(fmt.Sprintf("%s:%s", name, rt.Path))
<add> runtimeList.WriteString(name + ":" + rt.Path)
<ide> }
<ide>
<ide> attributes["runtimes"] = runtimeList.String()
<ide> attributes["default-runtime"] = daemon.configStore.DefaultRuntime
<del> attributes["default-shm-size"] = fmt.Sprintf("%d", daemon.configStore.ShmSize)
<add> attributes["default-shm-size"] = strconv.FormatInt(int64(daemon.configStore.ShmSize), 10)
<ide> attributes["default-ipc-mode"] = daemon.configStore.IpcMode
<ide> attributes["default-cgroupns-mode"] = daemon.configStore.CgroupNamespaceMode
<ide>
<ide><path>daemon/resize.go
<ide> package daemon // import "github.com/docker/docker/daemon"
<ide>
<ide> import (
<ide> "context"
<del> "fmt"
<add> "errors"
<add> "strconv"
<ide> "time"
<ide> )
<ide>
<ide> func (daemon *Daemon) ContainerResize(name string, height, width int) error {
<ide>
<ide> if err = tsk.Resize(context.Background(), uint32(width), uint32(height)); err == nil {
<ide> attributes := map[string]string{
<del> "height": fmt.Sprintf("%d", height),
<del> "width": fmt.Sprintf("%d", width),
<add> "height": strconv.Itoa(height),
<add> "width": strconv.Itoa(width),
<ide> }
<ide> daemon.LogContainerEventWithAttributes(container, "resize", attributes)
<ide> }
<ide> func (daemon *Daemon) ContainerExecResize(name string, height, width int) error
<ide> case <-ec.Started:
<ide> return ec.Process.Resize(context.Background(), uint32(width), uint32(height))
<ide> case <-timeout.C:
<del> return fmt.Errorf("timeout waiting for exec session ready")
<add> return errors.New("timeout waiting for exec session ready")
<ide> }
<ide> }
<ide><path>daemon/runtime_unix.go
<ide> import (
<ide> "github.com/docker/docker/api/types"
<ide> "github.com/docker/docker/daemon/config"
<ide> "github.com/docker/docker/errdefs"
<del> "github.com/docker/docker/pkg/ioutils"
<ide> "github.com/pkg/errors"
<ide> "github.com/sirupsen/logrus"
<ide> )
<ide> func (daemon *Daemon) initRuntimes(runtimes map[string]types.Runtime) (err error
<ide> runtimeDir := filepath.Join(daemon.configStore.Root, "runtimes")
<ide> // Remove old temp directory if any
<ide> os.RemoveAll(runtimeDir + "-old")
<del> tmpDir, err := ioutils.TempDir(daemon.configStore.Root, "gen-runtimes")
<add> tmpDir, err := os.MkdirTemp(daemon.configStore.Root, "gen-runtimes")
<ide> if err != nil {
<ide> return errors.Wrap(err, "failed to get temp dir to generate runtime scripts")
<ide> } | 7 |
Go | Go | extract mknod, umask, lstat to pkg/system | 3d2fae353f6ddc819d3a3c4db80887a40ac6f5f0 | <ide><path>pkg/archive/archive.go
<ide> func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L
<ide> mode |= syscall.S_IFIFO
<ide> }
<ide>
<del> if err := syscall.Mknod(path, mode, int(mkdev(hdr.Devmajor, hdr.Devminor))); err != nil {
<add> if err := syscall.Mknod(path, mode, int(system.Mkdev(hdr.Devmajor, hdr.Devminor))); err != nil {
<ide> return err
<ide> }
<ide>
<ide><path>pkg/archive/changes.go
<ide> func newRootFileInfo() *FileInfo {
<ide> return root
<ide> }
<ide>
<add>func lstat(path string) (*stat, error) {
<add> s, err := system.Lstat(path)
<add> if err != nil {
<add> return nil, err
<add> }
<add> return fromStatT(s), nil
<add>}
<add>
<ide> func collectFileInfo(sourceDir string) (*FileInfo, error) {
<ide> root := newRootFileInfo()
<ide>
<ide> func collectFileInfo(sourceDir string) (*FileInfo, error) {
<ide> parent: parent,
<ide> }
<ide>
<del> if err := syscall.Lstat(path, &info.stat); err != nil {
<add> s, err := lstat(path)
<add> if err != nil {
<ide> return err
<ide> }
<add> info.stat = s
<ide>
<ide> info.capability, _ = system.Lgetxattr(path, "security.capability")
<ide>
<ide><path>pkg/archive/diff.go
<ide> import (
<ide> "github.com/docker/docker/pkg/pools"
<ide> )
<ide>
<del>// Linux device nodes are a bit weird due to backwards compat with 16 bit device nodes.
<del>// They are, from low to high: the lower 8 bits of the minor, then 12 bits of the major,
<del>// then the top 12 bits of the minor
<del>func mkdev(major int64, minor int64) uint32 {
<del> return uint32(((minor & 0xfff00) << 12) | ((major & 0xfff) << 8) | (minor & 0xff))
<del>}
<del>
<ide> // ApplyLayer parses a diff in the standard layer format from `layer`, and
<ide> // applies it to the directory `dest`.
<ide> func ApplyLayer(dest string, layer ArchiveReader) error {
<ide><path>pkg/system/lstat.go
<add>// +build !windows
<add>
<add>package system
<add>
<add>import (
<add> "syscall"
<add>)
<add>
<add>func Lstat(path string) (*syscall.Stat_t, error) {
<add> s := &syscall.Stat_t{}
<add> err := syscall.Lstat(path, s)
<add> if err != nil {
<add> return nil, err
<add> }
<add> return s, nil
<add>}
<ide><path>pkg/system/lstat_windows.go
<add>// +build windows
<add>
<add>package system
<add>
<add>import (
<add> "syscall"
<add>)
<add>
<add>func Lstat(path string) (*syscall.Win32FileAttributeData, error) {
<add> // should not be called on cli code path
<add> return nil, ErrNotSupportedPlatform
<add>}
<ide><path>pkg/system/mknod.go
<add>// +build !windows
<add>
<add>package system
<add>
<add>import (
<add> "syscall"
<add>)
<add>
<add>func Mknod(path string, mode uint32, dev int) error {
<add> return syscall.Mknod(path, mode, dev)
<add>}
<add>
<add>// Linux device nodes are a bit weird due to backwards compat with 16 bit device nodes.
<add>// They are, from low to high: the lower 8 bits of the minor, then 12 bits of the major,
<add>// then the top 12 bits of the minor
<add>func Mkdev(major int64, minor int64) uint32 {
<add> return uint32(((minor & 0xfff00) << 12) | ((major & 0xfff) << 8) | (minor & 0xff))
<add>}
<ide><path>pkg/system/mknod_windows.go
<add>// +build windows
<add>
<add>package system
<add>
<add>func Mknod(path string, mode uint32, dev int) error {
<add> // should not be called on cli code path
<add> return ErrNotSupportedPlatform
<add>}
<add>
<add>func Mkdev(major int64, minor int64) uint32 {
<add> panic("Mkdev not implemented on windows, should not be called on cli code")
<add>}
<ide><path>pkg/system/umask.go
<add>// +build !windows
<add>
<add>package system
<add>
<add>import (
<add> "syscall"
<add>)
<add>
<add>func Umask(newmask int) (oldmask int, err error) {
<add> return syscall.Umask(newmask), nil
<add>}
<ide><path>pkg/system/umask_windows.go
<add>// +build windows
<add>
<add>package system
<add>
<add>func Umask(newmask int) (oldmask int, err error) {
<add> // should not be called on cli code path
<add> return 0, ErrNotSupportedPlatform
<add>} | 9 |
Javascript | Javascript | fix todo comments | 665fbd0ca866985b93e46350dcd35beb209f70ed | <ide><path>lib/Compilation.js
<ide> class Compilation extends Tapable {
<ide> var unusedIds = [];
<ide> var nextFreeModuleId = 0;
<ide> var usedIds = [];
<del> // TODO
<add> // TODO consider Map when performance has improved https://gist.github.com/sokra/234c077e1299b7369461f1708519c392
<ide> var usedIdMap = Object.create(null);
<ide> if(this.usedModuleIds) {
<ide> Object.keys(this.usedModuleIds).forEach(key => {
<ide> class Compilation extends Tapable {
<ide> });
<ide> }
<ide>
<del> // TODO
<ide> var modules1 = this.modules;
<ide> for(var indexModule1 = 0; indexModule1 < modules1.length; indexModule1++) {
<ide> var module1 = modules1[indexModule1];
<ide><path>lib/optimize/RemoveParentModulesPlugin.js
<ide> class RemoveParentModulesPlugin {
<ide> for(var index = 0; index < chunks.length; index++) {
<ide> var chunk = chunks[index];
<ide>
<add> // TODO consider Map when performance has improved https://gist.github.com/sokra/b36098368da7b8f6792fd7c85fca6311
<ide> var cache = Object.create(null);
<ide> var modules = chunk.modules.slice();
<ide> for(var i = 0; i < modules.length; i++) { | 2 |
PHP | PHP | add test asserting immutable/mutable datetime | 5c21e5f3813ac0606d48437b5aa234171465d051 | <ide><path>tests/TestCase/ORM/Behavior/TimestampBehaviorTest.php
<ide> */
<ide> namespace Cake\Test\TestCase\ORM\Behavior;
<ide>
<add>use Cake\Database\Type;
<ide> use Cake\Event\Event;
<ide> use Cake\I18n\Time;
<ide> use Cake\ORM\Behavior\TimestampBehavior;
<ide> public function testModifiedPresent()
<ide> $this->assertSame($ts->format('c'), $entity->modified->format('c'), 'Modified timestamp is expected to be updated');
<ide> }
<ide>
<add> /**
<add> * testUseImmutable
<add> *
<add> * @return void
<add> * @triggers Model.beforeSave
<add> */
<add> public function testUseImmutable()
<add> {
<add> $table = $this->getTable();
<add> $this->Behavior = new TimestampBehavior($table);
<add> $entity = new Entity();
<add> $event = new Event('Model.beforeSave');
<add>
<add> Type::build('timestamp')->useImmutable();
<add> $entity->clean();
<add> $this->Behavior->handleEvent($event, $entity);
<add> $this->assertInstanceOf('Cake\I18n\FrozenTime', $entity->modified);
<add>
<add> Type::build('timestamp')->useMutable();
<add> $entity->clean();
<add> $this->Behavior->handleEvent($event, $entity);
<add> $this->assertInstanceOf('Cake\I18n\Time', $entity->modified);
<add> }
<add>
<ide> /**
<ide> * testInvalidEventConfig
<ide> * | 1 |
Go | Go | fix incorrect handling of "**/foo" pattern | 90f8d1b6756825093f92547f6141bd196c5a3a80 | <ide><path>pkg/fileutils/fileutils.go
<ide> func (pm *PatternMatcher) Matches(file string) (bool, error) {
<ide>
<ide> if !match && parentPath != "." {
<ide> // Check to see if the pattern matches one of our parent dirs.
<del> if len(pattern.dirs) <= len(parentPathDirs) {
<del> match, _ = pattern.match(strings.Join(parentPathDirs[:len(pattern.dirs)], string(os.PathSeparator)))
<add> for i := range parentPathDirs {
<add> match, _ = pattern.match(strings.Join(parentPathDirs[:i+1], string(os.PathSeparator)))
<add> if match {
<add> break
<add> }
<ide> }
<ide> }
<ide>
<ide><path>pkg/fileutils/fileutils_test.go
<ide> func TestMatches(t *testing.T) {
<ide> {"dir/**", "dir/file/", true},
<ide> {"dir/**", "dir/dir2/file", true},
<ide> {"dir/**", "dir/dir2/file/", true},
<add> {"**/dir", "dir", true},
<add> {"**/dir", "dir/file", true},
<ide> {"**/dir2/*", "dir/dir2/file", true},
<ide> {"**/dir2/*", "dir/dir2/file/", true},
<ide> {"**/dir2/**", "dir/dir2/dir3/file", true}, | 2 |
Text | Text | add link to the show action in the getting started | 5f5f3a8216f5c8f2c484f80eec6ee69cd28d5977 | <ide><path>guides/source/getting_started.md
<ide> And then finally, add the view for this action, located at
<ide> <tr>
<ide> <td><%= article.title %></td>
<ide> <td><%= article.text %></td>
<add> <td><%= link_to 'Show', article_path(article) %></td>
<ide> </tr>
<ide> <% end %>
<ide> </table> | 1 |
Javascript | Javascript | add internal createdeferredpromise() | 17467d15f8e0494579c32acf576240a346e82c2b | <ide><path>lib/child_process.js
<ide> const {
<ide> ObjectAssign,
<ide> ObjectDefineProperty,
<ide> ObjectPrototypeHasOwnProperty,
<del> Promise,
<ide> RegExpPrototypeTest,
<ide> SafeSet,
<ide> StringPrototypeSlice,
<ide> const {
<ide> const {
<ide> promisify,
<ide> convertToValidSignal,
<add> createDeferredPromise,
<ide> getSystemErrorName
<ide> } = require('internal/util');
<ide> const { isArrayBufferView } = require('internal/util/types');
<ide> function exec(command, options, callback) {
<ide>
<ide> const customPromiseExecFunction = (orig) => {
<ide> return (...args) => {
<del> let resolve;
<del> let reject;
<del> const promise = new Promise((res, rej) => {
<del> resolve = res;
<del> reject = rej;
<del> });
<add> const { promise, resolve, reject } = createDeferredPromise();
<ide>
<ide> promise.child = orig(...args, (err, stdout, stderr) => {
<ide> if (err !== null) {
<ide><path>lib/internal/blob.js
<ide> const {
<ide> ArrayFrom,
<ide> ObjectSetPrototypeOf,
<del> Promise,
<ide> PromiseResolve,
<ide> RegExpPrototypeTest,
<ide> StringPrototypeToLowerCase,
<ide> const {
<ide> } = require('internal/util/types');
<ide>
<ide> const {
<add> createDeferredPromise,
<ide> customInspectSymbol: kInspect,
<ide> emitExperimentalWarning,
<ide> } = require('internal/util');
<ide> const kLength = Symbol('kLength');
<ide>
<ide> let Buffer;
<ide>
<del>function deferred() {
<del> let res, rej;
<del> const promise = new Promise((resolve, reject) => {
<del> res = resolve;
<del> rej = reject;
<del> });
<del> return { promise, resolve: res, reject: rej };
<del>}
<del>
<ide> function lazyBuffer() {
<ide> if (Buffer === undefined)
<ide> Buffer = require('buffer').Buffer;
<ide> class Blob extends JSTransferable {
<ide> promise,
<ide> resolve,
<ide> reject
<del> } = deferred();
<add> } = createDeferredPromise();
<ide> job.ondone = (err, ab) => {
<ide> if (err !== undefined)
<ide> return reject(new AbortError());
<ide><path>lib/internal/util.js
<ide> function sleep(msec) {
<ide> _sleep(msec);
<ide> }
<ide>
<add>function createDeferredPromise() {
<add> let resolve;
<add> let reject;
<add> const promise = new Promise((res, rej) => {
<add> resolve = res;
<add> reject = rej;
<add> });
<add>
<add> return { promise, resolve, reject };
<add>}
<add>
<ide> module.exports = {
<ide> assertCrypto,
<ide> cachedResult,
<ide> convertToValidSignal,
<ide> createClassWrapper,
<add> createDeferredPromise,
<ide> decorateErrorStack,
<ide> deprecate,
<ide> emitExperimentalWarning, | 3 |
Ruby | Ruby | move the header hash to the super class | fcf5e178dd6384cb5f9e99c0026ba958e426a03f | <ide><path>actionpack/lib/action_controller/metal/live.rb
<ide> def call_on_error
<ide> end
<ide>
<ide> class Response < ActionDispatch::Response #:nodoc: all
<del> class Header < DelegateClass(Hash) # :nodoc:
<del> def initialize(response, header)
<del> @response = response
<del> super(header)
<del> end
<del>
<del> def []=(k,v)
<del> if @response.committed?
<del> raise ActionDispatch::IllegalStateError, 'header already sent'
<del> end
<del>
<del> super
<del> end
<del>
<del> def merge(other)
<del> self.class.new @response, __getobj__.merge(other)
<del> end
<del>
<del> def to_hash
<del> __getobj__.dup
<del> end
<del> end
<del>
<del> def initialize(status = 200, header = {}, body = [])
<del> super(status, Header.new(self, header), body)
<del> end
<del>
<ide> private
<ide>
<ide> def before_committed
<ide><path>actionpack/lib/action_dispatch/http/response.rb
<ide> module ActionDispatch # :nodoc:
<ide> # end
<ide> # end
<ide> class Response
<add> class Header < DelegateClass(Hash) # :nodoc:
<add> def initialize(response, header)
<add> @response = response
<add> super(header)
<add> end
<add>
<add> def []=(k,v)
<add> if @response.committed?
<add> raise ActionDispatch::IllegalStateError, 'header already sent'
<add> end
<add>
<add> super
<add> end
<add>
<add> def merge(other)
<add> self.class.new @response, __getobj__.merge(other)
<add> end
<add>
<add> def to_hash
<add> __getobj__.dup
<add> end
<add> end
<add>
<ide> # The request that the response is responding to.
<ide> attr_accessor :request
<ide>
<ide> def self.merge_default_headers(original, default)
<ide> def initialize(status = 200, header = {}, body = [])
<ide> super()
<ide>
<del> @header = header
<add> @header = Header.new(self, header)
<ide>
<ide> self.body, self.status = body, status
<ide> | 2 |
Text | Text | fix extra changelog entry added in 959d46e | 81c5c9971abe7a42a53ddbfede2683081a67e9d1 | <ide><path>activesupport/CHANGELOG.md
<ide>
<ide> *Matt Swanson*
<ide>
<del>* Add `urlsafe` option to `ActiveSupport::MessageVerifier` initializer
<del>
<ide> * Fix `NoMethodError` on custom `ActiveSupport::Deprecation` behavior.
<ide>
<ide> `ActiveSupport::Deprecation.behavior=` was supposed to accept any object | 1 |
Javascript | Javascript | remove duplicate expression | 362dd1786f585594de8295144dd161dc425e6676 | <ide><path>docs/config/services/deployments/production.js
<ide> var cdnUrl = googleCdnUrl + versionInfo.cdnVersion;
<ide> // docs.angularjs.org and code.angularjs.org need them.
<ide> var versionPath = versionInfo.currentVersion.isSnapshot ?
<ide> 'snapshot' :
<del> (versionInfo.currentVersion.version || versionInfo.currentVersion.version);
<add> versionInfo.currentVersion.version;
<ide> var examplesDependencyPath = angularCodeUrl + versionPath + '/';
<ide>
<ide> module.exports = function productionDeployment(getVersion) { | 1 |
Text | Text | update backend docs | 90f76daf11a8376670928dacd555c69c683e12d4 | <ide><path>docs/templates/backend.md
<ide> Keras is a model-level library, providing high-level building blocks for develop
<ide>
<ide> At this time, Keras has three backend implementations available: the **TensorFlow** backend, the **Theano** backend, and the **CNTK** backend.
<ide>
<del>- [TensorFlow](http://www.tensorflow.org/) is an open-source symbolic tensor manipulation framework developed by Google, Inc.
<del>- [Theano](http://deeplearning.net/software/theano/) is an open-source symbolic tensor manipulation framework developed by LISA/MILA Lab at Université de Montréal.
<del>- [CNTK](https://www.microsoft.com/en-us/cognitive-toolkit/) is an open-source, commercial-grade toolkit for deep learning developed by Microsoft.
<add>- [TensorFlow](http://www.tensorflow.org/) is an open-source symbolic tensor manipulation framework developed by Google.
<add>- [Theano](http://deeplearning.net/software/theano/) is an open-source symbolic tensor manipulation framework developed by LISA Lab at Université de Montréal.
<add>- [CNTK](https://www.microsoft.com/en-us/cognitive-toolkit/) is an open-source toolkit for deep learning developed by Microsoft.
<ide>
<ide> In the future, we are likely to add more backend options.
<ide>
<ide> If you have run Keras at least once, you will find the Keras configuration file
<ide>
<ide> If it isn't there, you can create it.
<ide>
<del>**NOTE for Windows Users:** Please change `$HOME` with `%USERPROFILE%`.
<add>**NOTE for Windows Users:** Please replace `$HOME` with `%USERPROFILE%`.
<ide>
<ide> The default configuration file looks like this:
<ide>
<ide> Using TensorFlow backend.
<ide> ## keras.json details
<ide>
<ide>
<add>The `keras.json` configuration file contains the following settings:
<add>
<ide> ```
<ide> {
<ide> "image_data_format": "channels_last",
<ide> Using TensorFlow backend.
<ide>
<ide> You can change these settings by editing `$HOME/.keras/keras.json`.
<ide>
<del>* `image_data_format`: string, either `"channels_last"` or `"channels_first"`. It specifies which data format convention Keras will follow. (`keras.backend.image_data_format()` returns it.)
<add>* `image_data_format`: String, either `"channels_last"` or `"channels_first"`. It specifies which data format convention Keras will follow. (`keras.backend.image_data_format()` returns it.)
<ide> - For 2D data (e.g. image), `"channels_last"` assumes `(rows, cols, channels)` while `"channels_first"` assumes `(channels, rows, cols)`.
<ide> - For 3D data, `"channels_last"` assumes `(conv_dim1, conv_dim2, conv_dim3, channels)` while `"channels_first"` assumes `(channels, conv_dim1, conv_dim2, conv_dim3)`.
<del>* `epsilon`: float, a numeric fuzzing constant used to avoid dividing by zero in some operations.
<del>* `floatx`: string, `"float16"`, `"float32"`, or `"float64"`. Default float precision.
<del>* `backend`: string, `"tensorflow"`, `"theano"`, or `"cntk"`.
<add>* `epsilon`: Float, a numeric fuzzing constant used to avoid dividing by zero in some operations.
<add>* `floatx`: String, `"float16"`, `"float32"`, or `"float64"`. Default float precision.
<add>* `backend`: String, `"tensorflow"`, `"theano"`, or `"cntk"`.
<ide>
<ide> ----
<ide>
<ide> inputs = K.placeholder(shape=(None, 4, 5))
<ide> inputs = K.placeholder(ndim=3)
<ide> ```
<ide>
<del>The code below instantiates a shared variable. It's equivalent to `tf.Variable()` or `th.shared()`.
<add>The code below instantiates a variable. It's equivalent to `tf.Variable()` or `th.shared()`.
<ide>
<ide> ```python
<ide> import numpy as np
<ide> Most tensor operations you will need can be done as you would in TensorFlow or T
<ide> b = K.random_uniform_variable(shape=(3, 4)). # Uniform distribution
<ide> c = K.random_normal_variable(shape=(3, 4)). # Gaussian distribution
<ide> d = K.random_normal_variable(shape=(3, 4)).
<del># Tensor Arithmetics
<add>
<add># Tensor Arithmetic
<ide> a = b + c * K.abs(d)
<ide> c = K.dot(a, K.transpose(b))
<ide> a = K.sum(b, axis=1) | 1 |
Go | Go | fix the tests, too | 0d871840b202fc31418990bbcbe0df1c4ad689fb | <ide><path>integration/api_test.go
<ide> import (
<ide> "fmt"
<ide> "github.com/dotcloud/docker"
<ide> "github.com/dotcloud/docker/api"
<add> "github.com/dotcloud/docker/dockerversion"
<ide> "github.com/dotcloud/docker/engine"
<ide> "github.com/dotcloud/docker/utils"
<ide> "io"
<ide> func TestGetVersion(t *testing.T) {
<ide> t.Fatal(err)
<ide> }
<ide> out.Close()
<del> expected := docker.VERSION
<add> expected := dockerversion.VERSION
<ide> if result := v.Get("Version"); result != expected {
<ide> t.Errorf("Expected version %s, %s found", expected, result)
<ide> }
<ide><path>integration/graph_test.go
<ide> import (
<ide> "errors"
<ide> "github.com/dotcloud/docker"
<ide> "github.com/dotcloud/docker/archive"
<add> "github.com/dotcloud/docker/dockerversion"
<ide> "github.com/dotcloud/docker/graphdriver"
<ide> "github.com/dotcloud/docker/utils"
<ide> "io"
<ide> func TestGraphCreate(t *testing.T) {
<ide> if image.Comment != "Testing" {
<ide> t.Fatalf("Wrong comment: should be '%s', not '%s'", "Testing", image.Comment)
<ide> }
<del> if image.DockerVersion != docker.VERSION {
<del> t.Fatalf("Wrong docker_version: should be '%s', not '%s'", docker.VERSION, image.DockerVersion)
<add> if image.DockerVersion != dockerversion.VERSION {
<add> t.Fatalf("Wrong docker_version: should be '%s', not '%s'", dockerversion.VERSION, image.DockerVersion)
<ide> }
<ide> images, err := graph.Map()
<ide> if err != nil { | 2 |
Text | Text | remove non-latest builds | 83141df210fa420d5bf0470d46acdecd5b777ff8 | <ide><path>CONTRIBUTING.md
<ide> this bug already.
<ide> demo should be fully operational with the exception of the bug you want to
<ide> demonstrate. The more pared down, the better.
<ide> Preconfigured starting points for the latest Ember: [JSFiddle](http://jsfiddle.net/DCrHG/) | [JSBin](http://jsbin.com/ucanam/54/edit) (may not work with older IE versions due to MIME type isses).
<del>Preconfigured starting points for 1.0.0-rc.3: [JSFiddle](http://jsfiddle.net/3bGN4/244/) | [JSBin](http://jsbin.com/icejog/1/edit).
<ide> Issues with fiddles are prioritized.
<ide>
<ide> 4. Your issue will be verified. The provided fiddle will be tested for | 1 |
Ruby | Ruby | push reduction visitors to a reduction base class | a6a7c75ff486657909e20e2f48764136caa5e87e | <ide><path>lib/arel/visitors/depth_first.rb
<ide> def initialize block = nil
<ide> @block = block || Proc.new
<ide> end
<ide>
<del> def accept object
<del> visit object
<del> end
<del>
<ide> private
<ide>
<del> def visit object
<del> send dispatch[object.class], object
<del> rescue NoMethodError => e
<del> raise e if respond_to?(dispatch[object.class], true)
<del> superklass = object.class.ancestors.find { |klass|
<del> respond_to?(dispatch[klass], true)
<del> }
<del> raise(TypeError, "Cannot visit #{object.class}") unless superklass
<del> dispatch[object.class] = dispatch[superklass]
<del> retry
<add> def visit o
<add> super
<add> @block.call o
<ide> end
<ide>
<ide> def unary o
<ide><path>lib/arel/visitors/dot.rb
<ide> def initialize
<ide> end
<ide>
<ide> def accept object
<del> super
<add> visit object
<ide> to_dot
<ide> end
<ide>
<ide> private
<add>
<ide> def visit_Arel_Nodes_Ordering o
<ide> visit_edge o, "expr"
<ide> end
<ide><path>lib/arel/visitors/reduce.rb
<add>require 'arel/visitors/visitor'
<add>
<add>module Arel
<add> module Visitors
<add> class Reduce < Arel::Visitors::Visitor
<add> def accept object, collector
<add> visit object, collector
<add> end
<add>
<add> private
<add>
<add> def visit object, collector
<add> send dispatch[object.class], object, collector
<add> rescue NoMethodError => e
<add> raise e if respond_to?(dispatch[object.class], true)
<add> superklass = object.class.ancestors.find { |klass|
<add> respond_to?(dispatch[klass], true)
<add> }
<add> raise(TypeError, "Cannot visit #{object.class}") unless superklass
<add> dispatch[object.class] = dispatch[superklass]
<add> retry
<add> end
<add> end
<add> end
<add>end
<ide><path>lib/arel/visitors/to_sql.rb
<ide> require 'bigdecimal'
<ide> require 'date'
<add>require 'arel/visitors/reduce'
<ide>
<ide> module Arel
<ide> module Visitors
<del> class ToSql < Arel::Visitors::Visitor
<add> class ToSql < Arel::Visitors::Reduce
<ide> ##
<ide> # This is some roflscale crazy stuff. I'm roflscaling this because
<ide> # building SQL queries is a hotspot. I will explain the roflscale so that
<ide><path>lib/arel/visitors/visitor.rb
<ide> module Arel
<ide> module Visitors
<ide> class Visitor
<del> def accept object, collector
<del> visit object, collector
<add> def accept object
<add> visit object
<ide> end
<ide>
<ide> private
<ide> def dispatch
<ide> DISPATCH[self.class]
<ide> end
<ide>
<del> def visit object, collector
<del> send dispatch[object.class], object, collector
<add> def visit object
<add> send dispatch[object.class], object
<ide> rescue NoMethodError => e
<ide> raise e if respond_to?(dispatch[object.class], true)
<ide> superklass = object.class.ancestors.find { |klass|
<ide><path>test/visitors/test_to_sql.rb
<ide> def compile node
<ide>
<ide> it 'can define a dispatch method' do
<ide> visited = false
<del> viz = Class.new(Arel::Visitors::Visitor) {
<add> viz = Class.new(Arel::Visitors::Reduce) {
<ide> define_method(:hello) do |node, c|
<ide> visited = true
<ide> end | 6 |
PHP | PHP | apply fixes from styleci | 4be74e19a6282a789070b6da81f70e1a886b7176 | <ide><path>src/Illuminate/View/Compilers/Concerns/CompilesConditionals.php
<ide> protected function compileEndunless()
<ide> {
<ide> return '<?php endif; ?>';
<ide> }
<del>
<add>
<ide> /**
<ide> * Compile the if-isset statements into valid PHP.
<ide> * | 1 |
Ruby | Ruby | fetch new tags for git repos when cached | d518fca81c7ecebcb56feaabdb142dfd322b429c | <ide><path>Library/Homebrew/download_strategy.rb
<ide> def fetch
<ide> safe_system 'git', 'clone', @url, @clone # indeed, leave it verbose
<ide> else
<ide> puts "Updating #{@clone}"
<del> Dir.chdir(@clone) { quiet_safe_system 'git', 'fetch', @url }
<add> Dir.chdir(@clone) do
<add> quiet_safe_system 'git', 'fetch', @url
<add> # If we're going to checkout a tag, then we need to fetch new tags too.
<add> quiet_safe_system 'git', 'fetch', '--tags' if @spec == :tag
<add> end
<ide> end
<ide> end
<ide> | 1 |
Python | Python | correct an issue with unitest on python 3.x | 0ecbb12444794eaa9c62e51f7146871429ce6c6c | <ide><path>glances/plugins/glances_wifi.py
<ide>
<ide> # Python 3 is not supported (see issue #1377)
<ide> if PY3:
<del> import_error_tag = False
<add> import_error_tag = True
<ide> logger.warning("Wifi lib is not compliant with Python 3, Wifi plugin is disabled")
<ide>
<ide> | 1 |
Javascript | Javascript | add coverage for dns exception | 743c28104f3db504963409e8e91700e430131221 | <ide><path>test/parallel/test-dns-resolve-promises.js
<add>// Flags: --expose-internals
<add>'use strict';
<add>require('../common');
<add>const assert = require('assert');
<add>const { internalBinding } = require('internal/test/binding');
<add>const cares = internalBinding('cares_wrap');
<add>const { UV_EPERM } = internalBinding('uv');
<add>const dnsPromises = require('dns').promises;
<add>
<add>// Stub cares to force an error so we can test DNS error code path.
<add>cares.ChannelWrap.prototype.queryA = () => UV_EPERM;
<add>
<add>assert.rejects(
<add> dnsPromises.resolve('example.org'),
<add> {
<add> code: 'EPERM',
<add> syscall: 'queryA',
<add> hostname: 'example.org'
<add> }
<add>); | 1 |
Python | Python | add mongo_db param to function doc string | 454ca2ff92d221e4163e5024fc0fc797dc9bad84 | <ide><path>airflow/providers/mongo/sensors/mongo.py
<ide> class MongoSensor(BaseSensorOperator):
<ide> >>> mongo_sensor = MongoSensor(collection="coll",
<ide> ... query={"key": "value"},
<ide> ... mongo_conn_id="mongo_default",
<add> ... mongo_db="admin",
<ide> ... task_id="mongo_sensor")
<ide>
<ide> :param collection: Target MongoDB collection.
<ide> class MongoSensor(BaseSensorOperator):
<ide> :param mongo_conn_id: The :ref:`Mongo connection id <howto/connection:mongo>` to use
<ide> when connecting to MongoDB.
<ide> :type mongo_conn_id: str
<add> :param mongo_db: Target MongoDB name.
<add> :type mongo_db: str
<ide> """
<ide>
<ide> template_fields = ('collection', 'query') | 1 |
Python | Python | add perf stats for processcount | a1f11a72d2a9c5d4cb6103530c34dcf94ad2407f | <ide><path>glances/plugins/glances_processcount.py
<ide> def __init__(self, args=None, config=None):
<ide>
<ide> # Note: 'glances_processes' is already init in the glances_processes.py script
<ide>
<add> @GlancesPlugin._log_result_decorator
<ide> def update(self):
<ide> """Update processes stats using the input method."""
<ide> # Init new stats | 1 |
Ruby | Ruby | add documentation for inheritance_column method | 294219226175f8d17fb0348ceaba51caa5936ec3 | <ide><path>activerecord/lib/active_record/model.rb
<ide> def arel_engine
<ide> def abstract_class?
<ide> false
<ide> end
<del>
<add>
<add> # Defines the name of the table column which will store the class name on single-table
<add> # inheritance situations.
<ide> def inheritance_column
<ide> 'type'
<ide> end | 1 |
Javascript | Javascript | add a way to disable fonts that won't load | 2feec66b746513f004f8e6707974e7bf3a3050e0 | <ide><path>fonts.js
<ide> var kMaxWaitForFontFace = 1000;
<ide> var fontCount = 0;
<ide> var fontName = "";
<ide>
<add>/**
<add> * If for some reason one want to debug without fonts activated, it just need
<add> * to turn this pref to true/false.
<add> */
<add>var kDisableFonts = false;
<add>
<ide> /**
<ide> * Hold a map of decoded fonts and of the standard fourteen Type1 fonts and
<ide> * their acronyms.
<ide> var Font = function(aName, aFile, aProperties) {
<ide> }
<ide> fontCount++;
<ide>
<add> if (aProperties.ignore || kDisableFonts) {
<add> Fonts[aName] = {
<add> data: aFile,
<add> loading: false,
<add> properties: {},
<add> cache: Object.create(null)
<add> }
<add> return;
<add> }
<add>
<ide> switch (aProperties.type) {
<ide> case "Type1":
<ide> var cff = new CFF(aName, aFile, aProperties);
<ide> Font.prototype = {
<ide> if (debug)
<ide> ctx.fillText(testString, 20, 20);
<ide>
<del> var start = Date.now();
<ide> var interval = window.setInterval(function canvasInterval(self) {
<add> this.start = this.start || Date.now();
<ide> ctx.font = "bold italic 20px " + fontName + ", Symbol, Arial";
<ide>
<ide> // For some reasons the font has not loaded, so mark it loaded for the
<ide> // page to proceed but cry
<del> if ((Date.now() - start) >= kMaxWaitForFontFace) {
<add> if ((Date.now() - this.start) >= kMaxWaitForFontFace) {
<ide> window.clearInterval(interval);
<ide> Fonts[fontName].loading = false;
<ide> warn("Is " + fontName + " for charset: " + charset + " loaded?");
<add> this.start = 0;
<ide> } else if (textWidth != ctx.measureText(testString).width) {
<ide> window.clearInterval(interval);
<ide> Fonts[fontName].loading = false;
<add> this.start = 0;
<ide> }
<ide>
<ide> if (debug)
<ide> var TrueType = function(aName, aFile, aProperties) {
<ide> });
<ide> }
<ide>
<add>
<add> var offsetDelta = 0;
<add>
<ide> // Replace the old CMAP table
<ide> var rewrittedCMAP = this._createCMAPTable(glyphs);
<del> var offsetDelta = rewrittedCMAP.length - originalCMAP.data.length;
<add> offsetDelta = rewrittedCMAP.length - originalCMAP.data.length;
<ide> originalCMAP.data = rewrittedCMAP;
<ide>
<ide> // Rewrite the 'post' table if needed
<ide><path>pdf.js
<ide> var CanvasGraphics = (function() {
<ide> error("FontFile not found for font: " + fontName);
<ide> fontFile = xref.fetchIfRef(fontFile);
<ide>
<add> // Fonts with an embedded cmap but without any assignment in
<add> // it are not yet supported, so ask the fonts loader to ignore
<add> // them to not pay a stupid one sec latence.
<add> var ignoreFont = true;
<add>
<ide> var encodingMap = {};
<ide> var charset = [];
<ide> if (fontDict.has("Encoding")) {
<add> ignoreFont = false;
<add>
<ide> var encoding = xref.fetchIfRef(fontDict.get("Encoding"));
<ide> if (IsDict(encoding)) {
<ide> // Build a map between codes and glyphs
<ide> var CanvasGraphics = (function() {
<ide> error("useCMap is not implemented");
<ide> break;
<ide>
<del> case "begincodespacerange":
<ide> case "beginbfrange":
<add> ignoreFont = false;
<add> case "begincodespacerange":
<ide> token = "";
<ide> tokens = [];
<ide> break;
<ide> var CanvasGraphics = (function() {
<ide> }
<ide> }
<ide> }
<del> }
<add> }
<ide>
<ide> var subType = fontDict.get("Subtype");
<ide> var bbox = descriptor.get("FontBBox");
<ide> var CanvasGraphics = (function() {
<ide> type: subType.name,
<ide> encoding: encodingMap,
<ide> charset: charset,
<del> bbox: bbox
<add> bbox: bbox,
<add> ignore: ignoreFont
<ide> };
<ide>
<ide> return {
<ide> var CanvasGraphics = (function() {
<ide> }
<ide>
<ide> this.current.fontSize = size;
<del> this.ctx.font = this.current.fontSize +'px "' + fontName + '"';
<add> this.ctx.font = this.current.fontSize +'px "' + fontName + '", Symbol';
<ide> },
<ide> setTextRenderingMode: function(mode) {
<ide> TODO("text rendering mode"); | 2 |
PHP | PHP | add the url method for sanity | ef81c531512de75214e3723fa0725c2b64ad6395 | <ide><path>src/Illuminate/Filesystem/FilesystemAdapter.php
<ide> use Illuminate\Support\Collection;
<ide> use League\Flysystem\AdapterInterface;
<ide> use League\Flysystem\FilesystemInterface;
<add>use League\Flysystem\AwsS3v3\AwsS3Adapter;
<ide> use League\Flysystem\FileNotFoundException;
<ide> use Illuminate\Contracts\Filesystem\Filesystem as FilesystemContract;
<ide> use Illuminate\Contracts\Filesystem\Cloud as CloudFilesystemContract;
<ide> public function lastModified($path)
<ide> return $this->driver->getTimestamp($path);
<ide> }
<ide>
<add> /**
<add> * Get the URL for the file at the given path.
<add> *
<add> * @param string $path
<add> * @return string
<add> */
<add> public function url($path)
<add> {
<add> if (! $this->driver->getAdapter() instanceof AwsS3Adapter) {
<add> throw new RuntimeException("This driver does not support retrieving URLs.");
<add> }
<add>
<add> $bucket = $this->driver->getAdapter()->getBucket();
<add>
<add> return $this->driver->getAdapter()->getClient()->getObjectUrl($bucket, $path);
<add> }
<add>
<ide> /**
<ide> * Get an array of all files in a directory.
<ide> * | 1 |
Ruby | Ruby | eliminate the duplication code of `statementpool` | f9e27bc582fc66e04f11d42cb420636654872cba | <ide><path>activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
<ide> class MysqlAdapter < AbstractMysqlAdapter
<ide> ADAPTER_NAME = 'MySQL'.freeze
<ide>
<ide> class StatementPool < ConnectionAdapters::StatementPool
<del> def initialize(connection, max = 1000)
<del> super
<del> @cache = Hash.new { |h,pid| h[pid] = {} }
<del> end
<del>
<del> def each(&block); cache.each(&block); end
<del> def key?(key); cache.key?(key); end
<del> def [](key); cache[key]; end
<del> def length; cache.length; end
<del> def delete(key); cache.delete(key); end
<del>
<del> def []=(sql, key)
<del> while @max <= cache.size
<del> cache.shift.last[:stmt].close
<del> end
<del> cache[sql] = key
<del> end
<del>
<del> def clear
<del> cache.each_value do |hash|
<del> hash[:stmt].close
<del> end
<del> cache.clear
<del> end
<del>
<ide> private
<del> def cache
<del> @cache[Process.pid]
<add>
<add> def dealloc(stmt)
<add> stmt[:stmt].close
<ide> end
<ide> end
<ide>
<ide> def exec_stmt(sql, name, binds)
<ide> # place when an error occurs. To support older MySQL versions, we
<ide> # need to close the statement and delete the statement from the
<ide> # cache.
<del> stmt.close
<del> @statements.delete sql
<add> if binds.empty?
<add> stmt.close
<add> else
<add> @statements.delete sql
<add> end
<ide> raise e
<ide> end
<ide>
<ide><path>activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
<ide> class StatementPool < ConnectionAdapters::StatementPool
<ide> def initialize(connection, max)
<ide> super
<ide> @counter = 0
<del> @cache = Hash.new { |h,pid| h[pid] = {} }
<ide> end
<ide>
<del> def each(&block); cache.each(&block); end
<del> def key?(key); cache.key?(key); end
<del> def [](key); cache[key]; end
<del> def length; cache.length; end
<del>
<ide> def next_key
<ide> "a#{@counter + 1}"
<ide> end
<ide>
<ide> def []=(sql, key)
<del> while @max <= cache.size
<del> dealloc(cache.shift.last)
<del> end
<del> @counter += 1
<del> cache[sql] = key
<del> end
<del>
<del> def clear
<del> cache.each_value do |stmt_key|
<del> dealloc stmt_key
<del> end
<del> cache.clear
<del> end
<del>
<del> def delete(sql_key)
<del> dealloc cache[sql_key]
<del> cache.delete sql_key
<add> super.tap { @counter += 1 }
<ide> end
<ide>
<ide> private
<ide>
<del> def cache
<del> @cache[Process.pid]
<del> end
<del>
<ide> def dealloc(key)
<ide> @connection.query "DEALLOCATE #{key}" if connection_active?
<ide> end
<ide><path>activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
<ide> def <=>(version_string)
<ide> end
<ide>
<ide> class StatementPool < ConnectionAdapters::StatementPool
<del> def initialize(connection, max)
<del> super
<del> @cache = Hash.new { |h,pid| h[pid] = {} }
<del> end
<del>
<del> def each(&block); cache.each(&block); end
<del> def key?(key); cache.key?(key); end
<del> def [](key); cache[key]; end
<del> def length; cache.length; end
<del>
<del> def []=(sql, key)
<del> while @max <= cache.size
<del> dealloc(cache.shift.last[:stmt])
<del> end
<del> cache[sql] = key
<del> end
<del>
<del> def clear
<del> cache.each_value do |hash|
<del> dealloc hash[:stmt]
<del> end
<del> cache.clear
<del> end
<del>
<ide> private
<del> def cache
<del> @cache[$$]
<del> end
<ide>
<ide> def dealloc(stmt)
<del> stmt.close unless stmt.closed?
<add> stmt[:stmt].close unless stmt[:stmt].closed?
<ide> end
<ide> end
<ide>
<ide><path>activerecord/lib/active_record/connection_adapters/statement_pool.rb
<ide> class StatementPool
<ide> include Enumerable
<ide>
<ide> def initialize(connection, max = 1000)
<add> @cache = Hash.new { |h,pid| h[pid] = {} }
<ide> @connection = connection
<ide> @max = max
<ide> end
<ide>
<del> def each
<del> raise NotImplementedError
<add> def each(&block)
<add> cache.each(&block)
<ide> end
<ide>
<ide> def key?(key)
<del> raise NotImplementedError
<add> cache.key?(key)
<ide> end
<ide>
<ide> def [](key)
<del> raise NotImplementedError
<add> cache[key]
<ide> end
<ide>
<ide> def length
<del> raise NotImplementedError
<add> cache.length
<ide> end
<ide>
<del> def []=(sql, key)
<del> raise NotImplementedError
<add> def []=(sql, stmt)
<add> while @max <= cache.size
<add> dealloc(cache.shift.last)
<add> end
<add> cache[sql] = stmt
<ide> end
<ide>
<ide> def clear
<del> raise NotImplementedError
<add> cache.each_value do |stmt|
<add> dealloc stmt
<add> end
<add> cache.clear
<ide> end
<ide>
<ide> def delete(key)
<add> dealloc cache[key]
<add> cache.delete(key)
<add> end
<add>
<add> private
<add>
<add> def cache
<add> @cache[Process.pid]
<add> end
<add>
<add> def dealloc(stmt)
<ide> raise NotImplementedError
<ide> end
<ide> end | 4 |
Javascript | Javascript | pass arrays of languages | eaff269698124dedabd13054754782afb76bf8b6 | <ide><path>moment.js
<ide> return value;
<ide> }
<ide>
<add> function normalizeLanguage(key) {
<add> return key.toLowerCase().replace('_', '-');
<add> }
<add>
<ide> /************************************
<ide> Languages
<ide> ************************************/
<ide> // definition for 'en', so long as 'en' has already been loaded using
<ide> // moment.lang.
<ide> function getLangDefinition(key) {
<del> if (!key) {
<del> return moment.fn._lang;
<del> }
<del> if (!languages[key] && hasModule) {
<del> try {
<del> require('./lang/' + key);
<del> } catch (e) {
<del> // call with no params to set to default
<del> return moment.fn._lang;
<add> var i, lang,
<add> get = function (k) {
<add> k = normalizeLanguage(k);
<add> if (!languages[k] && hasModule) {
<add> try {
<add> require('./lang/' + k);
<add> } catch (e) { }
<add> }
<add> return languages[k];
<add> };
<add>
<add> if (isArray(key)) {
<add> for (i in key) {
<add> lang = get(key[i]);
<add> if (lang) {
<add> return lang;
<add> }
<ide> }
<ide> }
<del> return languages[key] || moment.fn._lang;
<add> else if (key) {
<add> return get(key) || moment.fn._lang;
<add> }
<add>
<add> return moment.fn._lang;
<ide> }
<ide>
<ide>
<ide> // no arguments are passed in, it will simply return the current global
<ide> // language key.
<ide> moment.lang = function (key, values) {
<add> var r;
<ide> if (!key) {
<ide> return moment.fn._lang._abbr;
<ide> }
<del> key = key.toLowerCase();
<del> key = key.replace('_', '-');
<ide> if (values) {
<del> loadLang(key, values);
<add> loadLang(normalizeLanguage(key), values);
<ide> } else if (values === null) {
<ide> unloadLang(key);
<ide> key = 'en';
<ide> } else if (!languages[key]) {
<ide> getLangDefinition(key);
<ide> }
<del> moment.duration.fn._lang = moment.fn._lang = getLangDefinition(key);
<add> r = moment.duration.fn._lang = moment.fn._lang = getLangDefinition(key);
<add> return r._abbr;
<ide> };
<ide>
<ide> // returns language data
<ide><path>test/moment/lang.js
<ide> var moment = require("../../moment");
<ide>
<ide> exports.lang = {
<ide> "library getter" : function (test) {
<del> test.expect(7);
<add> var r;
<add> test.expect(8);
<ide>
<del> moment.lang('en');
<add> r = moment.lang('en');
<add> test.equal(r, 'en', 'Lang should return en by default');
<ide> test.equal(moment.lang(), 'en', 'Lang should return en by default');
<ide>
<ide> moment.lang('fr');
<ide> exports.lang = {
<ide> test.done();
<ide> },
<ide>
<add> "library getter array of langs" : function (test) {
<add> test.equal(moment.lang(['non-existent', 'fr', 'also-non-existent']), 'fr', "passing an array uses the first valid language");
<add> test.equal(moment.lang(['es', 'fr', 'also-non-existent']), 'es', "passing an array uses the first valid language");
<add> test.done();
<add> },
<add>
<ide> "library ensure inheritance" : function (test) {
<ide> test.expect(2);
<ide>
<ide> exports.lang = {
<ide> test.done();
<ide> },
<ide>
<add> "instance lang method with array" : function (test) {
<add> var m = moment().lang(['non-existent', 'fr', 'also-non-existent']);
<add> test.equal(m.lang()._abbr, 'fr', "passing an array uses the first valid language");
<add> m = moment().lang(['es', 'fr', 'also-non-existent']);
<add> test.equal(m.lang()._abbr, 'es', "passing an array uses the first valid language");
<add> test.done();
<add> },
<add>
<ide> "instance lang persists with manipulation" : function (test) {
<ide> test.expect(3);
<ide> moment.lang('en'); | 2 |
Javascript | Javascript | add setpath method to fontloader | eb70fbc5547b9894ce997ab64e78c6cda6e73d5d | <ide><path>src/loaders/FontLoader.js
<ide> Object.assign( FontLoader.prototype, {
<ide> var scope = this;
<ide>
<ide> var loader = new FileLoader( this.manager );
<add> loader.setPath( this.path );
<ide> loader.load( url, function ( text ) {
<ide>
<ide> var json;
<ide> Object.assign( FontLoader.prototype, {
<ide>
<ide> return new Font( json );
<ide>
<add> },
<add>
<add> setPath: function ( value ) {
<add>
<add> this.path = value;
<add> return this;
<add>
<ide> }
<ide>
<ide> } ); | 1 |
Javascript | Javascript | fix racey-ness in tls-inception | e1bf6709dc720fa06359ccd745d81cafc37dbd39 | <ide><path>test/parallel/test-tls-inception.js
<ide> a = tls.createServer(options, function (socket) {
<ide> var dest = net.connect(options);
<ide> dest.pipe(socket);
<ide> socket.pipe(dest);
<add>
<add> dest.on('close', function() {
<add> socket.destroy();
<add> });
<ide> });
<ide>
<ide> // the "target" server | 1 |
Ruby | Ruby | pull the port out of the options hash once | a64914de4c41473c4bfecec1c69cfc931ccb6281 | <ide><path>actionpack/lib/action_dispatch/http/url.rb
<ide> def add_trailing_slash(path)
<ide> def build_host_url(options)
<ide> protocol = options[:protocol]
<ide> host = options[:host]
<add> port = options[:port]
<ide> if match = host.match(HOST_REGEXP)
<ide> protocol ||= match[1] unless protocol == false
<ide> host = match[2]
<del> options[:port] = match[3] unless options.key?(:port)
<add> port = match[3] unless options.key? :port
<ide> end
<ide>
<ide> protocol = normalize_protocol protocol
<ide> def build_host_url(options)
<ide> end
<ide>
<ide> result << host
<del> normalize_port(options[:port], protocol) { |port|
<add> normalize_port(port, protocol) { |port|
<ide> result << ":#{port}"
<ide> }
<ide> | 1 |
PHP | PHP | fix coding style | 8b578b8ca1444653f01b415edbe43f5cb579a9aa | <ide><path>src/Illuminate/Database/DetectsLostConnections.php
<ide> protected function causedByLostConnection(Exception $e)
<ide> 'SSL connection has been closed unexpectedly',
<ide> 'Deadlock found when trying to get lock',
<ide> 'Error writing data to the connection',
<del> 'Resource deadlock avoided'
<add> 'Resource deadlock avoided',
<ide> ]);
<ide> }
<ide> } | 1 |
PHP | PHP | remove unused class from test | 4a4a6f6a79fdb3a29445dd8b0614f59bdd1e833c | <ide><path>tests/Foundation/FoundationExceptionsHandlerTest.php
<ide> use Mockery as m;
<ide> use PHPUnit\Framework\TestCase;
<ide> use Illuminate\Container\Container;
<del>use Illuminate\Foundation\Application;
<ide> use Illuminate\Config\Repository as Config;
<ide> use Illuminate\Foundation\Exceptions\Handler;
<ide>
<ide> public function testReturnsJsonWithoutStackTraceWhenAjaxRequestAndDebugFalse()
<ide> $this->assertNotContains('"line"', $response);
<ide> $this->assertNotContains('"trace"', $response);
<ide> }
<del>
<ide> } | 1 |
Text | Text | use the javascript console to check the value... | 9d09a129063466d5e77be6d76f1e0582d96dd9e5 | <ide><path>guide/english/certifications/javascript-algorithms-and-data-structures/debugging/use-the-javascript-console-to-check-the-value-of-a-variable/index.md
<ide> title: Use the JavaScript Console to Check the Value of a Variable
<ide> ---
<ide> ## Use the JavaScript Console to Check the Value of a Variable
<ide>
<del>This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/debugging/use-the-javascript-console-to-check-the-value-of-a-variable/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<add>### Solution
<ide>
<del><a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<add>```js
<add>let a = 5;
<add>let b = 1;
<add>a++;
<add>// Add your code below this line
<ide>
<del><!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
<add>let sumAB = a + b;
<add>console.log(sumAB);
<add>
<add>console.log(a);
<add>``` | 1 |
Javascript | Javascript | fix arguments order in assertions | 6eda924c189e44a36fc97a7cfae41b69483d5bfb | <ide><path>test/parallel/test-process-env.js
<ide> const assert = require('assert');
<ide>
<ide> // changes in environment should be visible to child processes
<ide> if (process.argv[2] === 'you-are-the-child') {
<del> assert.strictEqual(false, 'NODE_PROCESS_ENV_DELETED' in process.env);
<del> assert.strictEqual('42', process.env.NODE_PROCESS_ENV);
<del> assert.strictEqual('asdf', process.env.hasOwnProperty);
<add> assert.strictEqual('NODE_PROCESS_ENV_DELETED' in process.env, false);
<add> assert.strictEqual(process.env.NODE_PROCESS_ENV, '42');
<add> assert.strictEqual(process.env.hasOwnProperty, 'asdf');
<ide> const hasOwnProperty = Object.prototype.hasOwnProperty;
<ide> const has = hasOwnProperty.call(process.env, 'hasOwnProperty');
<del> assert.strictEqual(true, has);
<add> assert.strictEqual(has, true);
<ide> process.exit(0);
<ide> }
<ide>
<ide> if (process.argv[2] === 'you-are-the-child') {
<ide> assert.strictEqual(Object.prototype.hasOwnProperty,
<ide> process.env.hasOwnProperty);
<ide> const has = process.env.hasOwnProperty('hasOwnProperty');
<del> assert.strictEqual(false, has);
<add> assert.strictEqual(has, false);
<ide>
<ide> process.env.hasOwnProperty = 'asdf';
<ide>
<ide> process.env.NODE_PROCESS_ENV = 42;
<del> assert.strictEqual('42', process.env.NODE_PROCESS_ENV);
<add> assert.strictEqual(process.env.NODE_PROCESS_ENV, '42');
<ide>
<ide> process.env.NODE_PROCESS_ENV_DELETED = 42;
<del> assert.strictEqual(true, 'NODE_PROCESS_ENV_DELETED' in process.env);
<add> assert.strictEqual('NODE_PROCESS_ENV_DELETED' in process.env, true);
<ide>
<ide> delete process.env.NODE_PROCESS_ENV_DELETED;
<del> assert.strictEqual(false, 'NODE_PROCESS_ENV_DELETED' in process.env);
<add> assert.strictEqual('NODE_PROCESS_ENV_DELETED' in process.env, false);
<ide>
<ide> const child = spawn(process.argv[0], [process.argv[1], 'you-are-the-child']);
<ide> child.stdout.on('data', function(data) { console.log(data.toString()); }); | 1 |
PHP | PHP | add class_alias for old cake\utility\number | bef6bb76657c6dc09623cbd4ded8294b5d9d229f | <ide><path>config/bootstrap.php
<ide> class_alias('Cake\Network\Exception\UnauthorizedException', 'Cake\Error\Unauthor
<ide> class_alias('Cake\Filesystem\File', 'Cake\Utility\File');
<ide> class_alias('Cake\Filesystem\Folder', 'Cake\Utility\Folder');
<ide> class_alias('Cake\I18n\Time', 'Cake\Utility\Time');
<add>class_alias('Cake\I18n\Number', 'Cake\Utility\Number');
<ide>
<ide> require CAKE . 'basics.php'; | 1 |
Ruby | Ruby | add suffix for bottles to avoid cache confusion | 1efd33cac090936616e9873ae58ae540d0581517 | <ide><path>Library/Contributions/examples/brew-bottle.rb
<ide> # Get the latest version
<ide> version = `brew list --versions #{formula}`.split.last
<ide> source = HOMEBREW_CELLAR + formula + version
<del> filename = formula + '-' + version + '.tar.gz'
<add> filename = formula + '-' + version + '-bottle.tar.gz'
<ide> ohai "Bottling #{formula} #{version}..."
<ide> HOMEBREW_CELLAR.cd do
<ide> # Use gzip, faster to compress than bzip2, faster to uncompress than bzip2 | 1 |
Python | Python | fix attributeerror in numpy/distutils | 9b59edebeadddf8012459e401434353b2de8babb | <ide><path>numpy/distutils/ccompiler.py
<ide> def CCompiler_customize(self, dist, need_cxx=0):
<ide> a, b = 'cc', 'c++'
<ide> self.compiler_cxx = [self.compiler[0].replace(a, b)]\
<ide> + self.compiler[1:]
<del> elif not self.compiler_cxx:
<add> else:
<ide> if hasattr(self, 'compiler'):
<ide> log.warn("#### %s #######" % (self.compiler,))
<del> log.warn('Missing compiler_cxx fix for '+self.__class__.__name__)
<add> if not hasattr(self, 'compiler_cxx'):
<add> log.warn('Missing compiler_cxx fix for ' + self.__class__.__name__)
<ide> return
<ide>
<ide> replace_method(CCompiler, 'customize', CCompiler_customize) | 1 |
Python | Python | apply lxml elementtree import pattern properly | 1588cc738ce472c329f1bba81bdef5ca977e9d64 | <ide><path>libcloud/storage/drivers/azure_blobs.py
<ide> import os
<ide> import binascii
<ide>
<del>from xml.etree.ElementTree import Element, SubElement
<add>try:
<add> from lxml import etree as ET
<add>except ImportError:
<add> from xml.etree import ElementTree as ET
<ide>
<ide> from libcloud.utils.py3 import PY3
<ide> from libcloud.utils.py3 import httplib
<ide> def _commit_blocks(self, object_path, chunks, lease):
<ide> :type upload_id: ``list``
<ide> """
<ide>
<del> root = Element('BlockList')
<add> root = ET.Element('BlockList')
<ide>
<ide> for block_id in chunks:
<del> part = SubElement(root, 'Uncommitted')
<add> part = ET.SubElement(root, 'Uncommitted')
<ide> part.text = str(block_id)
<ide>
<ide> data = tostring(root) | 1 |
Javascript | Javascript | add mustcall to test-net-eaddrinuse test | a4fff9a72f036a5e5dfa88757d1dd0796e1e2dad | <ide><path>test/parallel/test-net-eaddrinuse.js
<ide> // USE OR OTHER DEALINGS IN THE SOFTWARE.
<ide>
<ide> 'use strict';
<del>require('../common');
<add>const common = require('../common');
<ide> const assert = require('assert');
<ide> const net = require('net');
<ide>
<ide> const server1 = net.createServer(function(socket) {
<ide> });
<ide> const server2 = net.createServer(function(socket) {
<ide> });
<del>server1.listen(0, function() {
<add>server1.listen(0, common.mustCall(function() {
<ide> server2.on('error', function(error) {
<ide> assert.strictEqual(error.message.includes('EADDRINUSE'), true);
<ide> server1.close();
<ide> });
<ide> server2.listen(this.address().port);
<del>});
<add>})); | 1 |
Ruby | Ruby | add tests to | e5e42a3687801a1dc1c3e36ea784a7a1479a9230 | <ide><path>actionview/test/template/asset_tag_helper_test.rb
<ide> def test_image_alt
<ide> [nil, '/', '/foo/bar/', 'foo/bar/'].each do |prefix|
<ide> assert_equal 'Rails', image_alt("#{prefix}rails.png")
<ide> assert_equal 'Rails', image_alt("#{prefix}rails-9c0a079bdd7701d7e729bd956823d153.png")
<add> assert_equal 'Rails', image_alt("#{prefix}rails-f56ef62bc41b040664e801a38f068082a75d506d9048307e8096737463503d0b.png")
<ide> assert_equal 'Long file name with hyphens', image_alt("#{prefix}long-file-name-with-hyphens.png")
<ide> assert_equal 'Long file name with underscores', image_alt("#{prefix}long_file_name_with_underscores.png")
<ide> end | 1 |
PHP | PHP | fix invalid method calls | 45b5031b8e3428362b2b9ea74b7b1ba5bfd942cc | <ide><path>src/Console/ConsoleInput.php
<ide> public function read()
<ide> public function dataAvailable($timeout = 0)
<ide> {
<ide> $readFds = [$this->_input];
<del> $readyFds = stream_select($readFds, null, null, $timeout);
<add> $writeFds = null;
<add> $errorFds = null;
<add> $readyFds = stream_select($readFds, $writeFds, $errorFds, $timeout);
<ide>
<ide> return ($readyFds > 0);
<ide> } | 1 |
Python | Python | add a py3k version of pyod | 54d51ba9375a62a504bac2d560358e07e5f8d078 | <ide><path>numpy/core/setup_common.py
<ide> def pyod(filename):
<ide> We only implement enough to get the necessary information for long double
<ide> representation, this is not intended as a compatible replacement for od.
<ide> """
<del> out = []
<del>
<del> fid = open(filename, 'r')
<del> try:
<del> yo = [int(oct(int(binascii.b2a_hex(o), 16))) for o in fid.read()]
<del> for i in range(0, len(yo), 16):
<del> line = ['%07d' % int(oct(i))]
<del> line.extend(['%03d' % c for c in yo[i:i+16]])
<del> out.append(" ".join(line))
<del> return out
<del> finally:
<del> fid.close()
<add> def _pyod2():
<add> out = []
<add>
<add> fid = open(filename, 'r')
<add> try:
<add> yo = [int(oct(int(binascii.b2a_hex(o), 16))) for o in fid.read()]
<add> for i in range(0, len(yo), 16):
<add> line = ['%07d' % int(oct(i))]
<add> line.extend(['%03d' % c for c in yo[i:i+16]])
<add> out.append(" ".join(line))
<add> return out
<add> finally:
<add> fid.close()
<add>
<add> def _pyod3():
<add> out = []
<add>
<add> fid = open(filename, 'rb')
<add> try:
<add> yo2 = [oct(o)[2:] for o in fid.read()]
<add> for i in range(0, len(yo2), 16):
<add> line = ['%07d' % int(oct(i)[2:])]
<add> line.extend(['%03d' % int(c) for c in yo2[i:i+16]])
<add> out.append(" ".join(line))
<add> return out
<add> finally:
<add> fid.close()
<add>
<add> if sys.version_info[0] < 3:
<add> return _pyod2()
<add> else:
<add> return _pyod3()
<ide>
<ide> _BEFORE_SEQ = ['000','000','000','000','000','000','000','000',
<ide> '001','043','105','147','211','253','315','357'] | 1 |
Ruby | Ruby | fix the doc for `strict_loading!` [ci skip] | ab06682534f63257f33ad81e4c87931e36658cb7 | <ide><path>activerecord/lib/active_record/core.rb
<ide> def strict_loading?
<ide> # Sets the record to strict_loading mode. This will raise an error
<ide> # if the record tries to lazily load an association.
<ide> #
<del> # user = User.first.strict_loading!
<add> # user = User.first
<add> # user.strict_loading!
<ide> # user.comments.to_a
<ide> # => ActiveRecord::StrictLoadingViolationError
<ide> def strict_loading! | 1 |
PHP | PHP | remove a "feature" | 6877cb78b5f7c66a714826b3ea09dadef09d4c93 | <ide><path>src/Illuminate/Database/Eloquent/Model.php
<ide> public function load($relations)
<ide> {
<ide> if (is_string($relations)) $relations = func_get_args();
<ide>
<del> $query = $this->newQuery()->wi@th($relations);
<add> $query = $this->newQuery()->with($relations);
<ide>
<ide> $query->eagerLoadRelations(array($this));
<ide> } | 1 |
PHP | PHP | use config for verification expiry time | df153ce876e644c74357dd1310dedd983dc40446 | <ide><path>src/Illuminate/Auth/Notifications/VerifyEmail.php
<ide> public function toMail($notifiable)
<ide> protected function verificationUrl($notifiable)
<ide> {
<ide> return URL::temporarySignedRoute(
<del> 'verification.verify', Carbon::now()->addMinutes(60), ['id' => $notifiable->getKey()]
<add> 'verification.verify', Carbon::now()->addMinutes(config('auth.verification.expire', 60)), ['id' => $notifiable->getKey()]
<ide> );
<ide> }
<ide> | 1 |
Text | Text | update the call for contributions section | a7621b15bfa86bb7476684980b44c60aee2dd9c4 | <ide><path>README.md
<ide> Tests can then be run after installation with:
<ide> Call for Contributions
<ide> ----------------------
<ide>
<del>NumPy appreciates help from a wide range of different backgrounds.
<del>Work such as high level documentation or website improvements are valuable
<del>and we would like to grow our team with people filling these roles.
<del>Small improvements or fixes are always appreciated and issues labeled as easy
<del>may be a good starting point.
<del>If you are considering larger contributions outside the traditional coding work,
<del>please contact us through the mailing list.
<add>The NumPy project welcomes your expertise and enthusiasm!
<add>
<add>Small improvements or fixes are always appreciated. (Issues labeled as easy may be a good starting point.) If you are considering larger contributions to the source code, please contact us through the [mailing list](https://mail.python.org/mailman/listinfo/numpy-discussion) first.
<add>
<add>Writing code isn’t the only way to contribute to NumPy. You can also:
<add>- review pull requests
<add>- triage issues
<add>- develop tutorials, presentations, and other educational materials
<add>- maintain and improve our website numpy.org
<add>- develop graphic design for our brand assets and promotional materials
<add>- translate website content
<add>- serve as a community coordinator
<add>- write grant proposals and help with other fundraising efforts
<add>
<add>If you’re unsure where to start or how your skills fit in, reach out! You can ask on the mailing list or here, on GitHub, by opening a new issue or leaving a comment on a relevant issue that is already open.
<add>
<add>Those are our preferred channels (open source is open by nature), but if you’d like to speak to us in private first, contact our community coordinators at [email protected] or on Slack (write [email protected] for an invite).
<add>
<add>We also have a biweekly community call, details of which are announced on the mailing list. You are very welcome to join.
<add>
<add>If you are new to contributing to open source, we highly recommend reading [this guide](https://opensource.guide/how-to-contribute/).
<add>
<ide>
<ide>
<ide> [](https://numfocus.org) | 1 |
Javascript | Javascript | add basic middleware api to default dispatcher | 9109b5fef099111f9886842f9a175c30b638c06a | <ide><path>examples/components/Counter.js
<ide> export default class Counter {
<ide> };
<ide>
<ide> render() {
<del> const { increment, decrement, counter } = this.props;
<add> const { increment, incrementIfOdd, decrement, counter } = this.props;
<ide> return (
<ide> <p>
<ide> Clicked: {counter} times
<ide> {' '}
<ide> <button onClick={increment}>+</button>
<ide> {' '}
<ide> <button onClick={decrement}>-</button>
<add> {' '}
<add> <button onClick={incrementIfOdd}>Increment if odd</button>
<ide> </p>
<ide> );
<ide> }
<ide><path>src/Redux.js
<ide> export default class Redux {
<ide> constructor(dispatcher, initialState) {
<ide> if (typeof dispatcher === 'object') {
<ide> // A shortcut notation to use the default dispatcher
<del> dispatcher = createDispatcher(composeStores(dispatcher));
<add> dispatcher = createDispatcher(composeStores(dispatcher), initialState);
<ide> }
<ide>
<ide> this.state = initialState;
<ide><path>src/createDispatcher.js
<del>export default function createDispatcher(store) {
<add>export default function createDispatcher(store, middleware) {
<ide> return function dispatcher(initialState, setState) {
<ide> let state = store(initialState, {});
<ide> setState(state);
<ide>
<del> function dispatchSync(action) {
<add> function dispatch(action) {
<ide> state = store(state, action);
<ide> setState(state);
<ide> return action;
<ide> }
<ide>
<del> function dispatch(action) {
<del> return typeof action === 'function' ?
<del> action(dispatch, state) :
<del> dispatchSync(action);
<add> // Default middleware. It's special because it reads in the current state.
<add> // This is kept here to maintain existing API behavior.
<add> function perform(next) {
<add> return function recurse(action) {
<add> return typeof action === 'function' ?
<add> action(recurse, state) :
<add> next(action);
<add> };
<add> }
<add>
<add> if (typeof middleware === 'undefined') {
<add> middleware = perform;
<ide> }
<ide>
<del> return dispatch;
<add> return middleware(dispatch);
<ide> };
<ide> }
<ide><path>src/index.js
<ide> export provide from './components/provide';
<ide> export connect from './components/connect';
<ide>
<ide> // Utilities
<add>export compose from './utils/composeMiddleware';
<ide> export composeStores from './utils/composeStores';
<ide> export bindActionCreators from './utils/bindActionCreators';
<ide><path>src/utils/composeMiddleware.js
<add>export default function compose(...middlewares) {
<add> return middlewares.reduceRight((composed, m) => m(composed));
<add>} | 5 |
Go | Go | remove container dependency for links | fc952e0de94aa4283c677ce6c153b1a766db2fc0 | <ide><path>container.go
<ide> func (container *Container) Start() (err error) {
<ide> container.activeLinks = nil
<ide> }
<ide>
<del> for p, child := range children {
<del> link, err := NewLink(container, child, p, runtime.eng)
<add> for linkAlias, child := range children {
<add> if !child.State.IsRunning() {
<add> return fmt.Errorf("Cannot link to a non running container: %s AS %s", child.Name, linkAlias)
<add> }
<add>
<add> link, err := NewLink(
<add> container.NetworkSettings.IPAddress,
<add> child.NetworkSettings.IPAddress,
<add> linkAlias,
<add> child.Config.Env,
<add> child.Config.ExposedPorts,
<add> runtime.eng)
<add>
<ide> if err != nil {
<ide> rollback()
<ide> return err
<ide><path>links.go
<ide> type Link struct {
<ide> eng *engine.Engine
<ide> }
<ide>
<del>func NewLink(parent, child *Container, name string, eng *engine.Engine) (*Link, error) {
<del> if parent.ID == child.ID {
<del> return nil, fmt.Errorf("Cannot link to self: %s == %s", parent.ID, child.ID)
<del> }
<del> if !child.State.IsRunning() {
<del> return nil, fmt.Errorf("Cannot link to a non running container: %s AS %s", child.Name, name)
<del> }
<add>func NewLink(parentIP, childIP, name string, env []string, exposedPorts map[nat.Port]struct{}, eng *engine.Engine) (*Link, error) {
<add>
<add> var (
<add> i int
<add> ports = make([]nat.Port, len(exposedPorts))
<add> )
<ide>
<del> ports := make([]nat.Port, len(child.Config.ExposedPorts))
<del> var i int
<del> for p := range child.Config.ExposedPorts {
<add> for p := range exposedPorts {
<ide> ports[i] = p
<ide> i++
<ide> }
<ide>
<ide> l := &Link{
<ide> Name: name,
<del> ChildIP: child.NetworkSettings.IPAddress,
<del> ParentIP: parent.NetworkSettings.IPAddress,
<del> ChildEnvironment: child.Config.Env,
<add> ChildIP: childIP,
<add> ParentIP: parentIP,
<add> ChildEnvironment: env,
<ide> Ports: ports,
<ide> eng: eng,
<ide> }
<ide><path>links_test.go
<ide> package docker
<ide>
<ide> import (
<ide> "github.com/dotcloud/docker/nat"
<del> "github.com/dotcloud/docker/runconfig"
<ide> "strings"
<ide> "testing"
<ide> )
<ide>
<del>func newMockLinkContainer(id string, ip string) *Container {
<del> return &Container{
<del> Config: &runconfig.Config{},
<del> ID: id,
<del> NetworkSettings: &NetworkSettings{
<del> IPAddress: ip,
<del> },
<del> }
<del>}
<del>
<ide> func TestLinkNew(t *testing.T) {
<del> toID := GenerateID()
<del> fromID := GenerateID()
<del>
<del> from := newMockLinkContainer(fromID, "172.0.17.2")
<del> from.Config.Env = []string{}
<del> from.State = State{Running: true}
<ide> ports := make(nat.PortSet)
<del>
<ide> ports[nat.Port("6379/tcp")] = struct{}{}
<ide>
<del> from.Config.ExposedPorts = ports
<del>
<del> to := newMockLinkContainer(toID, "172.0.17.3")
<del>
<del> link, err := NewLink(to, from, "/db/docker", nil)
<add> link, err := NewLink("172.0.17.3", "172.0.17.2", "/db/docker", nil, ports, nil)
<ide> if err != nil {
<ide> t.Fatal(err)
<ide> }
<ide> func TestLinkNew(t *testing.T) {
<ide> }
<ide>
<ide> func TestLinkEnv(t *testing.T) {
<del> toID := GenerateID()
<del> fromID := GenerateID()
<del>
<del> from := newMockLinkContainer(fromID, "172.0.17.2")
<del> from.Config.Env = []string{"PASSWORD=gordon"}
<del> from.State = State{Running: true}
<ide> ports := make(nat.PortSet)
<del>
<ide> ports[nat.Port("6379/tcp")] = struct{}{}
<ide>
<del> from.Config.ExposedPorts = ports
<del>
<del> to := newMockLinkContainer(toID, "172.0.17.3")
<del>
<del> link, err := NewLink(to, from, "/db/docker", nil)
<add> link, err := NewLink("172.0.17.3", "172.0.17.2", "/db/docker", []string{"PASSWORD=gordon"}, ports, nil)
<ide> if err != nil {
<ide> t.Fatal(err)
<ide> } | 3 |
Text | Text | add hdf5 inputs to faq | 40e91020ddb96935e7ed8ea4881884235b4c7168 | <ide><path>docs/templates/getting-started/faq.md
<ide> - [How can I use stateful RNNs?](#how-can-i-use-stateful-rnns)
<ide> - [How can I remove a layer from a Sequential model?](#how-can-i-remove-a-layer-from-a-sequential-model)
<ide> - [How can I use pre-trained models in Keras?](#how-can-i-use-pre-trained-models-in-keras)
<add>- [How can I use HDF5 inputs with Keras?](#how-can-i-use-hdf5-inputs-with-keras)
<ide>
<ide> ---
<ide>
<ide> The VGG16 model is also the basis for several Keras example scripts:
<ide> - [Style transfer](https://github.com/fchollet/keras/blob/master/examples/neural_style_transfer.py)
<ide> - [Feature visualization](https://github.com/fchollet/keras/blob/master/examples/conv_filter_visualization.py)
<ide> - [Deep dream](https://github.com/fchollet/keras/blob/master/examples/deep_dream.py)
<add>
<add>---
<add>
<add>### How can I use HDF5 inputs with Keras?
<add>
<add>You can use the `HDF5Matrix` class from `keras.utils.io_utils`. See [the documentation](/io_utils/#HDF5Matrix) for details.
<add>
<add>You can also directly use a HDF5 dataset:
<add>
<add>```python
<add>import h5py
<add>with h5py.File('input/file.hdf5', 'r') as f:
<add> X_data = f['X_data']
<add> model.predict(X_data)
<add>``` | 1 |
Ruby | Ruby | preserve existing metadata when analyzing a blob | 704a7e425ca99af1b778c764a86e5388647631dd | <ide><path>activestorage/app/models/active_storage/blob.rb
<ide> def download(&block)
<ide> # You won't ordinarily need to call this method from a Rails application. New blobs are automatically and asynchronously
<ide> # analyzed via #analyze_later when they're attached for the first time.
<ide> def analyze
<del> update! metadata: extract_metadata_via_analyzer
<add> update! metadata: metadata.merge(extract_metadata_via_analyzer)
<ide> end
<ide>
<ide> # Enqueues an ActiveStorage::AnalyzeJob which calls #analyze.
<ide><path>activestorage/test/models/attachments_test.rb
<ide> class ActiveStorage::AttachmentsTest < ActiveSupport::TestCase
<ide> end
<ide> end
<ide>
<add> test "preserve existing metadata when analyzing a newly-attached blob" do
<add> blob = create_file_blob(metadata: { foo: "bar" })
<add>
<add> perform_enqueued_jobs do
<add> @user.avatar.attach blob
<add> end
<add>
<add> assert_equal "bar", blob.reload.metadata[:foo]
<add> end
<add>
<ide> test "purge attached blob" do
<ide> @user.avatar.attach create_blob(filename: "funky.jpg")
<ide> avatar_key = @user.avatar.key
<ide> class ActiveStorage::AttachmentsTest < ActiveSupport::TestCase
<ide> end
<ide> end
<ide>
<add> test "preserve existing metadata when analyzing newly-attached blobs" do
<add> blobs = [
<add> create_file_blob(filename: "racecar.jpg", content_type: "image/jpeg", metadata: { foo: "bar" }),
<add> create_file_blob(filename: "video.mp4", content_type: "video/mp4", metadata: { foo: "bar" })
<add> ]
<add>
<add> perform_enqueued_jobs do
<add> @user.highlights.attach(blobs)
<add> end
<add>
<add> blobs.each do |blob|
<add> assert_equal "bar", blob.reload.metadata[:foo]
<add> end
<add> end
<add>
<ide> test "purge attached blobs" do
<ide> @user.highlights.attach create_blob(filename: "funky.jpg"), create_blob(filename: "wonky.jpg")
<ide> highlight_keys = @user.highlights.collect(&:key)
<ide><path>activestorage/test/test_helper.rb
<ide> def create_blob(data: "Hello world!", filename: "hello.txt", content_type: "text
<ide> ActiveStorage::Blob.create_after_upload! io: StringIO.new(data), filename: filename, content_type: content_type
<ide> end
<ide>
<del> def create_file_blob(filename: "racecar.jpg", content_type: "image/jpeg")
<del> ActiveStorage::Blob.create_after_upload! io: file_fixture(filename).open, filename: filename, content_type: content_type
<add> def create_file_blob(filename: "racecar.jpg", content_type: "image/jpeg", metadata: nil)
<add> ActiveStorage::Blob.create_after_upload! io: file_fixture(filename).open, filename: filename, content_type: content_type, metadata: metadata
<ide> end
<ide>
<ide> def create_blob_before_direct_upload(filename: "hello.txt", byte_size:, checksum:, content_type: "text/plain") | 3 |
PHP | PHP | add runtime for seeders | b648c2e8377023c8fbe89c8068fe20364dc580a3 | <ide><path>src/Illuminate/Database/Seeder.php
<ide> public function call($class, $silent = false)
<ide>
<ide> foreach ($classes as $class) {
<ide> $seeder = $this->resolve($class);
<add> $name = get_class($seeder);
<ide>
<ide> if ($silent === false && isset($this->command)) {
<del> $this->command->getOutput()->writeln('<info>Seeding:</info> '.get_class($seeder));
<add> $this->command->getOutput()->writeln("<comment>Seeding:</comment> {$name}");
<ide> }
<ide>
<add> $startTime = microtime(true);
<add>
<ide> $seeder->__invoke();
<add>
<add> $runTime = round(microtime(true) - $startTime, 2);
<add>
<add> if ($silent === false && isset($this->command)) {
<add> $this->command->getOutput()->writeln("<info>Seeded:</info> {$name} ({$runTime} seconds)");
<add> }
<ide> }
<ide>
<ide> return $this;
<ide><path>tests/Database/DatabaseSeederTest.php
<ide> public function testCallResolveTheClassAndCallsRun()
<ide> $seeder = new TestSeeder;
<ide> $seeder->setContainer($container = m::mock(Container::class));
<ide> $output = m::mock(OutputInterface::class);
<del> $output->shouldReceive('writeln')->once()->andReturn('foo');
<add> $output->shouldReceive('writeln')->once();
<ide> $command = m::mock(Command::class);
<ide> $command->shouldReceive('getOutput')->once()->andReturn($output);
<ide> $seeder->setCommand($command);
<ide> $container->shouldReceive('make')->once()->with('ClassName')->andReturn($child = m::mock(Seeder::class));
<ide> $child->shouldReceive('setContainer')->once()->with($container)->andReturn($child);
<ide> $child->shouldReceive('setCommand')->once()->with($command)->andReturn($child);
<ide> $child->shouldReceive('__invoke')->once();
<add> $command->shouldReceive('getOutput')->once()->andReturn($output);
<add> $output->shouldReceive('writeln')->once();
<ide>
<ide> $seeder->call('ClassName');
<ide> } | 2 |
Javascript | Javascript | fix caching crash in concatenatedmodule | 38c7cf2d85ef21cbcf0b35d9833f0555df80aa01 | <ide><path>lib/InvalidDependenciesModuleWarning.js
<ide> "use strict";
<ide>
<ide> const WebpackError = require("./WebpackError");
<add>const makeSerializable = require("./util/makeSerializable");
<ide>
<ide> /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
<ide> /** @typedef {import("./Module")} Module */
<ide>
<del>module.exports = class InvalidDependenciesModuleWarning extends WebpackError {
<add>class InvalidDependenciesModuleWarning extends WebpackError {
<ide> /**
<ide> * @param {Module} module module tied to dependency
<ide> * @param {Iterable<string>} deps invalid dependencies
<ide> */
<ide> constructor(module, deps) {
<del> const orderedDeps = Array.from(deps).sort();
<add> const orderedDeps = deps ? Array.from(deps).sort() : [];
<ide> const depsList = orderedDeps.map(dep => ` * ${JSON.stringify(dep)}`);
<ide> super(`Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
<ide> Invalid dependencies may lead to broken watching and caching.
<ide> ${depsList.slice(0, 3).join("\n")}${
<ide>
<ide> Error.captureStackTrace(this, this.constructor);
<ide> }
<del>};
<add>}
<add>
<add>makeSerializable(
<add> InvalidDependenciesModuleWarning,
<add> "webpack/lib/InvalidDependenciesModuleWarning"
<add>);
<add>
<add>module.exports = InvalidDependenciesModuleWarning;
<ide><path>lib/Module.js
<ide> class Module extends DependenciesBlock {
<ide> */
<ide> updateCacheModule(module) {
<ide> this.type = module.type;
<add> this.layer = module.layer;
<ide> this.context = module.context;
<ide> this.factoryMeta = module.factoryMeta;
<ide> this.resolveOptions = module.resolveOptions;
<ide><path>lib/ModuleDependencyWarning.js
<ide> "use strict";
<ide>
<ide> const WebpackError = require("./WebpackError");
<add>const makeSerializable = require("./util/makeSerializable");
<ide>
<ide> /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
<ide> /** @typedef {import("./Module")} Module */
<ide>
<del>module.exports = class ModuleDependencyWarning extends WebpackError {
<add>class ModuleDependencyWarning extends WebpackError {
<ide> /**
<ide> * @param {Module} module module tied to dependency
<ide> * @param {Error} err error thrown
<ide> * @param {DependencyLocation} loc location of dependency
<ide> */
<ide> constructor(module, err, loc) {
<del> super(err.message);
<add> super(err ? err.message : "");
<ide>
<ide> this.name = "ModuleDependencyWarning";
<del> this.details = err.stack.split("\n").slice(1).join("\n");
<add> this.details = err && err.stack.split("\n").slice(1).join("\n");
<ide> this.module = module;
<ide> this.loc = loc;
<add> /** error is not (de)serialized, so it might be undefined after deserialization */
<ide> this.error = err;
<ide>
<ide> Error.captureStackTrace(this, this.constructor);
<ide> }
<del>};
<add>}
<add>
<add>makeSerializable(
<add> ModuleDependencyWarning,
<add> "webpack/lib/ModuleDependencyWarning"
<add>);
<add>
<add>module.exports = ModuleDependencyWarning;
<ide><path>lib/optimize/ConcatenatedModule.js
<ide> class ConcatenatedModule extends Module {
<ide> * @param {Set<Module>=} options.modules all concatenated modules
<ide> */
<ide> constructor({ identifier, rootModule, modules, runtime }) {
<del> super("javascript/esm", null, rootModule.layer);
<add> super("javascript/esm", null, rootModule && rootModule.layer);
<ide>
<ide> // Info from Factory
<ide> /** @type {string} */
<ide><path>lib/util/internalSerializables.js
<ide> module.exports = {
<ide> DllModule: () => require("../DllModule"),
<ide> ExternalModule: () => require("../ExternalModule"),
<ide> FileSystemInfo: () => require("../FileSystemInfo"),
<add> InvalidDependenciesModuleWarning: () =>
<add> require("../InvalidDependenciesModuleWarning"),
<ide> Module: () => require("../Module"),
<ide> ModuleBuildError: () => require("../ModuleBuildError"),
<add> ModuleDependencyWarning: () => require("../ModuleDependencyWarning"),
<ide> ModuleError: () => require("../ModuleError"),
<ide> ModuleGraph: () => require("../ModuleGraph"),
<ide> ModuleParseError: () => require("../ModuleParseError"),
<ide><path>test/BuildDependencies.test.js
<ide> const exec = (n, options = {}) => {
<ide> p.once("exit", code => {
<ide> const stdout = Buffer.concat(chunks).toString("utf-8");
<ide> if (code === 0) {
<add> if (!options.ignoreErrors && /<[ew]>/.test(stdout))
<add> return reject(stdout);
<add> console.log(stdout);
<ide> resolve(stdout);
<ide> } else {
<ide> reject(new Error(`Code ${code}: ${stdout}`));
<ide> describe("BuildDependencies", () => {
<ide> path.resolve(inputDirectory, "config-dependency.js"),
<ide> "module.exports = 0;"
<ide> );
<del> await exec("0", { invalidBuildDepdencies: true, buildTwice: true });
<add> await exec("0", {
<add> invalidBuildDepdencies: true,
<add> buildTwice: true,
<add> ignoreErrors: true
<add> });
<ide> fs.writeFileSync(
<ide> path.resolve(inputDirectory, "loader-dependency.js"),
<ide> "module.exports = 1;"
<ide><path>test/ConfigTestCases.template.js
<ide> const deprecationTracking = require("./helpers/deprecationTracking");
<ide> const FakeDocument = require("./helpers/FakeDocument");
<ide> const CurrentScript = require("./helpers/CurrentScript");
<ide>
<del>const webpack = require("..");
<ide> const prepareOptions = require("./helpers/prepareOptions");
<ide> const { parseResource } = require("../lib/util/identifier");
<add>const captureStdio = require("./helpers/captureStdio");
<add>
<add>let webpack;
<ide>
<ide> const casesPath = path.join(__dirname, "configCases");
<ide> const categories = fs.readdirSync(casesPath).map(cat => {
<ide> const categories = fs.readdirSync(casesPath).map(cat => {
<ide>
<ide> const describeCases = config => {
<ide> describe(config.name, () => {
<add> let stderr;
<add> beforeEach(() => {
<add> stderr = captureStdio(process.stderr, true);
<add> webpack = require("..");
<add> });
<add> afterEach(() => {
<add> stderr.restore();
<add> });
<ide> jest.setTimeout(20000);
<ide>
<ide> for (const category of categories) {
<add> // eslint-disable-next-line no-loop-func
<ide> describe(category.name, () => {
<ide> for (const testName of category.tests) {
<add> // eslint-disable-next-line no-loop-func
<ide> describe(testName, function () {
<ide> const testDirectory = path.join(casesPath, category.name, testName);
<ide> const filterPath = path.join(testDirectory, "test.filter.js");
<ide> const describeCases = config => {
<ide> ) {
<ide> return;
<ide> }
<add> const infrastructureLogging = stderr.toString();
<add> if (infrastructureLogging) {
<add> done(
<add> new Error(
<add> "Errors/Warnings during build:\n" + infrastructureLogging
<add> )
<add> );
<add> }
<ide> if (
<ide> checkArrayExpectation(
<ide> testDirectory,
<ide><path>test/TestCases.template.js
<ide> const TerserPlugin = require("terser-webpack-plugin");
<ide> const checkArrayExpectation = require("./checkArrayExpectation");
<ide> const createLazyTestEnv = require("./helpers/createLazyTestEnv");
<ide> const deprecationTracking = require("./helpers/deprecationTracking");
<add>const captureStdio = require("./helpers/captureStdio");
<ide>
<del>const webpack = require("..");
<add>let webpack;
<ide>
<ide> const terserForTesting = new TerserPlugin({
<ide> parallel: false
<ide> categories = categories.map(cat => {
<ide>
<ide> const describeCases = config => {
<ide> describe(config.name, () => {
<add> let stderr;
<add> beforeEach(() => {
<add> stderr = captureStdio(process.stderr, true);
<add> webpack = require("..");
<add> });
<add> afterEach(() => {
<add> stderr.restore();
<add> });
<ide> categories.forEach(category => {
<ide> describe(category.name, function () {
<ide> jest.setTimeout(20000);
<ide> const describeCases = config => {
<ide> ) {
<ide> return;
<ide> }
<add> const infrastructureLogging = stderr.toString();
<add> if (infrastructureLogging) {
<add> done(
<add> new Error(
<add> "Errors/Warnings during build:\n" +
<add> infrastructureLogging
<add> )
<add> );
<add> }
<add>
<ide> expect(deprecations).toEqual(config.deprecations || []);
<ide>
<ide> Promise.resolve().then(done); | 8 |
Python | Python | fix typos in __repr__ | 9b6110e3519272b91f9d51ca58a09ba25fd4aa3a | <ide><path>libcloud/common/openstack_identity.py
<ide> def __init__(self, version, status, updated, url):
<ide>
<ide> def __repr__(self):
<ide> return (('<OpenStackIdentityVersion version=%s, status=%s, '
<del> 'updated=%s, url=%s' %
<add> 'updated=%s, url=%s>' %
<ide> (self.version, self.status, self.updated, self.url)))
<ide>
<ide>
<ide> def __init__(self, id, domain_id, name, email, description, enabled):
<ide>
<ide> def __repr__(self):
<ide> return (('<OpenStackIdentityUser id=%s, domain_id=%s, name=%s, '
<del> 'email=%s, enabled=%s' % (self.id, self.domain_id, self.name,
<del> self.email, self.enabled)))
<add> 'email=%s, enabled=%s>' % (self.id, self.domain_id, self.name,
<add> self.email, self.enabled)))
<ide>
<ide>
<ide> class OpenStackServiceCatalog(object): | 1 |
Text | Text | improve instructions in rothko-painting | 59f21b1d8ff14dc230de54d262847f7e91a979e9 | <ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-the-css-box-model-by-building-a-rothko-painting/step-012.md
<ide> dashedName: step-12
<ide>
<ide> Write a new rule using the `.frame` class selector.
<ide>
<del>Give the `.frame` a border with the shorthand `border: 50px solid black;` declaration.
<add>Use the `border` shorthand declaration to give the `.frame` element a solid, black border with a width of `50px`.
<ide>
<ide> # --hints--
<ide>
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-the-css-box-model-by-building-a-rothko-painting/step-014.md
<ide> dashedName: step-14
<ide>
<ide> Use padding to adjust the spacing within an element.
<ide>
<del>In `.frame`, use the shorthand `padding: 50px;` to increase the space between the top, bottom, left, and right of the frame's border and the canvas within.
<add>In `.frame`, use the `padding` shorthand property to increase the space between the `.frame` and `.canvas` elements by `50px`. The shorthand will increase space in the top, bottom, left, and right of the element's border and canvas within.
<ide>
<ide> # --hints--
<ide>
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-the-css-box-model-by-building-a-rothko-painting/step-015.md
<ide> dashedName: step-15
<ide>
<ide> Use margins to adjust the spacing outside of an element.
<ide>
<del>Add the `margin` property to `.frame` and set it to `20px auto` to move the frame down 20 pixels and center it horizontally on the page.
<add>Using the `margin` property, give the `.frame` element vertical margin of `20px`, and horizontal margin of `auto`. This will move the frame down 20 pixels and horizontally center it on the page.
<ide>
<ide> # --hints--
<ide>
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-the-css-box-model-by-building-a-rothko-painting/step-020.md
<ide> dashedName: step-20
<ide>
<ide> Use margins to position the `.one` element on the canvas.
<ide>
<del>Add the shorthand `margin: 20px auto;` to set the top and bottom margins to 20 pixels, and center it horizontally.
<add>Add the shorthand `margin` property with a vertical margin of `20px` and a horizontal margin of `auto`.
<ide>
<ide> # --hints--
<ide>
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-the-css-box-model-by-building-a-rothko-painting/step-021.md
<ide> dashedName: step-21
<ide>
<ide> Now `.one` is centered horizontally, but its top margin is pushing past the canvas and onto the frame's border, shifting the entire canvas down 20 pixels.
<ide>
<del>Add `padding: 1px;` to `.canvas` to give the `.one` element something solid to push off of.
<add>Add `padding` of `1px` to the `.canvas` element to give the `.one` element something solid to push off of.
<ide>
<ide> # --hints--
<ide>
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-the-css-box-model-by-building-a-rothko-painting/step-022.md
<ide> dashedName: step-22
<ide>
<ide> Adding 1 pixel of padding to the top, bottom, left, and right of the canvas changed its dimensions to 502 pixels x 602 pixels.
<ide>
<del>Replace `padding: 1px;` with `overflow: hidden;` to change the canvas back to its original dimensions.
<add>Replace the `padding` property with `overflow` set to `hidden` - changing the canvas back to its original dimensions.
<ide>
<ide> # --hints--
<ide>
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-the-css-box-model-by-building-a-rothko-painting/step-034.md
<ide> It's helpful to have your margins push in one direction.
<ide>
<ide> In this case, the bottom margin of the `.one` element pushes `.two` down 20 pixels.
<ide>
<del>In `.two`, add `margin: 0 auto 20px;` to set its top margin to 0, center it horizontally, and set its bottom margin to 20 pixels.
<add>In the `.two` selector, use `margin` shorthand property to set top margin to `0`, horizontal margin to `auto`, and bottom margin to `20px`. This will remove its top margin, horizontally center it, and set its bottom margin to 20 pixels.
<ide>
<ide> # --hints--
<ide>
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-the-css-box-model-by-building-a-rothko-painting/step-035.md
<ide> dashedName: step-35
<ide>
<ide> The colors and shapes of your painting are too sharp to pass as a Rothko.
<ide>
<del>Use the `filter` property with the value `blur(2px)` in the `.canvas` element.
<add>Use the `filter` property to `blur` the painting by `2px` in the `.canvas` element.
<ide>
<ide> # --hints--
<ide>
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-the-css-box-model-by-building-a-rothko-painting/step-041.md
<ide> dashedName: step-41
<ide>
<ide> The corners of each rectangle are still too sharp.
<ide>
<del>Round each corner of `.one` by 9 pixels with `border-radius: 9px;`.
<add>Round each corner of the `.one` element by 9 pixels, using the `border-radius` property.
<ide>
<ide> # --hints--
<ide>
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-the-css-box-model-by-building-a-rothko-painting/step-042.md
<ide> dashedName: step-42
<ide>
<ide> # --description--
<ide>
<del>Set the `border-radius` of `.two` to `8px 10px`. This will round its top-left and bottom-right corners by 8 pixels, and top-right and bottom-left corners by 10 pixels.
<add>Use the `border-radius` property on the `.two` selector, to set its top-left and bottom-right radii to `8px`, and top-right and bottom-left radii to `10px`.
<ide>
<ide> # --hints--
<ide>
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-the-css-box-model-by-building-a-rothko-painting/step-044.md
<ide> dashedName: step-44
<ide>
<ide> Rotate each rectangle to give them more of an imperfect, hand-painted look.
<ide>
<del>Use the following to rotate `.one` counter clockwise by 0.6 degrees: `transform: rotate(-0.6deg);`
<add>Use the `transform` property on the `.one` selector to `rotate` it counter clockwise by 0.6 degrees.
<ide>
<ide> # --hints--
<ide>
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-the-css-box-model-by-building-a-rothko-painting/step-045.md
<ide> dashedName: step-45
<ide>
<ide> # --description--
<ide>
<del>Rotate `.two` clockwise slightly by adding the `transform` property with the value `rotate(0.4deg)`.
<add>Rotate the `.two` element clockwise by 0.4 degrees.
<ide>
<ide> # --hints--
<ide> | 12 |
Text | Text | add article by ellen lupton | b51957033676a5c2c2d30cb1c30d289590aa34f9 | <ide><path>guide/english/typography/kerning-and-tracking/index.md
<ide> One should also consider the positive and negative ground when tracking and kern
<ide> #### More Information:
<ide> <!-- Please add any articles you think might be helpful to read before writing the article -->
<ide>
<add>- ["Thinking With Type" by Ellen Lupton](http://thinkingwithtype.com/text/)
<add>
<ide> | 1 |
PHP | PHP | fix cs for easier 3.x/4.x comparison/merge | 44a78128e7262959c5f8b6bc7dd7766b68822edf | <ide><path>config/config.php
<ide> */
<ide> $versionFile = file(CORE_PATH . 'VERSION.txt');
<ide> return [
<del> 'Cake.version' => trim(array_pop($versionFile))
<add> 'Cake.version' => trim(array_pop($versionFile)),
<ide> ];
<ide><path>src/Auth/BaseAuthenticate.php
<ide> abstract class BaseAuthenticate implements EventListenerInterface
<ide> protected $_defaultConfig = [
<ide> 'fields' => [
<ide> 'username' => 'username',
<del> 'password' => 'password'
<add> 'password' => 'password',
<ide> ],
<ide> 'userModel' => 'Users',
<ide> 'scope' => [],
<ide> 'finder' => 'all',
<ide> 'contain' => null,
<del> 'passwordHasher' => 'Default'
<add> 'passwordHasher' => 'Default',
<ide> ];
<ide>
<ide> /**
<ide> protected function _query($username)
<ide> $table = $this->getTableLocator()->get($config['userModel']);
<ide>
<ide> $options = [
<del> 'conditions' => [$table->aliasField($config['fields']['username']) => $username]
<add> 'conditions' => [$table->aliasField($config['fields']['username']) => $username],
<ide> ];
<ide>
<ide> if (!empty($config['scope'])) {
<ide><path>src/Auth/BasicAuthenticate.php
<ide> public function loginHeaders(ServerRequest $request)
<ide> $realm = $this->getConfig('realm') ?: $request->getEnv('SERVER_NAME');
<ide>
<ide> return [
<del> 'WWW-Authenticate' => sprintf('Basic realm="%s"', $realm)
<add> 'WWW-Authenticate' => sprintf('Basic realm="%s"', $realm),
<ide> ];
<ide> }
<ide> }
<ide><path>src/Auth/DefaultPasswordHasher.php
<ide> class DefaultPasswordHasher extends AbstractPasswordHasher
<ide> */
<ide> protected $_defaultConfig = [
<ide> 'hashType' => PASSWORD_DEFAULT,
<del> 'hashOptions' => []
<add> 'hashOptions' => [],
<ide> ];
<ide>
<ide> /**
<ide><path>src/Auth/DigestAuthenticate.php
<ide> public function loginHeaders(ServerRequest $request)
<ide> 'realm' => $realm,
<ide> 'qop' => $this->_config['qop'],
<ide> 'nonce' => $this->generateNonce(),
<del> 'opaque' => $this->_config['opaque'] ?: md5($realm)
<add> 'opaque' => $this->_config['opaque'] ?: md5($realm),
<ide> ];
<ide>
<ide> $digest = $this->_getDigest($request);
<ide> public function loginHeaders(ServerRequest $request)
<ide> }
<ide>
<ide> return [
<del> 'WWW-Authenticate' => 'Digest ' . implode(',', $opts)
<add> 'WWW-Authenticate' => 'Digest ' . implode(',', $opts),
<ide> ];
<ide> }
<ide>
<ide><path>src/Auth/FallbackPasswordHasher.php
<ide> class FallbackPasswordHasher extends AbstractPasswordHasher
<ide> * @var array
<ide> */
<ide> protected $_defaultConfig = [
<del> 'hashers' => []
<add> 'hashers' => [],
<ide> ];
<ide>
<ide> /**
<ide><path>src/Auth/Storage/SessionStorage.php
<ide> class SessionStorage implements StorageInterface
<ide> */
<ide> protected $_defaultConfig = [
<ide> 'key' => 'Auth.User',
<del> 'redirect' => 'Auth.redirect'
<add> 'redirect' => 'Auth.redirect',
<ide> ];
<ide>
<ide> /**
<ide><path>src/Auth/WeakPasswordHasher.php
<ide> class WeakPasswordHasher extends AbstractPasswordHasher
<ide> * @var array
<ide> */
<ide> protected $_defaultConfig = [
<del> 'hashType' => null
<add> 'hashType' => null,
<ide> ];
<ide>
<ide> /**
<ide><path>src/Cache/Engine/FileEngine.php
<ide> class FileEngine extends CacheEngine
<ide> 'path' => null,
<ide> 'prefix' => 'cake_',
<ide> 'probability' => 100,
<del> 'serialize' => true
<add> 'serialize' => true,
<ide> ];
<ide>
<ide> /**
<ide><path>src/Cache/Engine/MemcachedEngine.php
<ide> public function init(array $config = [])
<ide> $this->_serializers = [
<ide> 'igbinary' => Memcached::SERIALIZER_IGBINARY,
<ide> 'json' => Memcached::SERIALIZER_JSON,
<del> 'php' => Memcached::SERIALIZER_PHP
<add> 'php' => Memcached::SERIALIZER_PHP,
<ide> ];
<ide> if (defined('Memcached::HAVE_MSGPACK') && Memcached::HAVE_MSGPACK) {
<ide> $this->_serializers['msgpack'] = Memcached::SERIALIZER_MSGPACK;
<ide><path>src/Cache/Engine/XcacheEngine.php
<ide> class XcacheEngine extends CacheEngine
<ide> 'prefix' => null,
<ide> 'probability' => 100,
<ide> 'PHP_AUTH_USER' => 'user',
<del> 'PHP_AUTH_PW' => 'password'
<add> 'PHP_AUTH_PW' => 'password',
<ide> ];
<ide>
<ide> /**
<ide><path>src/Collection/CollectionTrait.php
<ide> public function combine($keyPath, $valuePath, $groupPath = null)
<ide> $options = [
<ide> 'keyPath' => $this->_propertyExtractor($keyPath),
<ide> 'valuePath' => $this->_propertyExtractor($valuePath),
<del> 'groupPath' => $groupPath ? $this->_propertyExtractor($groupPath) : null
<add> 'groupPath' => $groupPath ? $this->_propertyExtractor($groupPath) : null,
<ide> ];
<ide>
<ide> $mapper = function ($value, $key, $mapReduce) use ($options) {
<ide> public function listNested($dir = 'desc', $nestingKey = 'children')
<ide> $modes = [
<ide> 'desc' => TreeIterator::SELF_FIRST,
<ide> 'asc' => TreeIterator::CHILD_FIRST,
<del> 'leaves' => TreeIterator::LEAVES_ONLY
<add> 'leaves' => TreeIterator::LEAVES_ONLY,
<ide> ];
<ide>
<ide> return new TreeIterator(
<ide><path>src/Collection/Iterator/BufferedIterator.php
<ide> public function valid()
<ide> $this->_key = parent::key();
<ide> $this->_buffer->push([
<ide> 'key' => $this->_key,
<del> 'value' => $this->_current
<add> 'value' => $this->_current,
<ide> ]);
<ide> }
<ide>
<ide><path>src/Command/HelpCommand.php
<ide> protected function buildOptionParser(ConsoleOptionParser $parser)
<ide> 'Get the list of available commands for this application.'
<ide> )->addOption('xml', [
<ide> 'help' => 'Get the listing as XML.',
<del> 'boolean' => true
<add> 'boolean' => true,
<ide> ]);
<ide>
<ide> return $parser;
<ide><path>src/Console/CommandScanner.php
<ide> protected function scanDir($path, $namespace, $prefix, array $hide)
<ide> 'file' => $path . $file,
<ide> 'fullName' => $prefix . $name,
<ide> 'name' => $name,
<del> 'class' => $class
<add> 'class' => $class,
<ide> ];
<ide> }
<ide>
<ide><path>src/Console/ConsoleIo.php
<ide> public function setLoggers($enable)
<ide> if ($enable !== static::QUIET) {
<ide> $stdout = new ConsoleLog([
<ide> 'types' => $outLevels,
<del> 'stream' => $this->_out
<add> 'stream' => $this->_out,
<ide> ]);
<ide> Log::setConfig('stdout', ['engine' => $stdout]);
<ide> }
<ide><path>src/Console/ConsoleOptionParser.php
<ide> public function __construct($command = null, $defaultOptions = true)
<ide> $this->addOption('help', [
<ide> 'short' => 'h',
<ide> 'help' => 'Display this help.',
<del> 'boolean' => true
<add> 'boolean' => true,
<ide> ]);
<ide>
<ide> if ($defaultOptions) {
<ide> $this->addOption('verbose', [
<ide> 'short' => 'v',
<ide> 'help' => 'Enable verbose output.',
<del> 'boolean' => true
<add> 'boolean' => true,
<ide> ])->addOption('quiet', [
<ide> 'short' => 'q',
<ide> 'help' => 'Enable quiet output.',
<del> 'boolean' => true
<add> 'boolean' => true,
<ide> ]);
<ide> }
<ide> }
<ide> public function toArray()
<ide> 'options' => $this->_options,
<ide> 'subcommands' => $this->_subcommands,
<ide> 'description' => $this->_description,
<del> 'epilog' => $this->_epilog
<add> 'epilog' => $this->_epilog,
<ide> ];
<ide>
<ide> return $result;
<ide> public function addOption($name, array $options = [])
<ide> 'help' => '',
<ide> 'default' => null,
<ide> 'boolean' => false,
<del> 'choices' => []
<add> 'choices' => [],
<ide> ];
<ide> $options += $defaults;
<ide> $option = new ConsoleInputOption($options);
<ide> public function addArgument($name, array $params = [])
<ide> 'help' => '',
<ide> 'index' => count($this->_args),
<ide> 'required' => false,
<del> 'choices' => []
<add> 'choices' => [],
<ide> ];
<ide> $options = $params + $defaults;
<ide> $index = $options['index'];
<ide> public function addSubcommand($name, array $options = [])
<ide> $defaults = [
<ide> 'name' => $name,
<ide> 'help' => '',
<del> 'parser' => null
<add> 'parser' => null,
<ide> ];
<ide> $options += $defaults;
<ide>
<ide> protected function getCommandError($command)
<ide> $this->rootName,
<ide> $rootCommand
<ide> ),
<del> ''
<add> '',
<ide> ];
<ide>
<ide> if ($bestGuess !== null) {
<ide> protected function getOptionError($option)
<ide> $bestGuess = $this->findClosestItem($option, $availableOptions);
<ide> $out = [
<ide> sprintf('Unknown option `%s`.', $option),
<del> ''
<add> '',
<ide> ];
<ide>
<ide> if ($bestGuess !== null) {
<ide><path>src/Console/ConsoleOutput.php
<ide> class ConsoleOutput
<ide> 'blue' => 34,
<ide> 'magenta' => 35,
<ide> 'cyan' => 36,
<del> 'white' => 37
<add> 'white' => 37,
<ide> ];
<ide>
<ide> /**
<ide> class ConsoleOutput
<ide> 'blue' => 44,
<ide> 'magenta' => 45,
<ide> 'cyan' => 46,
<del> 'white' => 47
<add> 'white' => 47,
<ide> ];
<ide>
<ide> /**
<ide> class ConsoleOutput
<ide> 'success' => ['text' => 'green'],
<ide> 'comment' => ['text' => 'blue'],
<ide> 'question' => ['text' => 'magenta'],
<del> 'notice' => ['text' => 'cyan']
<add> 'notice' => ['text' => 'cyan'],
<ide> ];
<ide>
<ide> /**
<ide><path>src/Console/HelpFormatter.php
<ide> public function text($width = 72)
<ide> $out[] = Text::wrapBlock($command->help($max), [
<ide> 'width' => $width,
<ide> 'indent' => str_repeat(' ', $max),
<del> 'indentAt' => 1
<add> 'indentAt' => 1,
<ide> ]);
<ide> }
<ide> $out[] = '';
<ide> public function text($width = 72)
<ide> $out[] = Text::wrapBlock($option->help($max), [
<ide> 'width' => $width,
<ide> 'indent' => str_repeat(' ', $max),
<del> 'indentAt' => 1
<add> 'indentAt' => 1,
<ide> ]);
<ide> }
<ide> $out[] = '';
<ide> public function text($width = 72)
<ide> $out[] = Text::wrapBlock($argument->help($max), [
<ide> 'width' => $width,
<ide> 'indent' => str_repeat(' ', $max),
<del> 'indentAt' => 1
<add> 'indentAt' => 1,
<ide> ]);
<ide> }
<ide> $out[] = '';
<ide><path>src/Console/HelperRegistry.php
<ide> protected function _throwMissingClassError($class, $plugin)
<ide> {
<ide> throw new MissingHelperException([
<ide> 'class' => $class,
<del> 'plugin' => $plugin
<add> 'plugin' => $plugin,
<ide> ]);
<ide> }
<ide>
<ide><path>src/Console/TaskRegistry.php
<ide> protected function _throwMissingClassError($class, $plugin)
<ide> {
<ide> throw new MissingTaskException([
<ide> 'class' => $class,
<del> 'plugin' => $plugin
<add> 'plugin' => $plugin,
<ide> ]);
<ide> }
<ide>
<ide><path>src/Controller/Component/AuthComponent.php
<ide> class AuthComponent extends Component
<ide> 'authError' => null,
<ide> 'unauthorizedRedirect' => true,
<ide> 'storage' => 'Session',
<del> 'checkAuthIn' => 'Controller.startup'
<add> 'checkAuthIn' => 'Controller.startup',
<ide> ];
<ide>
<ide> /**
<ide> protected function _setDefaults()
<ide> 'flash' => [
<ide> 'element' => 'error',
<ide> 'key' => 'flash',
<del> 'params' => ['class' => 'error']
<add> 'params' => ['class' => 'error'],
<ide> ],
<ide> 'loginAction' => [
<ide> 'controller' => 'Users',
<ide> 'action' => 'login',
<del> 'plugin' => null
<add> 'plugin' => null,
<ide> ],
<ide> 'logoutRedirect' => $this->_config['loginAction'],
<del> 'authError' => __d('cake', 'You are not authorized to access that location.')
<add> 'authError' => __d('cake', 'You are not authorized to access that location.'),
<ide> ];
<ide>
<ide> $config = $this->getConfig();
<ide><path>src/Controller/Component/FlashComponent.php
<ide> class FlashComponent extends Component
<ide> 'element' => 'default',
<ide> 'params' => [],
<ide> 'clear' => false,
<del> 'duplicate' => true
<add> 'duplicate' => true,
<ide> ];
<ide>
<ide> /**
<ide> public function set($message, array $options = [])
<ide> 'message' => $message,
<ide> 'key' => $options['key'],
<ide> 'element' => $options['element'],
<del> 'params' => $options['params']
<add> 'params' => $options['params'],
<ide> ];
<ide>
<ide> $this->getSession()->write('Flash.' . $options['key'], $messages);
<ide><path>src/Controller/Component/PaginatorComponent.php
<ide> class PaginatorComponent extends Component
<ide> 'page' => 1,
<ide> 'limit' => 20,
<ide> 'maxLimit' => 100,
<del> 'whitelist' => ['limit', 'sort', 'page', 'direction']
<add> 'whitelist' => ['limit', 'sort', 'page', 'direction'],
<ide> ];
<ide>
<ide> /**
<ide><path>src/Controller/Component/RequestHandlerComponent.php
<ide> class RequestHandlerComponent extends Component
<ide> 'checkHttpCache' => true,
<ide> 'viewClassMap' => [],
<ide> 'inputTypeMap' => [],
<del> 'enableBeforeRedirect' => true
<add> 'enableBeforeRedirect' => true,
<ide> ];
<ide>
<ide> /**
<ide> public function __construct(ComponentRegistry $registry, array $config = [])
<ide> 'viewClassMap' => [
<ide> 'json' => 'Json',
<ide> 'xml' => 'Xml',
<del> 'ajax' => 'Ajax'
<add> 'ajax' => 'Ajax',
<ide> ],
<ide> 'inputTypeMap' => [
<ide> 'json' => ['json_decode', true],
<ide> 'xml' => [[$this, 'convertXml']],
<del> ]
<add> ],
<ide> ];
<ide> parent::__construct($registry, $config);
<ide> }
<ide> public function beforeRedirect(Event $event, $url, Response $response)
<ide> 'return',
<ide> 'bare' => false,
<ide> 'environment' => [
<del> 'REQUEST_METHOD' => 'GET'
<add> 'REQUEST_METHOD' => 'GET',
<ide> ],
<ide> 'query' => $query,
<del> 'cookies' => $request->getCookieParams()
<add> 'cookies' => $request->getCookieParams(),
<ide> ]));
<ide>
<ide> return $response->withStatus(200);
<ide><path>src/Controller/Component/SecurityComponent.php
<ide> class SecurityComponent extends Component
<ide> 'allowedActions' => [],
<ide> 'unlockedFields' => [],
<ide> 'unlockedActions' => [],
<del> 'validatePost' => true
<add> 'validatePost' => true,
<ide> ];
<ide>
<ide> /**
<ide> protected function _hashParts(Controller $controller)
<ide> Router::url($request->getRequestTarget()),
<ide> serialize($fieldList),
<ide> $unlocked,
<del> $session->id()
<add> $session->id(),
<ide> ];
<ide> }
<ide>
<ide> public function generateToken(ServerRequest $request)
<ide> $this->session->write('_Token', $token);
<ide>
<ide> return $request->withParam('_Token', [
<del> 'unlockedFields' => $token['unlockedFields']
<add> 'unlockedFields' => $token['unlockedFields'],
<ide> ]);
<ide> }
<ide>
<ide><path>src/Controller/ComponentRegistry.php
<ide> protected function _throwMissingClassError($class, $plugin)
<ide> {
<ide> throw new MissingComponentException([
<ide> 'class' => $class . 'Component',
<del> 'plugin' => $plugin
<add> 'plugin' => $plugin,
<ide> ]);
<ide> }
<ide>
<ide><path>src/Controller/Controller.php
<ide> class Controller implements EventListenerInterface, EventDispatcherInterface
<ide> * @deprecated 3.7.0 Use ViewBuilder::setOptions() or any one of it's setter methods instead.
<ide> */
<ide> protected $_validViewOptions = [
<del> 'passedArgs'
<add> 'passedArgs',
<ide> ];
<ide>
<ide> /**
<ide> public function __set($name, $value)
<ide> {
<ide> $deprecated = [
<ide> 'name' => 'setName',
<del> 'plugin' => 'setPlugin'
<add> 'plugin' => 'setPlugin',
<ide> ];
<ide> if (isset($deprecated[$name])) {
<ide> $method = $deprecated[$name];
<ide><path>src/Core/App.php
<ide> public static function shortName($class, $type, $suffix = '')
<ide>
<ide> $nonPluginNamespaces = [
<ide> 'Cake',
<del> str_replace('\\', '/', Configure::read('App.namespace'))
<add> str_replace('\\', '/', Configure::read('App.namespace')),
<ide> ];
<ide> if (in_array($pluginName, $nonPluginNamespaces)) {
<ide> return $name;
<ide><path>src/Core/Configure.php
<ide> class Configure
<ide> * @var array
<ide> */
<ide> protected static $_values = [
<del> 'debug' => false
<add> 'debug' => false,
<ide> ];
<ide>
<ide> /**
<ide><path>src/Core/Plugin.php
<ide> public static function load($plugin, array $config = [])
<ide> 'console' => true,
<ide> 'classBase' => 'src',
<ide> 'ignoreMissing' => false,
<del> 'name' => $plugin
<add> 'name' => $plugin,
<ide> ];
<ide>
<ide> if (!isset($config['path'])) {
<ide><path>src/Database/Connection.php
<ide> public function __debugInfo()
<ide> 'username' => '*****',
<ide> 'host' => '*****',
<ide> 'database' => '*****',
<del> 'port' => '*****'
<add> 'port' => '*****',
<ide> ];
<ide> $replace = array_intersect_key($secrets, $this->_config);
<ide> $config = $replace + $this->_config;
<ide> public function __debugInfo()
<ide> 'transactionStarted' => $this->_transactionStarted,
<ide> 'useSavePoints' => $this->_useSavePoints,
<ide> 'logQueries' => $this->_logQueries,
<del> 'logger' => $this->_logger
<add> 'logger' => $this->_logger,
<ide> ];
<ide> }
<ide> }
<ide><path>src/Database/Dialect/PostgresDialectTrait.php
<ide> protected function _expressionTranslators()
<ide> $namespace = 'Cake\Database\Expression';
<ide>
<ide> return [
<del> $namespace . '\FunctionExpression' => '_transformFunctionExpression'
<add> $namespace . '\FunctionExpression' => '_transformFunctionExpression',
<ide> ];
<ide> }
<ide>
<ide><path>src/Database/Dialect/SqliteDialectTrait.php
<ide> trait SqliteDialectTrait
<ide> 'minute' => 'M',
<ide> 'second' => 'S',
<ide> 'week' => 'W',
<del> 'year' => 'Y'
<add> 'year' => 'Y',
<ide> ];
<ide>
<ide> /**
<ide> protected function _expressionTranslators()
<ide>
<ide> return [
<ide> $namespace . '\FunctionExpression' => '_transformFunctionExpression',
<del> $namespace . '\TupleComparison' => '_transformTupleComparison'
<add> $namespace . '\TupleComparison' => '_transformTupleComparison',
<ide> ];
<ide> }
<ide>
<ide><path>src/Database/Dialect/SqlserverDialectTrait.php
<ide> protected function _pagingSubquery($original, $limit, $offset)
<ide>
<ide> $query = clone $original;
<ide> $query->select([
<del> '_cake_page_rownum_' => new UnaryExpression('ROW_NUMBER() OVER', $order)
<add> '_cake_page_rownum_' => new UnaryExpression('ROW_NUMBER() OVER', $order),
<ide> ])->limit(null)
<ide> ->offset(null)
<ide> ->order([], true);
<ide> protected function _transformDistinct($original)
<ide> ->setConjunction(' ');
<ide>
<ide> return [
<del> '_cake_distinct_pivot_' => $over
<add> '_cake_distinct_pivot_' => $over,
<ide> ];
<ide> })
<ide> ->limit(null)
<ide> protected function _expressionTranslators()
<ide>
<ide> return [
<ide> $namespace . '\FunctionExpression' => '_transformFunctionExpression',
<del> $namespace . '\TupleComparison' => '_transformTupleComparison'
<add> $namespace . '\TupleComparison' => '_transformTupleComparison',
<ide> ];
<ide> }
<ide>
<ide><path>src/Database/Driver.php
<ide> public function __destruct()
<ide> public function __debugInfo()
<ide> {
<ide> return [
<del> 'connected' => $this->_connection !== null
<add> 'connected' => $this->_connection !== null,
<ide> ];
<ide> }
<ide> }
<ide><path>src/Database/Driver/Postgres.php
<ide> public function connect()
<ide> $config['flags'] += [
<ide> PDO::ATTR_PERSISTENT => $config['persistent'],
<ide> PDO::ATTR_EMULATE_PREPARES => false,
<del> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
<add> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
<ide> ];
<ide> if (empty($config['unix_socket'])) {
<ide> $dsn = "pgsql:host={$config['host']};port={$config['port']};dbname={$config['database']}";
<ide><path>src/Database/Driver/Sqlite.php
<ide> public function connect()
<ide> $config['flags'] += [
<ide> PDO::ATTR_PERSISTENT => $config['persistent'],
<ide> PDO::ATTR_EMULATE_PREPARES => false,
<del> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
<add> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
<ide> ];
<ide>
<ide> $databaseExists = file_exists($config['database']);
<ide><path>src/Database/Driver/Sqlserver.php
<ide> public function connect()
<ide>
<ide> $config['flags'] += [
<ide> PDO::ATTR_EMULATE_PREPARES => false,
<del> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
<add> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
<ide> ];
<ide>
<ide> if (!empty($config['encoding'])) {
<ide><path>src/Database/Expression/BetweenExpression.php
<ide> public function sql(ValueBinder $generator)
<ide> {
<ide> $parts = [
<ide> 'from' => $this->_from,
<del> 'to' => $this->_to
<add> 'to' => $this->_to,
<ide> ];
<ide>
<ide> $field = $this->_field;
<ide><path>src/Database/Query.php
<ide> class Query implements ExpressionInterface, IteratorAggregate
<ide> 'limit' => null,
<ide> 'offset' => null,
<ide> 'union' => [],
<del> 'epilog' => null
<add> 'epilog' => null,
<ide> ];
<ide>
<ide> /**
<ide> protected function _makeJoin($table, $conditions, $type)
<ide> $alias => [
<ide> 'table' => $table,
<ide> 'conditions' => $conditions,
<del> 'type' => $type
<del> ]
<add> 'type' => $type,
<add> ],
<ide> ];
<ide> }
<ide>
<ide> public function union($query, $overwrite = false)
<ide> }
<ide> $this->_parts['union'][] = [
<ide> 'all' => false,
<del> 'query' => $query
<add> 'query' => $query,
<ide> ];
<ide> $this->_dirty();
<ide>
<ide> public function unionAll($query, $overwrite = false)
<ide> }
<ide> $this->_parts['union'][] = [
<ide> 'all' => true,
<del> 'query' => $query
<add> 'query' => $query,
<ide> ];
<ide> $this->_dirty();
<ide>
<ide> public function __debugInfo()
<ide> 'params' => $params,
<ide> 'defaultTypes' => $this->getDefaultTypes(),
<ide> 'decorators' => count($this->_resultDecorators),
<del> 'executed' => $this->_iterator ? true : false
<add> 'executed' => $this->_iterator ? true : false,
<ide> ];
<ide> }
<ide> }
<ide><path>src/Database/QueryCompiler.php
<ide> class QueryCompiler
<ide> 'order' => ' %s',
<ide> 'limit' => ' LIMIT %s',
<ide> 'offset' => ' OFFSET %s',
<del> 'epilog' => ' %s'
<add> 'epilog' => ' %s',
<ide> ];
<ide>
<ide> /**
<ide> class QueryCompiler
<ide> */
<ide> protected $_selectParts = [
<ide> 'select', 'from', 'join', 'where', 'group', 'having', 'order', 'limit',
<del> 'offset', 'union', 'epilog'
<add> 'offset', 'union', 'epilog',
<ide> ];
<ide>
<ide> /**
<ide><path>src/Database/Schema/MysqlSchema.php
<ide> protected function _convertColumn($column)
<ide> 'type' => TableSchema::TYPE_FLOAT,
<ide> 'length' => $length,
<ide> 'precision' => $precision,
<del> 'unsigned' => $unsigned
<add> 'unsigned' => $unsigned,
<ide> ];
<ide> }
<ide> if (strpos($col, 'decimal') !== false) {
<ide> return [
<ide> 'type' => TableSchema::TYPE_DECIMAL,
<ide> 'length' => $length,
<ide> 'precision' => $precision,
<del> 'unsigned' => $unsigned
<add> 'unsigned' => $unsigned,
<ide> ];
<ide> }
<ide>
<ide> public function convertIndexDescription(TableSchema $schema, $row)
<ide> $schema->addIndex($name, [
<ide> 'type' => $type,
<ide> 'columns' => $columns,
<del> 'length' => $length
<add> 'length' => $length,
<ide> ]);
<ide> } else {
<ide> $schema->addConstraint($name, [
<ide> 'type' => $type,
<ide> 'columns' => $columns,
<del> 'length' => $length
<add> 'length' => $length,
<ide> ]);
<ide> }
<ide> }
<ide> public function columnSql(TableSchema $schema, $name)
<ide> TableSchema::TYPE_DATETIME => ' DATETIME',
<ide> TableSchema::TYPE_TIMESTAMP => ' TIMESTAMP',
<ide> TableSchema::TYPE_UUID => ' CHAR(36)',
<del> TableSchema::TYPE_JSON => $nativeJson ? ' JSON' : ' LONGTEXT'
<add> TableSchema::TYPE_JSON => $nativeJson ? ' JSON' : ' LONGTEXT',
<ide> ];
<ide> $specialMap = [
<ide> 'string' => true,
<ide> public function columnSql(TableSchema $schema, $name)
<ide> TableSchema::TYPE_INTEGER,
<ide> TableSchema::TYPE_SMALLINTEGER,
<ide> TableSchema::TYPE_TINYINTEGER,
<del> TableSchema::TYPE_STRING
<add> TableSchema::TYPE_STRING,
<ide> ];
<ide> if (in_array($data['type'], $hasLength, true) && isset($data['length'])) {
<ide> $out .= '(' . (int)$data['length'] . ')';
<ide> public function columnSql(TableSchema $schema, $name)
<ide> TableSchema::TYPE_INTEGER,
<ide> TableSchema::TYPE_BIGINTEGER,
<ide> TableSchema::TYPE_FLOAT,
<del> TableSchema::TYPE_DECIMAL
<add> TableSchema::TYPE_DECIMAL,
<ide> ];
<ide> if (in_array($data['type'], $hasUnsigned, true) &&
<ide> isset($data['unsigned']) && $data['unsigned'] === true
<ide><path>src/Database/Schema/PostgresSchema.php
<ide> public function convertColumnDescription(TableSchema $schema, $row)
<ide> 'default' => $this->_defaultValue($row['default']),
<ide> 'null' => $row['null'] === 'YES',
<ide> 'collate' => $row['collation_name'],
<del> 'comment' => $row['comment']
<add> 'comment' => $row['comment'],
<ide> ];
<ide> $field['length'] = $row['char_length'] ?: $field['length'];
<ide>
<ide> public function convertIndexDescription(TableSchema $schema, $row)
<ide> if (!$index) {
<ide> $index = [
<ide> 'type' => $type,
<del> 'columns' => []
<add> 'columns' => [],
<ide> ];
<ide> }
<ide> $index['columns'][] = $row['attname'];
<ide> protected function _convertConstraint($schema, $name, $type, $row)
<ide> if (!$constraint) {
<ide> $constraint = [
<ide> 'type' => $type,
<del> 'columns' => []
<add> 'columns' => [],
<ide> ];
<ide> }
<ide> $constraint['columns'][] = $row['attname'];
<ide> public function columnSql(TableSchema $schema, $name)
<ide> TableSchema::TYPE_DATETIME => ' TIMESTAMP',
<ide> TableSchema::TYPE_TIMESTAMP => ' TIMESTAMP',
<ide> TableSchema::TYPE_UUID => ' UUID',
<del> TableSchema::TYPE_JSON => ' JSONB'
<add> TableSchema::TYPE_JSON => ' JSONB',
<ide> ];
<ide>
<ide> if (isset($typeMap[$data['type']])) {
<ide> public function truncateTableSql(TableSchema $schema)
<ide> $name = $this->_driver->quoteIdentifier($schema->name());
<ide>
<ide> return [
<del> sprintf('TRUNCATE %s RESTART IDENTITY CASCADE', $name)
<add> sprintf('TRUNCATE %s RESTART IDENTITY CASCADE', $name),
<ide> ];
<ide> }
<ide>
<ide><path>src/Database/Schema/SqliteSchema.php
<ide> public function listTablesSql($config)
<ide> return [
<ide> 'SELECT name FROM sqlite_master WHERE type="table" ' .
<ide> 'AND name != "sqlite_sequence" ORDER BY name',
<del> []
<add> [],
<ide> ];
<ide> }
<ide>
<ide> public function convertColumnDescription(TableSchema $schema, $row)
<ide> if ($row['pk']) {
<ide> $constraint = (array)$schema->getConstraint('primary') + [
<ide> 'type' => TableSchema::CONSTRAINT_PRIMARY,
<del> 'columns' => []
<add> 'columns' => [],
<ide> ];
<ide> $constraint['columns'] = array_merge($constraint['columns'], [$row['name']]);
<ide> $schema->addConstraint('primary', $constraint);
<ide> public function convertIndexDescription(TableSchema $schema, $row)
<ide> if ($row['unique']) {
<ide> $schema->addConstraint($row['name'], [
<ide> 'type' => TableSchema::CONSTRAINT_UNIQUE,
<del> 'columns' => $columns
<add> 'columns' => $columns,
<ide> ]);
<ide> } else {
<ide> $schema->addIndex($row['name'], [
<ide> 'type' => TableSchema::INDEX_INDEX,
<del> 'columns' => $columns
<add> 'columns' => $columns,
<ide> ]);
<ide> }
<ide> }
<ide> public function columnSql(TableSchema $schema, $name)
<ide> TableSchema::TYPE_TIME => ' TIME',
<ide> TableSchema::TYPE_DATETIME => ' DATETIME',
<ide> TableSchema::TYPE_TIMESTAMP => ' TIMESTAMP',
<del> TableSchema::TYPE_JSON => ' TEXT'
<add> TableSchema::TYPE_JSON => ' TEXT',
<ide> ];
<ide>
<ide> $out = $this->_driver->quoteIdentifier($name);
<ide> public function columnSql(TableSchema $schema, $name)
<ide> TableSchema::TYPE_INTEGER,
<ide> TableSchema::TYPE_BIGINTEGER,
<ide> TableSchema::TYPE_FLOAT,
<del> TableSchema::TYPE_DECIMAL
<add> TableSchema::TYPE_DECIMAL,
<ide> ];
<ide>
<ide> if (in_array($data['type'], $hasUnsigned, true) &&
<ide><path>src/Database/Schema/SqlserverSchema.php
<ide> public function convertIndexDescription(TableSchema $schema, $row)
<ide> if ($type === TableSchema::CONSTRAINT_PRIMARY || $type === TableSchema::CONSTRAINT_UNIQUE) {
<ide> $schema->addConstraint($name, [
<ide> 'type' => $type,
<del> 'columns' => $columns
<add> 'columns' => $columns,
<ide> ]);
<ide>
<ide> return;
<ide> }
<ide> $schema->addIndex($name, [
<ide> 'type' => $type,
<del> 'columns' => $columns
<add> 'columns' => $columns,
<ide> ]);
<ide> }
<ide>
<ide> public function truncateTableSql(TableSchema $schema)
<ide> {
<ide> $name = $this->_driver->quoteIdentifier($schema->name());
<ide> $queries = [
<del> sprintf('DELETE FROM %s', $name)
<add> sprintf('DELETE FROM %s', $name),
<ide> ];
<ide>
<ide> // Restart identity sequences
<ide><path>src/Database/Schema/TableSchema.php
<ide> class TableSchema implements TableSchemaInterface, SqlGeneratorInterface
<ide> public static $columnLengths = [
<ide> 'tiny' => self::LENGTH_TINY,
<ide> 'medium' => self::LENGTH_MEDIUM,
<del> 'long' => self::LENGTH_LONG
<add> 'long' => self::LENGTH_LONG,
<ide> ];
<ide>
<ide> /**
<ide><path>src/Database/SqlserverCompiler.php
<ide> class SqlserverCompiler extends QueryCompiler
<ide> 'having' => ' HAVING %s ',
<ide> 'order' => ' %s',
<ide> 'offset' => ' OFFSET %s ROWS',
<del> 'epilog' => ' %s'
<add> 'epilog' => ' %s',
<ide> ];
<ide>
<ide> /**
<ide> * {@inheritDoc}
<ide> */
<ide> protected $_selectParts = [
<ide> 'select', 'from', 'join', 'where', 'group', 'having', 'order', 'offset',
<del> 'limit', 'union', 'epilog'
<add> 'limit', 'union', 'epilog',
<ide> ];
<ide>
<ide> /**
<ide><path>src/Database/Type.php
<ide> class Type implements TypeInterface
<ide> 'text' => ['callback' => [Type::class, 'strval']],
<ide> 'boolean' => [
<ide> 'callback' => [Type::class, 'boolval'],
<del> 'pdo' => PDO::PARAM_BOOL
<add> 'pdo' => PDO::PARAM_BOOL,
<ide> ],
<ide> ];
<ide>
<ide><path>src/Database/ValueBinder.php
<ide> class ValueBinder
<ide> public function bind($param, $value, $type = 'string')
<ide> {
<ide> $this->_bindings[$param] = compact('value', 'type') + [
<del> 'placeholder' => is_int($param) ? $param : substr($param, 1)
<add> 'placeholder' => is_int($param) ? $param : substr($param, 1),
<ide> ];
<ide> }
<ide>
<ide><path>src/Datasource/EntityTrait.php
<ide> public function __debugInfo()
<ide> '[hasErrors]' => $this->hasErrors(),
<ide> '[errors]' => $this->_errors,
<ide> '[invalid]' => $this->_invalid,
<del> '[repository]' => $this->_registryAlias
<add> '[repository]' => $this->_registryAlias,
<ide> ];
<ide> }
<ide> }
<ide><path>src/Datasource/Paginator.php
<ide> class Paginator implements PaginatorInterface
<ide> 'page' => 1,
<ide> 'limit' => 20,
<ide> 'maxLimit' => 100,
<del> 'whitelist' => ['limit', 'sort', 'page', 'direction']
<add> 'whitelist' => ['limit', 'sort', 'page', 'direction'],
<ide> ];
<ide>
<ide> /**
<ide> public function paginate($object, array $params = [], array $settings = [])
<ide> if ($requestedPage > $page) {
<ide> throw new PageOutOfBoundsException([
<ide> 'requestedPage' => $requestedPage,
<del> 'pagingParams' => $this->_pagingParams
<add> 'pagingParams' => $this->_pagingParams,
<ide> ]);
<ide> }
<ide>
<ide><path>src/Error/BaseErrorHandler.php
<ide> public function handleError($code, $description, $file = null, $line = null, $co
<ide> $data += [
<ide> 'context' => $context,
<ide> 'start' => 3,
<del> 'path' => Debugger::trimPath($file)
<add> 'path' => Debugger::trimPath($file),
<ide> ];
<ide> }
<ide> $this->_displayError($data, $debug);
<ide> protected function _logError($level, $data)
<ide> if (!empty($this->_options['trace'])) {
<ide> $trace = Debugger::trace([
<ide> 'start' => 1,
<del> 'format' => 'log'
<add> 'format' => 'log',
<ide> ]);
<ide>
<ide> $request = Router::getRequest();
<ide><path>src/Error/Debugger.php
<ide> class Debugger
<ide> * @var array
<ide> */
<ide> protected $_defaultConfig = [
<del> 'outputMask' => []
<add> 'outputMask' => [],
<ide> ];
<ide>
<ide> /**
<ide> class Debugger
<ide> protected $_templates = [
<ide> 'log' => [
<ide> 'trace' => '{:reference} - {:path}, line {:line}',
<del> 'error' => '{:error} ({:code}): {:description} in [{:file}, line {:line}]'
<add> 'error' => '{:error} ({:code}): {:description} in [{:file}, line {:line}]',
<ide> ],
<ide> 'js' => [
<ide> 'error' => '',
<ide> class Debugger
<ide> 'txt' => [
<ide> 'error' => "{:error}: {:code} :: {:description} on line {:line} of {:path}\n{:info}",
<ide> 'code' => '',
<del> 'info' => ''
<add> 'info' => '',
<ide> ],
<ide> 'base' => [
<ide> 'traceLine' => '{:reference} - {:path}, line {:line}',
<ide> 'trace' => "Trace:\n{:trace}\n",
<ide> 'context' => "Context:\n{:context}\n",
<del> ]
<add> ],
<ide> ];
<ide>
<ide> /**
<ide> public static function formatTrace($backtrace, $options = [])
<ide> 'args' => false,
<ide> 'start' => 0,
<ide> 'scope' => null,
<del> 'exclude' => ['call_user_func_array', 'trigger_error']
<add> 'exclude' => ['call_user_func_array', 'trigger_error'],
<ide> ];
<ide> $options = Hash::merge($defaults, $options);
<ide>
<ide> public static function formatTrace($backtrace, $options = [])
<ide> 'line' => '??',
<ide> 'file' => '[internal]',
<ide> 'class' => null,
<del> 'function' => '[main]'
<add> 'function' => '[main]',
<ide> ];
<ide>
<ide> for ($i = $options['start']; $i < $count && $i < $options['depth']; $i++) {
<ide><path>src/Error/ExceptionRenderer.php
<ide> public function render()
<ide> 'url' => h($url),
<ide> 'error' => $unwrapped,
<ide> 'code' => $code,
<del> '_serialize' => ['message', 'url', 'code']
<add> '_serialize' => ['message', 'url', 'code'],
<ide> ];
<ide>
<ide> $isDebug = Configure::read('debug');
<ide> if ($isDebug) {
<ide> $viewVars['trace'] = Debugger::formatTrace($unwrapped->getTrace(), [
<ide> 'format' => 'array',
<del> 'args' => false
<add> 'args' => false,
<ide> ]);
<ide> $viewVars['file'] = $exception->getFile() ?: 'null';
<ide> $viewVars['line'] = $exception->getLine() ?: 'null';
<ide> protected function _shutdown()
<ide> }
<ide> $args = [
<ide> 'request' => $this->controller->request,
<del> 'response' => $this->controller->response
<add> 'response' => $this->controller->response,
<ide> ];
<ide> $result = $dispatcher->dispatchEvent('Dispatcher.afterDispatch', $args);
<ide>
<ide><path>src/Event/EventManager.php
<ide> public function on($eventKey = null, $options = [], $callable = null)
<ide> $argCount = func_num_args();
<ide> if ($argCount === 2) {
<ide> $this->_listeners[$eventKey][static::$defaultPriority][] = [
<del> 'callable' => $options
<add> 'callable' => $options,
<ide> ];
<ide>
<ide> return $this;
<ide> }
<ide> if ($argCount === 3) {
<ide> $priority = isset($options['priority']) ? $options['priority'] : static::$defaultPriority;
<ide> $this->_listeners[$eventKey][$priority][] = [
<del> 'callable' => $callable
<add> 'callable' => $callable,
<ide> ];
<ide>
<ide> return $this;
<ide><path>src/Filesystem/Folder.php
<ide> class Folder
<ide> */
<ide> protected $_fsorts = [
<ide> self::SORT_NAME => 'getPathname',
<del> self::SORT_TIME => 'getCTime'
<add> self::SORT_TIME => 'getCTime',
<ide> ];
<ide>
<ide> /**
<ide> public function copy($options)
<ide> 'mode' => $this->mode,
<ide> 'skip' => [],
<ide> 'scheme' => Folder::MERGE,
<del> 'recursive' => true
<add> 'recursive' => true,
<ide> ];
<ide>
<ide> $fromDir = $options['from'];
<ide><path>src/Form/Form.php
<ide> public function __debugInfo()
<ide> $special = [
<ide> '_schema' => $this->schema()->__debugInfo(),
<ide> '_errors' => $this->getErrors(),
<del> '_validator' => $this->getValidator()->__debugInfo()
<add> '_validator' => $this->getValidator()->__debugInfo(),
<ide> ];
<ide>
<ide> return $special + get_object_vars($this);
<ide><path>src/Form/Schema.php
<ide> public function fieldType($name)
<ide> public function __debugInfo()
<ide> {
<ide> return [
<del> '_fields' => $this->_fields
<add> '_fields' => $this->_fields,
<ide> ];
<ide> }
<ide> }
<ide><path>src/Http/Client.php
<ide> public function send(Request $request, $options = [])
<ide> 'host' => $url->getHost(),
<ide> 'port' => $url->getPort(),
<ide> 'scheme' => $url->getScheme(),
<del> 'protocolRelative' => true
<add> 'protocolRelative' => true,
<ide> ]);
<ide> $request = $request->withUri(new Uri($locationUrl));
<ide> $request = $this->_cookies->addToRequest($request, []);
<ide> public function buildUrl($url, $query = [], $options = [])
<ide> 'host' => null,
<ide> 'port' => null,
<ide> 'scheme' => 'http',
<del> 'protocolRelative' => false
<add> 'protocolRelative' => false,
<ide> ];
<ide> $options += $defaults;
<ide>
<ide> public function buildUrl($url, $query = [], $options = [])
<ide>
<ide> $defaultPorts = [
<ide> 'http' => 80,
<del> 'https' => 443
<add> 'https' => 443,
<ide> ];
<ide> $out = $options['scheme'] . '://' . $options['host'];
<ide> if ($options['port'] && $options['port'] != $defaultPorts[$options['scheme']]) {
<ide> protected function _typeHeaders($type)
<ide> if (strpos($type, '/') !== false) {
<ide> return [
<ide> 'Accept' => $type,
<del> 'Content-Type' => $type
<add> 'Content-Type' => $type,
<ide> ];
<ide> }
<ide> $typeMap = [
<ide><path>src/Http/Client/Adapter/Curl.php
<ide> public function buildOptions(Request $request, array $options)
<ide> CURLOPT_HTTP_VERSION => $this->getProtocolVersion($request),
<ide> CURLOPT_RETURNTRANSFER => true,
<ide> CURLOPT_HEADER => true,
<del> CURLOPT_HTTPHEADER => $headers
<add> CURLOPT_HTTPHEADER => $headers,
<ide> ];
<ide> switch ($request->getMethod()) {
<ide> case Request::METHOD_GET:
<ide><path>src/Http/Client/CookieCollection.php
<ide> protected function convertCookieToArray(CookieInterface $cookie)
<ide> 'domain' => $cookie->getDomain(),
<ide> 'secure' => $cookie->isSecure(),
<ide> 'httponly' => $cookie->isHttpOnly(),
<del> 'expires' => $cookie->getExpiresTimestamp()
<add> 'expires' => $cookie->getExpiresTimestamp(),
<ide> ];
<ide> }
<ide> }
<ide><path>src/Http/Client/Request.php
<ide> public function __construct($url = '', $method = self::METHOD_GET, array $header
<ide> $this->uri = $this->createUri($url);
<ide> $headers += [
<ide> 'Connection' => 'close',
<del> 'User-Agent' => 'CakePHP'
<add> 'User-Agent' => 'CakePHP',
<ide> ];
<ide> $this->addHeaders($headers);
<ide> $this->body($data);
<ide><path>src/Http/Client/Response.php
<ide> public function isOk()
<ide> static::STATUS_CREATED,
<ide> static::STATUS_ACCEPTED,
<ide> static::STATUS_NON_AUTHORITATIVE_INFORMATION,
<del> static::STATUS_NO_CONTENT
<add> static::STATUS_NO_CONTENT,
<ide> ];
<ide>
<ide> return in_array($this->code, $codes);
<ide> protected function convertCookieToArray(CookieInterface $cookie)
<ide> 'domain' => $cookie->getDomain(),
<ide> 'secure' => $cookie->isSecure(),
<ide> 'httponly' => $cookie->isHttpOnly(),
<del> 'expires' => $cookie->getFormattedExpires()
<add> 'expires' => $cookie->getFormattedExpires(),
<ide> ];
<ide> }
<ide>
<ide><path>src/Http/ControllerFactory.php
<ide> protected function missingController($request)
<ide> 'class' => $request->getParam('controller'),
<ide> 'plugin' => $request->getParam('plugin'),
<ide> 'prefix' => $request->getParam('prefix'),
<del> '_ext' => $request->getParam('_ext')
<add> '_ext' => $request->getParam('_ext'),
<ide> ]);
<ide> }
<ide> }
<ide><path>src/Http/Cookie/CookieCollection.php
<ide> protected static function parseSetCookieHeader($values)
<ide> 'secure' => false,
<ide> 'httponly' => false,
<ide> 'expires' => null,
<del> 'max-age' => null
<add> 'max-age' => null,
<ide> ];
<ide> foreach ($parts as $i => $part) {
<ide> if (strpos($part, '=') !== false) {
<ide><path>src/Http/RequestTransformer.php
<ide> protected static function getParams(PsrRequest $request)
<ide> 'controller' => null,
<ide> 'action' => null,
<ide> '_ext' => null,
<del> 'pass' => []
<add> 'pass' => [],
<ide> ];
<ide>
<ide> return $params;
<ide><path>src/Http/Response.php
<ide> class Response implements ResponseInterface
<ide> 'mkv' => 'video/x-matroska',
<ide> 'pkpass' => 'application/vnd.apple.pkpass',
<ide> 'ajax' => 'text/html',
<del> 'bmp' => 'image/bmp'
<add> 'bmp' => 'image/bmp',
<ide> ];
<ide>
<ide> /**
<ide> protected function _setContentType()
<ide> return;
<ide> }
<ide> $whitelist = [
<del> 'application/javascript', 'application/xml', 'application/rss+xml'
<add> 'application/javascript', 'application/xml', 'application/rss+xml',
<ide> ];
<ide>
<ide> $charset = false;
<ide> public function notModified()
<ide> 'Content-Length',
<ide> 'Content-MD5',
<ide> 'Content-Type',
<del> 'Last-Modified'
<add> 'Last-Modified',
<ide> ];
<ide> foreach ($remove as $header) {
<ide> $this->_clearHeader($header);
<ide> public function withNotModified()
<ide> 'Content-Length',
<ide> 'Content-MD5',
<ide> 'Content-Type',
<del> 'Last-Modified'
<add> 'Last-Modified',
<ide> ];
<ide> foreach ($remove as $header) {
<ide> $new = $new->withoutHeader($header);
<ide> public function cookie($options = null)
<ide> 'path' => '/',
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httpOnly' => false
<add> 'httpOnly' => false,
<ide> ];
<ide> $expires = $options['expire'] ? new DateTime('@' . $options['expire']) : null;
<ide> $cookie = new Cookie(
<ide> public function withCookie($name, $data = '')
<ide> 'path' => '/',
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httpOnly' => false
<add> 'httpOnly' => false,
<ide> ];
<ide> $expires = $data['expire'] ? new DateTime('@' . $data['expire']) : null;
<ide> $cookie = new Cookie(
<ide> public function withExpiredCookie($name, $options = [])
<ide> 'path' => '/',
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httpOnly' => false
<add> 'httpOnly' => false,
<ide> ];
<ide>
<ide> $cookie = new Cookie(
<ide> protected function convertCookieToArray(CookieInterface $cookie)
<ide> 'domain' => $cookie->getDomain(),
<ide> 'secure' => $cookie->isSecure(),
<ide> 'httpOnly' => $cookie->isHttpOnly(),
<del> 'expire' => $cookie->getExpiresTimestamp()
<add> 'expire' => $cookie->getExpiresTimestamp(),
<ide> ];
<ide> }
<ide>
<ide> public function file($path, array $options = [])
<ide> $file = $this->validateFile($path);
<ide> $options += [
<ide> 'name' => null,
<del> 'download' => null
<add> 'download' => null,
<ide> ];
<ide>
<ide> $extension = strtolower($file->ext());
<ide> public function withFile($path, array $options = [])
<ide> $file = $this->validateFile($path);
<ide> $options += [
<ide> 'name' => null,
<del> 'download' => null
<add> 'download' => null,
<ide> ];
<ide>
<ide> $extension = strtolower($file->ext());
<ide><path>src/Http/ResponseEmitter.php
<ide> protected function emitCookies(array $cookies)
<ide> 'path' => '',
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httponly' => false
<add> 'httponly' => false,
<ide> ];
<ide>
<ide> foreach ($parts as $part) {
<ide><path>src/Http/ResponseTransformer.php
<ide> protected static function setContentType($headers, $response)
<ide> }
<ide>
<ide> $whitelist = [
<del> 'application/javascript', 'application/json', 'application/xml', 'application/rss+xml'
<add> 'application/javascript', 'application/json', 'application/xml', 'application/rss+xml',
<ide> ];
<ide>
<ide> $type = $response->type();
<ide> protected static function buildCookieHeader($cookies)
<ide> $headers = [];
<ide> foreach ($cookies as $cookie) {
<ide> $parts = [
<del> sprintf('%s=%s', urlencode($cookie['name']), urlencode($cookie['value']))
<add> sprintf('%s=%s', urlencode($cookie['name']), urlencode($cookie['value'])),
<ide> ];
<ide> if ($cookie['expire']) {
<ide> $cookie['expire'] = gmdate('D, d M Y H:i:s T', $cookie['expire']);
<ide><path>src/Http/ServerRequest.php
<ide> class ServerRequest implements ArrayAccess, ServerRequestInterface
<ide> 'controller' => null,
<ide> 'action' => null,
<ide> '_ext' => null,
<del> 'pass' => []
<add> 'pass' => [],
<ide> ];
<ide>
<ide> /**
<ide> protected function _setConfig($config)
<ide>
<ide> if (empty($config['session'])) {
<ide> $config['session'] = new Session([
<del> 'cookiePath' => $config['base']
<add> 'cookiePath' => $config['base'],
<ide> ]);
<ide> }
<ide>
<ide> public function getAttributes()
<ide> 'params' => $this->params,
<ide> 'webroot' => $this->webroot,
<ide> 'base' => $this->base,
<del> 'here' => $this->here
<add> 'here' => $this->here,
<ide> ];
<ide>
<ide> return $this->attributes + $emulated;
<ide><path>src/Http/ServerRequestFactory.php
<ide> public static function fromGlobals(
<ide> $uri = static::createUri($server);
<ide> $sessionConfig = (array)Configure::read('Session') + [
<ide> 'defaults' => 'php',
<del> 'cookiePath' => $uri->webroot
<add> 'cookiePath' => $uri->webroot,
<ide> ];
<ide> $session = Session::create($sessionConfig);
<ide> $request = new ServerRequest([
<ide> protected static function getBase($uri, $server)
<ide> $config = (array)Configure::read('App') + [
<ide> 'base' => null,
<ide> 'webroot' => null,
<del> 'baseUrl' => null
<add> 'baseUrl' => null,
<ide> ];
<ide> $base = $config['base'];
<ide> $baseUrl = $config['baseUrl'];
<ide><path>src/Http/Session.php
<ide> protected static function _defaultConfig($name)
<ide> 'cookie' => 'CAKEPHP',
<ide> 'ini' => [
<ide> 'session.use_trans_sid' => 0,
<del> ]
<add> ],
<ide> ],
<ide> 'cake' => [
<ide> 'cookie' => 'CAKEPHP',
<ide> protected static function _defaultConfig($name)
<ide> 'session.serialize_handler' => 'php',
<ide> 'session.use_cookies' => 1,
<ide> 'session.save_path' => TMP . 'sessions',
<del> 'session.save_handler' => 'files'
<del> ]
<add> 'session.save_handler' => 'files',
<add> ],
<ide> ],
<ide> 'cache' => [
<ide> 'cookie' => 'CAKEPHP',
<ide> protected static function _defaultConfig($name)
<ide> ],
<ide> 'handler' => [
<ide> 'engine' => 'CacheSession',
<del> 'config' => 'default'
<del> ]
<add> 'config' => 'default',
<add> ],
<ide> ],
<ide> 'database' => [
<ide> 'cookie' => 'CAKEPHP',
<ide> protected static function _defaultConfig($name)
<ide> 'session.serialize_handler' => 'php',
<ide> ],
<ide> 'handler' => [
<del> 'engine' => 'DatabaseSession'
<del> ]
<del> ]
<add> 'engine' => 'DatabaseSession',
<add> ],
<add> ],
<ide> ];
<ide>
<ide> if (isset($defaults[$name])) {
<ide><path>src/I18n/DateFormatTrait.php
<ide> public function __debugInfo()
<ide> return [
<ide> 'time' => $this->format('Y-m-d H:i:s.uP'),
<ide> 'timezone' => $this->getTimezone()->getName(),
<del> 'fixedNowTime' => static::hasTestNow() ? static::getTestNow()->format('Y-m-d H:i:s.uP') : false
<add> 'fixedNowTime' => static::hasTestNow() ? static::getTestNow()->format('Y-m-d H:i:s.uP') : false,
<ide> ];
<ide> }
<ide> }
<ide><path>src/I18n/MessagesFileLoader.php
<ide> public function translationsFolders()
<ide>
<ide> $folders = [
<ide> implode('_', [$locale['language'], $locale['region']]),
<del> $locale['language']
<add> $locale['language'],
<ide> ];
<ide>
<ide> $searchPaths = [];
<ide><path>src/I18n/Number.php
<ide> public static function formatter($options = [])
<ide> 'places' => null,
<ide> 'precision' => null,
<ide> 'pattern' => null,
<del> 'useIntlCode' => null
<add> 'useIntlCode' => null,
<ide> ]);
<ide> if (empty($options)) {
<ide> return $formatter;
<ide><path>src/I18n/Parser/PoFileParser.php
<ide> public function parse($resource)
<ide>
<ide> $defaults = [
<ide> 'ids' => [],
<del> 'translated' => null
<add> 'translated' => null,
<ide> ];
<ide>
<ide> $messages = [];
<ide><path>src/I18n/RelativeTimeFormatter.php
<ide> public function timeAgoInWords(DateTimeInterface $time, array $options = [])
<ide> 'day' => __d('cake', 'about a day ago'),
<ide> 'week' => __d('cake', 'about a week ago'),
<ide> 'month' => __d('cake', 'about a month ago'),
<del> 'year' => __d('cake', 'about a year ago')
<add> 'year' => __d('cake', 'about a year ago'),
<ide> ];
<ide>
<ide> return $relativeDate ? sprintf($options['relativeString'], $relativeDate) : $aboutAgo[$fWord];
<ide> public function timeAgoInWords(DateTimeInterface $time, array $options = [])
<ide> 'day' => __d('cake', 'in about a day'),
<ide> 'week' => __d('cake', 'in about a week'),
<ide> 'month' => __d('cake', 'in about a month'),
<del> 'year' => __d('cake', 'in about a year')
<add> 'year' => __d('cake', 'in about a year'),
<ide> ];
<ide>
<ide> return $aboutIn[$fWord];
<ide> public function dateAgoInWords(DateTimeInterface $date, array $options = [])
<ide> 'day' => __d('cake', 'about a day ago'),
<ide> 'week' => __d('cake', 'about a week ago'),
<ide> 'month' => __d('cake', 'about a month ago'),
<del> 'year' => __d('cake', 'about a year ago')
<add> 'year' => __d('cake', 'about a year ago'),
<ide> ];
<ide>
<ide> return $relativeDate ? sprintf($options['relativeString'], $relativeDate) : $aboutAgo[$fWord];
<ide> public function dateAgoInWords(DateTimeInterface $date, array $options = [])
<ide> 'day' => __d('cake', 'in about a day'),
<ide> 'week' => __d('cake', 'in about a week'),
<ide> 'month' => __d('cake', 'in about a month'),
<del> 'year' => __d('cake', 'in about a year')
<add> 'year' => __d('cake', 'in about a year'),
<ide> ];
<ide>
<ide> return $aboutIn[$fWord];
<ide><path>src/I18n/TranslatorRegistry.php
<ide> public function __construct(
<ide> $this->registerLoader($this->_fallbackLoader, function ($name, $locale) {
<ide> $chain = new ChainMessagesLoader([
<ide> new MessagesFileLoader($name, $locale, 'mo'),
<del> new MessagesFileLoader($name, $locale, 'po')
<add> new MessagesFileLoader($name, $locale, 'po'),
<ide> ]);
<ide>
<ide> // \Aura\Intl\Package by default uses formatter configured with key "basic".
<ide><path>src/Log/Engine/BaseLog.php
<ide> abstract class BaseLog extends AbstractLogger
<ide> */
<ide> protected $_defaultConfig = [
<ide> 'levels' => [],
<del> 'scopes' => []
<add> 'scopes' => [],
<ide> ];
<ide>
<ide> /**
<ide><path>src/Log/Engine/SyslogLog.php
<ide> class SyslogLog extends BaseLog
<ide> 'format' => '%s: %s',
<ide> 'flag' => LOG_ODELAY,
<ide> 'prefix' => '',
<del> 'facility' => LOG_USER
<add> 'facility' => LOG_USER,
<ide> ];
<ide>
<ide> /**
<ide> class SyslogLog extends BaseLog
<ide> 'warning' => LOG_WARNING,
<ide> 'notice' => LOG_NOTICE,
<ide> 'info' => LOG_INFO,
<del> 'debug' => LOG_DEBUG
<add> 'debug' => LOG_DEBUG,
<ide> ];
<ide>
<ide> /**
<ide><path>src/Log/Log.php
<ide> class Log
<ide> 'warning',
<ide> 'notice',
<ide> 'info',
<del> 'debug'
<add> 'debug',
<ide> ];
<ide>
<ide> /**
<ide><path>src/Mailer/Email.php
<ide> class Email implements JsonSerializable, Serializable
<ide> '8bit',
<ide> 'base64',
<ide> 'binary',
<del> 'quoted-printable'
<add> 'quoted-printable',
<ide> ];
<ide>
<ide> /**
<ide> class Email implements JsonSerializable, Serializable
<ide> * @var array
<ide> */
<ide> protected $_contentTypeCharset = [
<del> 'ISO-2022-JP-MS' => 'ISO-2022-JP'
<add> 'ISO-2022-JP-MS' => 'ISO-2022-JP',
<ide> ];
<ide>
<ide> /**
<ide> public function getHeaders(array $include = [])
<ide> 'from' => 'From',
<ide> 'replyTo' => 'Reply-To',
<ide> 'readReceipt' => 'Disposition-Notification-To',
<del> 'returnPath' => 'Return-Path'
<add> 'returnPath' => 'Return-Path',
<ide> ];
<ide> foreach ($relation as $var => $header) {
<ide> if ($include[$var]) {
<ide> public function template($template = false, $layout = false)
<ide> if ($template === false) {
<ide> return [
<ide> 'template' => $this->viewBuilder()->getTemplate(),
<del> 'layout' => $this->viewBuilder()->getLayout()
<add> 'layout' => $this->viewBuilder()->getLayout(),
<ide> ];
<ide> }
<ide> $this->viewBuilder()->setTemplate($template);
<ide> protected function _logDelivery($contents)
<ide> }
<ide> $config = [
<ide> 'level' => 'debug',
<del> 'scope' => 'email'
<add> 'scope' => 'email',
<ide> ];
<ide> if ($this->_profile['log'] !== true) {
<ide> if (!is_array($this->_profile['log'])) {
<ide> protected function _applyConfig($config)
<ide> $simpleMethods = [
<ide> 'from', 'sender', 'to', 'replyTo', 'readReceipt', 'returnPath',
<ide> 'cc', 'bcc', 'messageId', 'domain', 'subject', 'attachments',
<del> 'transport', 'emailFormat', 'emailPattern', 'charset', 'headerCharset'
<add> 'transport', 'emailFormat', 'emailPattern', 'charset', 'headerCharset',
<ide> ];
<ide> foreach ($simpleMethods as $method) {
<ide> if (isset($config[$method])) {
<ide> protected function _applyConfig($config)
<ide> }
<ide>
<ide> $viewBuilderMethods = [
<del> 'template', 'layout', 'theme'
<add> 'template', 'layout', 'theme',
<ide> ];
<ide> foreach ($viewBuilderMethods as $method) {
<ide> if (array_key_exists($method, $config)) {
<ide> public function jsonSerialize()
<ide> $properties = [
<ide> '_to', '_from', '_sender', '_replyTo', '_cc', '_bcc', '_subject',
<ide> '_returnPath', '_readReceipt', '_emailFormat', '_emailPattern', '_domain',
<del> '_attachments', '_messageId', '_headers', '_appCharset', 'viewVars', 'charset', 'headerCharset'
<add> '_attachments', '_messageId', '_headers', '_appCharset', 'viewVars', 'charset', 'headerCharset',
<ide> ];
<ide>
<ide> $array = ['viewConfig' => $this->viewBuilder()->jsonSerialize()];
<ide><path>src/Mailer/Transport/SmtpTransport.php
<ide> class SmtpTransport extends AbstractTransport
<ide> 'password' => null,
<ide> 'client' => null,
<ide> 'tls' => false,
<del> 'keepAlive' => false
<add> 'keepAlive' => false,
<ide> ];
<ide>
<ide> /**
<ide> protected function _bufferResponseLines(array $responseLines)
<ide> if (preg_match('/^(\d{3})(?:[ -]+(.*))?$/', $responseLine, $match)) {
<ide> $response[] = [
<ide> 'code' => $match[1],
<del> 'message' => isset($match[2]) ? $match[2] : null
<add> 'message' => isset($match[2]) ? $match[2] : null,
<ide> ];
<ide> }
<ide> }
<ide><path>src/Network/Socket.php
<ide> class Socket
<ide> 'host' => 'localhost',
<ide> 'protocol' => 'tcp',
<ide> 'port' => 80,
<del> 'timeout' => 30
<add> 'timeout' => 30,
<ide> ];
<ide>
<ide> /**
<ide><path>src/ORM/Association.php
<ide> abstract class Association
<ide> protected $_validStrategies = [
<ide> self::STRATEGY_JOIN,
<ide> self::STRATEGY_SELECT,
<del> self::STRATEGY_SUBQUERY
<add> self::STRATEGY_SUBQUERY,
<ide> ];
<ide>
<ide> /**
<ide> public function __construct($alias, array $options = [])
<ide> 'tableLocator',
<ide> 'propertyName',
<ide> 'sourceTable',
<del> 'targetTable'
<add> 'targetTable',
<ide> ];
<ide> foreach ($defaults as $property) {
<ide> if (isset($options[$property])) {
<ide> public function attachTo(Query $query, array $options = [])
<ide> 'fields' => [],
<ide> 'type' => $joinType,
<ide> 'table' => $table,
<del> 'finder' => $this->getFinder()
<add> 'finder' => $this->getFinder(),
<ide> ];
<ide>
<ide> if (!empty($options['foreignKey'])) {
<ide><path>src/ORM/Association/BelongsTo.php
<ide> class BelongsTo extends Association
<ide> */
<ide> protected $_validStrategies = [
<ide> self::STRATEGY_JOIN,
<del> self::STRATEGY_SELECT
<add> self::STRATEGY_SELECT,
<ide> ];
<ide>
<ide> /**
<ide> public function eagerLoader(array $options)
<ide> 'bindingKey' => $this->getBindingKey(),
<ide> 'strategy' => $this->getStrategy(),
<ide> 'associationType' => $this->type(),
<del> 'finder' => [$this, 'find']
<add> 'finder' => [$this, 'find'],
<ide> ]);
<ide>
<ide> return $loader->buildEagerLoader($options);
<ide><path>src/ORM/Association/BelongsToMany.php
<ide> class BelongsToMany extends Association
<ide> */
<ide> protected $_validStrategies = [
<ide> self::STRATEGY_SELECT,
<del> self::STRATEGY_SUBQUERY
<add> self::STRATEGY_SUBQUERY,
<ide> ];
<ide>
<ide> /**
<ide> protected function _generateJunctionAssociations($junction, $source, $target)
<ide> if (!$junction->hasAssociation($tAlias)) {
<ide> $junction->belongsTo($tAlias, [
<ide> 'foreignKey' => $this->getTargetForeignKey(),
<del> 'targetTable' => $target
<add> 'targetTable' => $target,
<ide> ]);
<ide> }
<ide> if (!$junction->hasAssociation($sAlias)) {
<ide> $junction->belongsTo($sAlias, [
<ide> 'foreignKey' => $this->getForeignKey(),
<del> 'targetTable' => $source
<add> 'targetTable' => $source,
<ide> ]);
<ide> }
<ide> }
<ide> protected function _appendNotMatching($query, $options)
<ide>
<ide> $assoc = $junction->getAssociation($this->getTarget()->getAlias());
<ide> $conditions = $assoc->_joinCondition([
<del> 'foreignKey' => $this->getTargetForeignKey()
<add> 'foreignKey' => $this->getTargetForeignKey(),
<ide> ]);
<ide> $subquery = $this->_appendJunctionJoin($subquery, $conditions);
<ide>
<ide> public function eagerLoader(array $options)
<ide> 'junctionConditions' => $this->junctionConditions(),
<ide> 'finder' => function () {
<ide> return $this->_appendJunctionJoin($this->find(), []);
<del> }
<add> },
<ide> ]);
<ide>
<ide> return $loader->buildEagerLoader($options);
<ide> public function unlink(EntityInterface $sourceEntity, array $targetEntities, $op
<ide> {
<ide> if (is_bool($options)) {
<ide> $options = [
<del> 'cleanProperty' => $options
<add> 'cleanProperty' => $options,
<ide> ];
<ide> } else {
<ide> $options += ['cleanProperty' => true];
<ide> public function find($type = null, array $options = [])
<ide>
<ide> $belongsTo = $this->junction()->getAssociation($this->getTarget()->getAlias());
<ide> $conditions = $belongsTo->_joinCondition([
<del> 'foreignKey' => $this->getTargetForeignKey()
<add> 'foreignKey' => $this->getTargetForeignKey(),
<ide> ]);
<ide> $conditions += $this->junctionConditions();
<ide>
<ide> protected function _appendJunctionJoin($query, $conditions)
<ide> $name => [
<ide> 'table' => $this->junction()->getTable(),
<ide> 'conditions' => $conditions,
<del> 'type' => QueryInterface::JOIN_TYPE_INNER
<del> ]
<add> 'type' => QueryInterface::JOIN_TYPE_INNER,
<add> ],
<ide> ];
<ide>
<ide> $assoc = $this->getTarget()->getAssociation($name);
<ide> protected function _junctionTableName($name = null)
<ide> if (empty($this->_junctionTableName)) {
<ide> $tablesNames = array_map('Cake\Utility\Inflector::underscore', [
<ide> $this->getSource()->getTable(),
<del> $this->getTarget()->getTable()
<add> $this->getTarget()->getTable(),
<ide> ]);
<ide> sort($tablesNames);
<ide> $this->_junctionTableName = implode('_', $tablesNames);
<ide><path>src/ORM/Association/HasMany.php
<ide> class HasMany extends Association
<ide> */
<ide> protected $_validStrategies = [
<ide> self::STRATEGY_SELECT,
<del> self::STRATEGY_SUBQUERY
<add> self::STRATEGY_SUBQUERY,
<ide> ];
<ide>
<ide> /**
<ide> public function unlink(EntityInterface $sourceEntity, array $targetEntities, $op
<ide> {
<ide> if (is_bool($options)) {
<ide> $options = [
<del> 'cleanProperty' => $options
<add> 'cleanProperty' => $options,
<ide> ];
<ide> } else {
<ide> $options += ['cleanProperty' => true];
<ide> public function unlink(EntityInterface $sourceEntity, array $targetEntities, $op
<ide> /** @var \Cake\Datasource\EntityInterface $entity */
<ide> return $entity->extract($targetPrimaryKey);
<ide> })
<del> ->toList()
<add> ->toList(),
<ide> ];
<ide>
<ide> $this->_unlink($foreignKey, $target, $conditions, $options);
<ide> function ($v) {
<ide> if (count($exclusions) > 0) {
<ide> $conditions = [
<ide> 'NOT' => [
<del> 'OR' => $exclusions
<add> 'OR' => $exclusions,
<ide> ],
<del> $foreignKeyReference
<add> $foreignKeyReference,
<ide> ];
<ide> }
<ide>
<ide> public function eagerLoader(array $options)
<ide> 'strategy' => $this->getStrategy(),
<ide> 'associationType' => $this->type(),
<ide> 'sort' => $this->getSort(),
<del> 'finder' => [$this, 'find']
<add> 'finder' => [$this, 'find'],
<ide> ]);
<ide>
<ide> return $loader->buildEagerLoader($options);
<ide><path>src/ORM/Association/HasOne.php
<ide> class HasOne extends Association
<ide> */
<ide> protected $_validStrategies = [
<ide> self::STRATEGY_JOIN,
<del> self::STRATEGY_SELECT
<add> self::STRATEGY_SELECT,
<ide> ];
<ide>
<ide> /**
<ide> public function eagerLoader(array $options)
<ide> 'bindingKey' => $this->getBindingKey(),
<ide> 'strategy' => $this->getStrategy(),
<ide> 'associationType' => $this->type(),
<del> 'finder' => [$this, 'find']
<add> 'finder' => [$this, 'find'],
<ide> ]);
<ide>
<ide> return $loader->buildEagerLoader($options);
<ide><path>src/ORM/Association/Loader/SelectLoader.php
<ide> protected function _defaultOptions()
<ide> 'conditions' => [],
<ide> 'strategy' => $this->strategy,
<ide> 'nestKey' => $this->alias,
<del> 'sort' => $this->sort
<add> 'sort' => $this->sort,
<ide> ];
<ide> }
<ide>
<ide><path>src/ORM/AssociationCollection.php
<ide> public function add($alias, Association $association)
<ide> public function load($className, $associated, array $options = [])
<ide> {
<ide> $options += [
<del> 'tableLocator' => $this->getTableLocator()
<add> 'tableLocator' => $this->getTableLocator(),
<ide> ];
<ide>
<ide> $association = new $className($associated, $options);
<ide><path>src/ORM/Behavior.php
<ide> public function implementedEvents()
<ide> } else {
<ide> $events[$event] = [
<ide> 'callable' => $method,
<del> 'priority' => $priority
<add> 'priority' => $priority,
<ide> ];
<ide> }
<ide> }
<ide> protected function _reflectionCache()
<ide>
<ide> $return = [
<ide> 'finders' => [],
<del> 'methods' => []
<add> 'methods' => [],
<ide> ];
<ide>
<ide> $reflection = new ReflectionClass($class);
<ide><path>src/ORM/Behavior/TimestampBehavior.php
<ide> class TimestampBehavior extends Behavior
<ide> 'implementedFinders' => [],
<ide> 'implementedMethods' => [
<ide> 'timestamp' => 'timestamp',
<del> 'touch' => 'touch'
<add> 'touch' => 'touch',
<ide> ],
<ide> 'events' => [
<ide> 'Model.beforeSave' => [
<ide> 'created' => 'new',
<del> 'modified' => 'always'
<del> ]
<add> 'modified' => 'always',
<add> ],
<ide> ],
<del> 'refreshTimestamp' => true
<add> 'refreshTimestamp' => true,
<ide> ];
<ide>
<ide> /**
<ide><path>src/ORM/Behavior/TranslateBehavior.php
<ide> class TranslateBehavior extends Behavior implements PropertyMarshalInterface
<ide> 'setLocale' => 'setLocale',
<ide> 'getLocale' => 'getLocale',
<ide> 'locale' => 'locale',
<del> 'translationField' => 'translationField'
<add> 'translationField' => 'translationField',
<ide> ],
<ide> 'fields' => [],
<ide> 'translationTable' => 'I18n',
<ide> class TranslateBehavior extends Behavior implements PropertyMarshalInterface
<ide> 'onlyTranslated' => false,
<ide> 'strategy' => 'subquery',
<ide> 'tableLocator' => null,
<del> 'validator' => false
<add> 'validator' => false,
<ide> ];
<ide>
<ide> /**
<ide> public function __construct(Table $table, array $config = [])
<ide> {
<ide> $config += [
<ide> 'defaultLocale' => I18n::getDefaultLocale(),
<del> 'referenceName' => $this->_referenceName($table)
<add> 'referenceName' => $this->_referenceName($table),
<ide> ];
<ide>
<ide> if (isset($config['tableLocator'])) {
<ide> public function setupFieldAssociations($fields, $table, $model, $strategy)
<ide> $fieldTable = $tableLocator->get($name, [
<ide> 'className' => $table,
<ide> 'alias' => $name,
<del> 'table' => $this->_translationTable->getTable()
<add> 'table' => $this->_translationTable->getTable(),
<ide> ]);
<ide> } else {
<ide> $fieldTable = $tableLocator->get($name);
<ide> public function setupFieldAssociations($fields, $table, $model, $strategy)
<ide> 'foreignKey' => 'foreign_key',
<ide> 'joinType' => $filter ? QueryInterface::JOIN_TYPE_INNER : QueryInterface::JOIN_TYPE_LEFT,
<ide> 'conditions' => $conditions,
<del> 'propertyName' => $field . '_translation'
<add> 'propertyName' => $field . '_translation',
<ide> ]);
<ide> }
<ide>
<ide> public function setupFieldAssociations($fields, $table, $model, $strategy)
<ide> 'strategy' => $strategy,
<ide> 'conditions' => $conditions,
<ide> 'propertyName' => '_i18n',
<del> 'dependent' => true
<add> 'dependent' => true,
<ide> ]);
<ide> }
<ide>
<ide> public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $o
<ide> 'field IN' => $fields,
<ide> 'locale' => $locale,
<ide> 'foreign_key' => $key,
<del> 'model' => $model
<add> 'model' => $model,
<ide> ])
<ide> ->disableBufferedResults()
<ide> ->all()
<ide> public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $o
<ide> foreach ($new as $field => $content) {
<ide> $new[$field] = new Entity(compact('locale', 'field', 'content', 'model'), [
<ide> 'useSetters' => false,
<del> 'markNew' => true
<add> 'markNew' => true,
<ide> ]);
<ide> }
<ide>
<ide> public function buildMarshalMap($marshaller, $map, $options)
<ide> }
<ide>
<ide> return $translations;
<del> }
<add> },
<ide> ];
<ide> }
<ide>
<ide> public function groupTranslations($results)
<ide> $translation = new $entityClass($keys + ['locale' => $locale], [
<ide> 'markNew' => false,
<ide> 'useSetters' => false,
<del> 'markClean' => true
<add> 'markClean' => true,
<ide> ]);
<ide> $result[$locale] = $translation;
<ide> }
<ide> protected function _bundleTranslatedFields($entity)
<ide> }
<ide> $find[] = ['locale' => $lang, 'field' => $field, 'foreign_key' => $key];
<ide> $contents[] = new Entity(['content' => $translation->get($field)], [
<del> 'useSetters' => false
<add> 'useSetters' => false,
<ide> ]);
<ide> }
<ide> }
<ide><path>src/ORM/BehaviorRegistry.php
<ide> protected function _throwMissingClassError($class, $plugin)
<ide> {
<ide> throw new MissingBehaviorException([
<ide> 'class' => $class . 'Behavior',
<del> 'plugin' => $plugin
<add> 'plugin' => $plugin,
<ide> ]);
<ide> }
<ide>
<ide><path>src/ORM/EagerLoadable.php
<ide> public function __construct($name, array $config = [])
<ide> $this->_name = $name;
<ide> $allowed = [
<ide> 'associations', 'instance', 'config', 'canBeJoined',
<del> 'aliasPath', 'propertyPath', 'forMatching', 'targetProperty'
<add> 'aliasPath', 'propertyPath', 'forMatching', 'targetProperty',
<ide> ];
<ide> foreach ($allowed as $property) {
<ide> if (isset($config[$property])) {
<ide> public function asContainArray()
<ide> return [
<ide> $this->_name => [
<ide> 'associations' => $associations,
<del> 'config' => $config
<del> ]
<add> 'config' => $config,
<add> ],
<ide> ];
<ide> }
<ide> }
<ide><path>src/ORM/EagerLoader.php
<ide> class EagerLoader
<ide> 'finder' => 1,
<ide> 'joinType' => 1,
<ide> 'strategy' => 1,
<del> 'negateMatch' => 1
<add> 'negateMatch' => 1,
<ide> ];
<ide>
<ide> /**
<ide> public function contain($associations = [], callable $queryBuilder = null)
<ide>
<ide> $associations = [
<ide> $associations => [
<del> 'queryBuilder' => $queryBuilder
<del> ]
<add> 'queryBuilder' => $queryBuilder,
<add> ],
<ide> ];
<ide> }
<ide>
<ide> protected function _normalizeContain(Table $parent, $alias, $options, $paths)
<ide> 'config' => array_diff_key($options, $extra),
<ide> 'aliasPath' => trim($paths['aliasPath'], '.'),
<ide> 'propertyPath' => trim($paths['propertyPath'], '.'),
<del> 'targetProperty' => $instance->getProperty()
<add> 'targetProperty' => $instance->getProperty(),
<ide> ];
<ide> $config['canBeJoined'] = $instance->canBeJoined($config['config']);
<ide> $eagerLoadable = new EagerLoadable($alias, $config);
<ide> public function loadExternal($query, $statement)
<ide> 'query' => $query,
<ide> 'contain' => $contain,
<ide> 'keys' => $keys,
<del> 'nestKey' => $meta->aliasPath()
<add> 'nestKey' => $meta->aliasPath(),
<ide> ]
<ide> );
<ide> $statement = new CallbackStatement($statement, $driver, $f);
<ide> protected function _buildAssociationsMap($map, $level, $matching = false)
<ide> 'entityClass' => $instance->getTarget()->getEntityClass(),
<ide> 'nestKey' => $canBeJoined ? $assoc : $meta->aliasPath(),
<ide> 'matching' => $forMatching !== null ? $forMatching : $matching,
<del> 'targetProperty' => $meta->targetProperty()
<add> 'targetProperty' => $meta->targetProperty(),
<ide> ];
<ide> if ($canBeJoined && $associations) {
<ide> $map = $this->_buildAssociationsMap($map, $associations, $matching);
<ide> public function addToJoinsMap($alias, Association $assoc, $asMatching = false, $
<ide> 'instance' => $assoc,
<ide> 'canBeJoined' => true,
<ide> 'forMatching' => $asMatching,
<del> 'targetProperty' => $targetProperty ?: $assoc->getProperty()
<add> 'targetProperty' => $targetProperty ?: $assoc->getProperty(),
<ide> ]);
<ide> }
<ide>
<ide><path>src/ORM/Entity.php
<ide> public function __construct(array $properties = [], array $options = [])
<ide> 'markClean' => false,
<ide> 'markNew' => null,
<ide> 'guard' => false,
<del> 'source' => null
<add> 'source' => null,
<ide> ];
<ide>
<ide> if (!empty($options['source'])) {
<ide> public function __construct(array $properties = [], array $options = [])
<ide> if (!empty($properties)) {
<ide> $this->set($properties, [
<ide> 'setter' => $options['useSetters'],
<del> 'guard' => $options['guard']
<add> 'guard' => $options['guard'],
<ide> ]);
<ide> }
<ide>
<ide><path>src/ORM/Query.php
<ide> public function leftJoinWith($assoc, callable $builder = null)
<ide> $result = $this->getEagerLoader()
<ide> ->setMatching($assoc, $builder, [
<ide> 'joinType' => QueryInterface::JOIN_TYPE_LEFT,
<del> 'fields' => false
<add> 'fields' => false,
<ide> ])
<ide> ->getMatching();
<ide> $this->_addAssociationsToTypeMap($this->getRepository(), $this->getTypeMap(), $result);
<ide> public function innerJoinWith($assoc, callable $builder = null)
<ide> $result = $this->getEagerLoader()
<ide> ->setMatching($assoc, $builder, [
<ide> 'joinType' => QueryInterface::JOIN_TYPE_INNER,
<del> 'fields' => false
<add> 'fields' => false,
<ide> ])
<ide> ->getMatching();
<ide> $this->_addAssociationsToTypeMap($this->getRepository(), $this->getTypeMap(), $result);
<ide> public function notMatching($assoc, callable $builder = null)
<ide> ->setMatching($assoc, $builder, [
<ide> 'joinType' => QueryInterface::JOIN_TYPE_LEFT,
<ide> 'fields' => false,
<del> 'negateMatch' => true
<add> 'negateMatch' => true,
<ide> ])
<ide> ->getMatching();
<ide> $this->_addAssociationsToTypeMap($this->getRepository(), $this->getTypeMap(), $result);
<ide> public function triggerBeforeFind()
<ide> $repository->dispatchEvent('Model.beforeFind', [
<ide> $this,
<ide> new ArrayObject($this->_options),
<del> !$this->isEagerLoaded()
<add> !$this->isEagerLoaded(),
<ide> ]);
<ide> }
<ide> }
<ide> public function __debugInfo()
<ide> 'contain' => $eagerLoader ? $eagerLoader->getContain() : [],
<ide> 'matching' => $eagerLoader ? $eagerLoader->getMatching() : [],
<ide> 'extraOptions' => $this->_options,
<del> 'repository' => $this->_repository
<add> 'repository' => $this->_repository,
<ide> ];
<ide> }
<ide>
<ide><path>src/ORM/ResultSet.php
<ide> protected function _groupResult($row)
<ide> 'useSetters' => false,
<ide> 'markClean' => true,
<ide> 'markNew' => false,
<del> 'guard' => false
<add> 'guard' => false,
<ide> ];
<ide>
<ide> foreach ($this->_matchingMapColumns as $alias => $keys) {
<ide><path>src/ORM/Table.php
<ide> public function findList(Query $query, array $options)
<ide> $options += [
<ide> 'keyField' => $this->getPrimaryKey(),
<ide> 'valueField' => $this->getDisplayField(),
<del> 'groupField' => null
<add> 'groupField' => null,
<ide> ];
<ide>
<ide> if (isset($options['idField'])) {
<ide> public function findThreaded(Query $query, array $options)
<ide> $options += [
<ide> 'keyField' => $this->getPrimaryKey(),
<ide> 'parentField' => 'parent_id',
<del> 'nestingKey' => 'children'
<add> 'nestingKey' => 'children',
<ide> ];
<ide>
<ide> if (isset($options['idField'])) {
<ide> public function save(EntityInterface $entity, $options = [])
<ide> 'associated' => true,
<ide> 'checkRules' => true,
<ide> 'checkExisting' => true,
<del> '_primary' => true
<add> '_primary' => true,
<ide> ]);
<ide>
<ide> if ($entity->hasErrors($options['associated'])) {
<ide> public function delete(EntityInterface $entity, $options = [])
<ide> if ($success && $this->_transactionCommitted($options['atomic'], $options['_primary'])) {
<ide> $this->dispatchEvent('Model.afterDeleteCommit', [
<ide> 'entity' => $entity,
<del> 'options' => $options
<add> 'options' => $options,
<ide> ]);
<ide> }
<ide>
<ide> protected function _processDelete($entity, $options)
<ide>
<ide> $event = $this->dispatchEvent('Model.beforeDelete', [
<ide> 'entity' => $entity,
<del> 'options' => $options
<add> 'options' => $options,
<ide> ]);
<ide>
<ide> if ($event->isStopped()) {
<ide> protected function _processDelete($entity, $options)
<ide>
<ide> $this->dispatchEvent('Model.afterDelete', [
<ide> 'entity' => $entity,
<del> 'options' => $options
<add> 'options' => $options,
<ide> ]);
<ide>
<ide> return $success;
<ide> protected function _dynamicFinder($method, $args)
<ide> } elseif ($hasOr !== false) {
<ide> $fields = explode('_or_', $fields);
<ide> $conditions = [
<del> 'OR' => $makeConditions($fields, $args)
<add> 'OR' => $makeConditions($fields, $args),
<ide> ];
<ide> } elseif ($hasAnd !== false) {
<ide> $fields = explode('_and_', $fields);
<ide> public function validateUnique($value, array $options, array $context = null)
<ide> [
<ide> 'useSetters' => false,
<ide> 'markNew' => $context['newRecord'],
<del> 'source' => $this->getRegistryAlias()
<add> 'source' => $this->getRegistryAlias(),
<ide> ]
<ide> );
<ide> $fields = array_merge(
<ide> public function __debugInfo()
<ide> 'associations' => $associations ? $associations->keys() : false,
<ide> 'behaviors' => $behaviors ? $behaviors->loaded() : false,
<ide> 'defaultConnection' => static::defaultConnectionName(),
<del> 'connectionName' => $conn ? $conn->configName() : null
<add> 'connectionName' => $conn ? $conn->configName() : null,
<ide> ];
<ide> }
<ide> }
<ide><path>src/Routing/DispatcherFilter.php
<ide> public function implementedEvents()
<ide> return [
<ide> 'Dispatcher.beforeDispatch' => [
<ide> 'callable' => 'handle',
<del> 'priority' => $this->_config['priority']
<add> 'priority' => $this->_config['priority'],
<ide> ],
<ide> 'Dispatcher.afterDispatch' => [
<ide> 'callable' => 'handle',
<del> 'priority' => $this->_config['priority']
<add> 'priority' => $this->_config['priority'],
<ide> ],
<ide> ];
<ide> }
<ide><path>src/Routing/RequestActionTrait.php
<ide> public function requestAction($url, array $extra = [])
<ide> }
<ide> if (is_string($url)) {
<ide> $params = [
<del> 'url' => $url
<add> 'url' => $url,
<ide> ];
<ide> } elseif (is_array($url)) {
<ide> $defaultParams = ['plugin' => null, 'controller' => null, 'action' => null];
<ide> $params = [
<ide> 'params' => $url + $defaultParams,
<ide> 'base' => false,
<del> 'url' => Router::reverse($url)
<add> 'url' => Router::reverse($url),
<ide> ];
<ide> if (empty($params['params']['pass'])) {
<ide> $params['params']['pass'] = [];
<ide> public function requestAction($url, array $extra = [])
<ide> // we need to 'fix' their missing dispatcher filters.
<ide> $needed = [
<ide> 'routing' => RoutingFilter::class,
<del> 'controller' => ControllerFactoryFilter::class
<add> 'controller' => ControllerFactoryFilter::class,
<ide> ];
<ide> foreach ($dispatcher->filters() as $filter) {
<ide> if ($filter instanceof RoutingFilter) {
<ide><path>src/Routing/Route/Route.php
<ide> public function getName()
<ide> 'prefix' => ':',
<ide> 'plugin' => '.',
<ide> 'controller' => ':',
<del> 'action' => ''
<add> 'action' => '',
<ide> ];
<ide> foreach ($keys as $key => $glue) {
<ide> $value = null;
<ide><path>src/Routing/Router.php
<ide> class Router
<ide> 'Month' => Router::MONTH,
<ide> 'Day' => Router::DAY,
<ide> 'ID' => Router::ID,
<del> 'UUID' => Router::UUID
<add> 'UUID' => Router::UUID,
<ide> ];
<ide>
<ide> /**
<ide> public static function setRequestInfo($request)
<ide> $requestData[0] += [
<ide> 'controller' => false,
<ide> 'action' => false,
<del> 'plugin' => null
<add> 'plugin' => null,
<ide> ];
<ide> $request = new ServerRequest([
<ide> 'params' => $requestData[0],
<ide> public static function url($url = null, $full = false)
<ide> 'plugin' => $params['plugin'],
<ide> 'controller' => $params['controller'],
<ide> 'action' => 'index',
<del> '_ext' => null
<add> '_ext' => null,
<ide> ];
<ide> }
<ide>
<ide> public static function parseNamedParams(ServerRequest $request, array $options =
<ide> $arr = [$arr];
<ide> } else {
<ide> $arr = [
<del> $match[1] => $arr
<add> $match[1] => $arr,
<ide> ];
<ide> }
<ide> }
<ide><path>src/Shell/CacheShell.php
<ide> public function getOptionParser()
<ide> 'description' => [
<ide> 'Clear the cache for a particular prefix.',
<ide> 'For example, `cake cache clear _cake_model_` will clear the model cache',
<del> 'Use `cake cache list_prefixes` to list available prefixes'
<add> 'Use `cake cache list_prefixes` to list available prefixes',
<ide> ],
<ide> 'arguments' => [
<ide> 'prefix' => [
<ide> 'help' => 'The cache prefix to be cleared.',
<del> 'required' => true
<del> ]
<del> ]
<del> ]
<add> 'required' => true,
<add> ],
<add> ],
<add> ],
<ide> ]);
<ide>
<ide> return $parser;
<ide><path>src/Shell/CommandListShell.php
<ide> public function getOptionParser()
<ide> 'Get the list of available shells for this CakePHP application.'
<ide> )->addOption('xml', [
<ide> 'help' => 'Get the listing as XML.',
<del> 'boolean' => true
<add> 'boolean' => true,
<ide> ])->addOption('version', [
<ide> 'help' => 'Prints the currently installed version of CakePHP. (deprecated - use `cake --version` instead)',
<del> 'boolean' => true
<add> 'boolean' => true,
<ide> ]);
<ide>
<ide> return $parser;
<ide><path>src/Shell/CompletionShell.php
<ide> public function getOptionParser()
<ide> 'help' => 'Output a list of available commands',
<ide> 'parser' => [
<ide> 'description' => 'List all available',
<del> ]
<add> ],
<ide> ])->addSubcommand('subcommands', [
<ide> 'help' => 'Output a list of available subcommands',
<ide> 'parser' => [
<ide> public function getOptionParser()
<ide> 'command' => [
<ide> 'help' => 'The command name',
<ide> 'required' => false,
<del> ]
<del> ]
<del> ]
<add> ],
<add> ],
<add> ],
<ide> ])->addSubcommand('options', [
<ide> 'help' => 'Output a list of available options',
<ide> 'parser' => [
<ide> public function getOptionParser()
<ide> 'subcommand' => [
<ide> 'help' => 'The subcommand name',
<ide> 'required' => false,
<del> ]
<del> ]
<del> ]
<add> ],
<add> ],
<add> ],
<ide> ])->addSubcommand('fuzzy', [
<del> 'help' => 'Guess autocomplete'
<add> 'help' => 'Guess autocomplete',
<ide> ])->setEpilog([
<ide> 'This command is not intended to be called manually',
<ide> ]);
<ide><path>src/Shell/I18nShell.php
<ide> public function getOptionParser()
<ide> 'options' => [
<ide> 'plugin' => [
<ide> 'help' => 'Plugin name.',
<del> 'short' => 'p'
<add> 'short' => 'p',
<ide> ],
<ide> 'force' => [
<ide> 'help' => 'Force overwriting.',
<ide> 'short' => 'f',
<del> 'boolean' => true
<del> ]
<add> 'boolean' => true,
<add> ],
<ide> ],
<ide> 'arguments' => [
<ide> 'language' => [
<del> 'help' => 'Two-letter language code.'
<del> ]
<del> ]
<add> 'help' => 'Two-letter language code.',
<add> ],
<add> ],
<ide> ];
<ide>
<ide> $parser->setDescription(
<ide> 'I18n Shell generates .pot files(s) with translations.'
<ide> )->addSubcommand('extract', [
<ide> 'help' => 'Extract the po translations from your application',
<del> 'parser' => $this->Extract->getOptionParser()
<add> 'parser' => $this->Extract->getOptionParser(),
<ide> ])
<ide> ->addSubcommand('init', [
<ide> 'help' => 'Init PO language file from POT file',
<del> 'parser' => $initParser
<add> 'parser' => $initParser,
<ide> ]);
<ide>
<ide> return $parser;
<ide><path>src/Shell/PluginShell.php
<ide> public function getOptionParser()
<ide> $parser->setDescription('Plugin Shell perform various tasks related to plugin.')
<ide> ->addSubcommand('assets', [
<ide> 'help' => 'Symlink / copy plugin assets to app\'s webroot',
<del> 'parser' => $this->Assets->getOptionParser()
<add> 'parser' => $this->Assets->getOptionParser(),
<ide> ])
<ide> ->addSubcommand('loaded', [
<ide> 'help' => 'Lists all loaded plugins',
<ide><path>src/Shell/RoutesShell.php
<ide> class RoutesShell extends Shell
<ide> public function main()
<ide> {
<ide> $output = [
<del> ['Route name', 'URI template', 'Defaults']
<add> ['Route name', 'URI template', 'Defaults'],
<ide> ];
<ide> foreach (Router::routes() as $route) {
<ide> $name = isset($route->options['_name']) ? $route->options['_name'] : $route->getName();
<ide> public function check($url)
<ide>
<ide> $output = [
<ide> ['Route name', 'URI template', 'Defaults'],
<del> [$name, $url, json_encode($route)]
<add> [$name, $url, json_encode($route)],
<ide> ];
<ide> $this->helper('table')->output($output);
<ide> $this->out();
<ide> public function getOptionParser()
<ide> 'This tool also lets you test URL generation and URL parsing.'
<ide> )->addSubcommand('check', [
<ide> 'help' => 'Check a URL string against the routes. ' .
<del> 'Will output the routing parameters the route resolves to.'
<add> 'Will output the routing parameters the route resolves to.',
<ide> ])->addSubcommand('generate', [
<ide> 'help' => 'Check a routing array against the routes. ' .
<ide> "Will output the URL if there is a match.\n\n" .
<ide> 'Routing parameters should be supplied in a key:value format. ' .
<del> 'For example `controller:Articles action:view 2`'
<add> 'For example `controller:Articles action:view 2`',
<ide> ]);
<ide>
<ide> return $parser;
<ide><path>src/Shell/ServerShell.php
<ide> public function getOptionParser()
<ide> '<warning>[WARN] Don\'t use this in a production environment</warning>',
<ide> ])->addOption('host', [
<ide> 'short' => 'H',
<del> 'help' => 'ServerHost'
<add> 'help' => 'ServerHost',
<ide> ])->addOption('port', [
<ide> 'short' => 'p',
<del> 'help' => 'ListenPort'
<add> 'help' => 'ListenPort',
<ide> ])->addOption('ini_path', [
<ide> 'short' => 'I',
<del> 'help' => 'php.ini path'
<add> 'help' => 'php.ini path',
<ide> ])->addOption('document_root', [
<ide> 'short' => 'd',
<del> 'help' => 'DocumentRoot'
<add> 'help' => 'DocumentRoot',
<ide> ]);
<ide>
<ide> return $parser;
<ide><path>src/Shell/Task/AssetsTask.php
<ide> protected function _list($name = null)
<ide> 'srcPath' => Plugin::path($plugin) . 'webroot',
<ide> 'destDir' => $dir,
<ide> 'link' => $link,
<del> 'namespaced' => $namespaced
<add> 'namespaced' => $namespaced,
<ide> ];
<ide> }
<ide>
<ide> public function getOptionParser()
<ide> $parser = parent::getOptionParser();
<ide>
<ide> $parser->addSubcommand('symlink', [
<del> 'help' => 'Symlink (copy as fallback) plugin assets to app\'s webroot.'
<add> 'help' => 'Symlink (copy as fallback) plugin assets to app\'s webroot.',
<ide> ])->addSubcommand('copy', [
<del> 'help' => 'Copy plugin assets to app\'s webroot.'
<add> 'help' => 'Copy plugin assets to app\'s webroot.',
<ide> ])->addSubcommand('remove', [
<del> 'help' => 'Remove plugin assets from app\'s webroot.'
<add> 'help' => 'Remove plugin assets from app\'s webroot.',
<ide> ])->addArgument('name', [
<ide> 'help' => 'A specific plugin you want to symlink assets for.',
<ide> 'optional' => true,
<ide> ])->addOption('overwrite', [
<ide> 'help' => 'Overwrite existing symlink / folder / files.',
<ide> 'default' => false,
<del> 'boolean' => true
<add> 'boolean' => true,
<ide> ]);
<ide>
<ide> return $parser;
<ide><path>src/Shell/Task/ExtractTask.php
<ide> protected function _addTranslation($domain, $msgid, $details = [])
<ide>
<ide> if (empty($this->_translations[$domain][$msgid][$context])) {
<ide> $this->_translations[$domain][$msgid][$context] = [
<del> 'msgid_plural' => false
<add> 'msgid_plural' => false,
<ide> ];
<ide> }
<ide>
<ide> public function getOptionParser()
<ide> $parser->setDescription(
<ide> 'CakePHP Language String Extraction:'
<ide> )->addOption('app', [
<del> 'help' => 'Directory where your application is located.'
<add> 'help' => 'Directory where your application is located.',
<ide> ])->addOption('paths', [
<del> 'help' => 'Comma separated list of paths.'
<add> 'help' => 'Comma separated list of paths.',
<ide> ])->addOption('merge', [
<ide> 'help' => 'Merge all domain strings into the default.po file.',
<del> 'choices' => ['yes', 'no']
<add> 'choices' => ['yes', 'no'],
<ide> ])->addOption('relative-paths', [
<ide> 'help' => 'Use relative paths in the .pot file',
<ide> 'boolean' => true,
<ide> 'default' => false,
<ide> ])->addOption('output', [
<del> 'help' => 'Full path to output directory.'
<add> 'help' => 'Full path to output directory.',
<ide> ])->addOption('files', [
<del> 'help' => 'Comma separated list of files.'
<add> 'help' => 'Comma separated list of files.',
<ide> ])->addOption('exclude-plugins', [
<ide> 'boolean' => true,
<ide> 'default' => true,
<del> 'help' => 'Ignores all files in plugins if this command is run inside from the same app directory.'
<add> 'help' => 'Ignores all files in plugins if this command is run inside from the same app directory.',
<ide> ])->addOption('plugin', [
<ide> 'help' => 'Extracts tokens only from the plugin specified and puts the result in the plugin\'s Locale directory.',
<ide> 'short' => 'p',
<ide> public function getOptionParser()
<ide> 'default' => false,
<ide> 'help' => 'Ignores validation messages in the $validate property.' .
<ide> ' If this flag is not set and the command is run from the same app directory,' .
<del> ' all messages in model validation rules will be extracted as tokens.'
<add> ' all messages in model validation rules will be extracted as tokens.',
<ide> ])->addOption('validation-domain', [
<del> 'help' => 'If set to a value, the localization domain to be used for model validation messages.'
<add> 'help' => 'If set to a value, the localization domain to be used for model validation messages.',
<ide> ])->addOption('exclude', [
<ide> 'help' => 'Comma separated list of directories to exclude.' .
<del> ' Any path containing a path segment with the provided values will be skipped. E.g. test,vendors'
<add> ' Any path containing a path segment with the provided values will be skipped. E.g. test,vendors',
<ide> ])->addOption('overwrite', [
<ide> 'boolean' => true,
<ide> 'default' => false,
<del> 'help' => 'Always overwrite existing .pot files.'
<add> 'help' => 'Always overwrite existing .pot files.',
<ide> ])->addOption('extract-core', [
<ide> 'help' => 'Extract messages from the CakePHP core libs.',
<del> 'choices' => ['yes', 'no']
<add> 'choices' => ['yes', 'no'],
<ide> ])->addOption('no-location', [
<ide> 'boolean' => true,
<ide> 'default' => false,
<ide><path>src/TestSuite/Fixture/FixtureManager.php
<ide> protected function _loadFixtures($test)
<ide> $baseNamespace,
<ide> 'Test\Fixture',
<ide> $additionalPath,
<del> $name . 'Fixture'
<add> $name . 'Fixture',
<ide> ];
<ide> $className = implode('\\', array_filter($nameSegments));
<ide> } else {
<ide><path>src/Utility/Hash.php
<ide> public static function expand(array $data, $separator = '.')
<ide> $keys = explode($separator, $flat);
<ide> $keys = array_reverse($keys);
<ide> $child = [
<del> $keys[0] => $value
<add> $keys[0] => $value,
<ide> ];
<ide> array_shift($keys);
<ide> foreach ($keys as $k) {
<ide> $child = [
<del> $k => $child
<add> $k => $child,
<ide> ];
<ide> }
<ide>
<ide> public static function nest(array $data, array $options = [])
<ide> 'idPath' => "{n}.$alias.id",
<ide> 'parentPath' => "{n}.$alias.parent_id",
<ide> 'children' => 'children',
<del> 'root' => null
<add> 'root' => null,
<ide> ];
<ide>
<ide> $return = $idMap = [];
<ide><path>src/Utility/Inflector.php
<ide> class Inflector
<ide> '/(n)ews$/i' => '\1\2ews',
<ide> '/eaus$/' => 'eau',
<ide> '/^(.*us)$/' => '\\1',
<del> '/s$/i' => ''
<add> '/s$/i' => '',
<ide> ];
<ide>
<ide> /**
<ide> class Inflector
<ide> '.*pox', '.*sheep', 'people', 'feedback', 'stadia', '.*?media',
<ide> 'chassis', 'clippers', 'debris', 'diabetes', 'equipment', 'gallows',
<ide> 'graffiti', 'headquarters', 'information', 'innings', 'news', 'nexus',
<del> 'pokemon', 'proceedings', 'research', 'sea[- ]bass', 'series', 'species', 'weather'
<add> 'pokemon', 'proceedings', 'research', 'sea[- ]bass', 'series', 'species', 'weather',
<ide> ];
<ide>
<ide> /**
<ide><path>src/Utility/Text.php
<ide> class Text
<ide> */
<ide> protected static $_defaultHtmlNoCount = [
<ide> 'style',
<del> 'script'
<add> 'script',
<ide> ];
<ide>
<ide> /**
<ide> public static function tokenize($data, $separator = ',', $leftBound = '(', $righ
<ide> $offsets = [
<ide> mb_strpos($data, $separator, $offset),
<ide> mb_strpos($data, $leftBound, $offset),
<del> mb_strpos($data, $rightBound, $offset)
<add> mb_strpos($data, $rightBound, $offset),
<ide> ];
<ide> for ($i = 0; $i < 3; $i++) {
<ide> if ($offsets[$i] !== false && ($offsets[$i] < $tmpOffset || $tmpOffset == -1)) {
<ide> public static function tokenize($data, $separator = ',', $leftBound = '(', $righ
<ide> public static function insert($str, $data, array $options = [])
<ide> {
<ide> $defaults = [
<del> 'before' => ':', 'after' => null, 'escape' => '\\', 'format' => null, 'clean' => false
<add> 'before' => ':', 'after' => null, 'escape' => '\\', 'format' => null, 'clean' => false,
<ide> ];
<ide> $options += $defaults;
<ide> $format = $options['format'];
<ide> public static function stripLinks($text)
<ide> public static function tail($text, $length = 100, array $options = [])
<ide> {
<ide> $default = [
<del> 'ellipsis' => '...', 'exact' => true
<add> 'ellipsis' => '...', 'exact' => true,
<ide> ];
<ide> $options += $default;
<ide> $exact = $ellipsis = null;
<ide> public static function slug($string, $options = [])
<ide> $options += [
<ide> 'replacement' => '-',
<ide> 'transliteratorId' => null,
<del> 'preserve' => null
<add> 'preserve' => null,
<ide> ];
<ide>
<ide> if ($options['transliteratorId'] !== false) {
<ide><path>src/Utility/Xml.php
<ide> public static function fromArray($input, $options = [])
<ide> 'version' => '1.0',
<ide> 'encoding' => mb_internal_encoding(),
<ide> 'return' => 'simplexml',
<del> 'pretty' => false
<add> 'pretty' => false,
<ide> ];
<ide> $options += $defaults;
<ide>
<ide><path>src/Validation/Validation.php
<ide> public static function creditCard($check, $type = 'fast', $deep = false, $regex
<ide> 'solo' => '/^(6334[5-9][0-9]|6767[0-9]{2})\\d{10}(\\d{2,3})?$/',
<ide> 'switch' => '/^(?:49(03(0[2-9]|3[5-9])|11(0[1-2]|7[4-9]|8[1-2])|36[0-9]{2})\\d{10}(\\d{2,3})?)|(?:564182\\d{10}(\\d{2,3})?)|(6(3(33[0-4][0-9])|759[0-9]{2})\\d{10}(\\d{2,3})?)$/',
<ide> 'visa' => '/^4\\d{12}(\\d{3})?$/',
<del> 'voyager' => '/^8699[0-9]{11}$/'
<add> 'voyager' => '/^8699[0-9]{11}$/',
<ide> ],
<del> 'fast' => '/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$/'
<add> 'fast' => '/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$/',
<ide> ];
<ide>
<ide> if (is_array($type)) {
<ide> public static function imageWidth($file, $operator, $width)
<ide> return self::imageSize($file, [
<ide> 'width' => [
<ide> $operator,
<del> $width
<del> ]
<add> $width,
<add> ],
<ide> ]);
<ide> }
<ide>
<ide> public static function imageHeight($file, $operator, $height)
<ide> return self::imageSize($file, [
<ide> 'height' => [
<ide> $operator,
<del> $height
<del> ]
<add> $height,
<add> ],
<ide> ]);
<ide> }
<ide>
<ide> public static function geoCoordinate($value, array $options = [])
<ide> {
<ide> $options += [
<ide> 'format' => 'both',
<del> 'type' => 'latLong'
<add> 'type' => 'latLong',
<ide> ];
<ide> if ($options['type'] !== 'latLong') {
<ide> throw new RuntimeException(sprintf(
<ide><path>src/Validation/Validator.php
<ide> public function requirePresence($field, $mode = true, $message = null)
<ide> {
<ide> $defaults = [
<ide> 'mode' => $mode,
<del> 'message' => $message
<add> 'message' => $message,
<ide> ];
<ide>
<ide> if (!is_array($field)) {
<ide> public function notEmpty($field, $message = null, $when = false)
<ide> {
<ide> $defaults = [
<ide> 'when' => $when,
<del> 'message' => $message
<add> 'message' => $message,
<ide> ];
<ide>
<ide> if (!is_array($field)) {
<ide> public function greaterThan($field, $value, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'greaterThan', $extra + [
<del> 'rule' => ['comparison', Validation::COMPARE_GREATER, $value]
<add> 'rule' => ['comparison', Validation::COMPARE_GREATER, $value],
<ide> ]);
<ide> }
<ide>
<ide> public function greaterThanOrEqual($field, $value, $message = null, $when = null
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'greaterThanOrEqual', $extra + [
<del> 'rule' => ['comparison', Validation::COMPARE_GREATER_OR_EQUAL, $value]
<add> 'rule' => ['comparison', Validation::COMPARE_GREATER_OR_EQUAL, $value],
<ide> ]);
<ide> }
<ide>
<ide> public function lessThan($field, $value, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'lessThan', $extra + [
<del> 'rule' => ['comparison', Validation::COMPARE_LESS, $value]
<add> 'rule' => ['comparison', Validation::COMPARE_LESS, $value],
<ide> ]);
<ide> }
<ide>
<ide> public function lessThanOrEqual($field, $value, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'lessThanOrEqual', $extra + [
<del> 'rule' => ['comparison', Validation::COMPARE_LESS_OR_EQUAL, $value]
<add> 'rule' => ['comparison', Validation::COMPARE_LESS_OR_EQUAL, $value],
<ide> ]);
<ide> }
<ide>
<ide> public function equals($field, $value, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'equals', $extra + [
<del> 'rule' => ['comparison', Validation::COMPARE_EQUAL, $value]
<add> 'rule' => ['comparison', Validation::COMPARE_EQUAL, $value],
<ide> ]);
<ide> }
<ide>
<ide> public function notEquals($field, $value, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'notEquals', $extra + [
<del> 'rule' => ['comparison', Validation::COMPARE_NOT_EQUAL, $value]
<add> 'rule' => ['comparison', Validation::COMPARE_NOT_EQUAL, $value],
<ide> ]);
<ide> }
<ide>
<ide> public function sameAs($field, $secondField, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'sameAs', $extra + [
<del> 'rule' => ['compareFields', $secondField, Validation::COMPARE_SAME]
<add> 'rule' => ['compareFields', $secondField, Validation::COMPARE_SAME],
<ide> ]);
<ide> }
<ide>
<ide> public function notSameAs($field, $secondField, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'notSameAs', $extra + [
<del> 'rule' => ['compareFields', $secondField, Validation::COMPARE_NOT_SAME]
<add> 'rule' => ['compareFields', $secondField, Validation::COMPARE_NOT_SAME],
<ide> ]);
<ide> }
<ide>
<ide> public function equalToField($field, $secondField, $message = null, $when = null
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'equalToField', $extra + [
<del> 'rule' => ['compareFields', $secondField, Validation::COMPARE_EQUAL]
<add> 'rule' => ['compareFields', $secondField, Validation::COMPARE_EQUAL],
<ide> ]);
<ide> }
<ide>
<ide> public function notEqualToField($field, $secondField, $message = null, $when = n
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'notEqualToField', $extra + [
<del> 'rule' => ['compareFields', $secondField, Validation::COMPARE_NOT_EQUAL]
<add> 'rule' => ['compareFields', $secondField, Validation::COMPARE_NOT_EQUAL],
<ide> ]);
<ide> }
<ide>
<ide> public function greaterThanField($field, $secondField, $message = null, $when =
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'greaterThanField', $extra + [
<del> 'rule' => ['compareFields', $secondField, Validation::COMPARE_GREATER]
<add> 'rule' => ['compareFields', $secondField, Validation::COMPARE_GREATER],
<ide> ]);
<ide> }
<ide>
<ide> public function greaterThanOrEqualToField($field, $secondField, $message = null,
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'greaterThanOrEqualToField', $extra + [
<del> 'rule' => ['compareFields', $secondField, Validation::COMPARE_GREATER_OR_EQUAL]
<add> 'rule' => ['compareFields', $secondField, Validation::COMPARE_GREATER_OR_EQUAL],
<ide> ]);
<ide> }
<ide>
<ide> public function lessThanField($field, $secondField, $message = null, $when = nul
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'lessThanField', $extra + [
<del> 'rule' => ['compareFields', $secondField, Validation::COMPARE_LESS]
<add> 'rule' => ['compareFields', $secondField, Validation::COMPARE_LESS],
<ide> ]);
<ide> }
<ide>
<ide> public function lessThanOrEqualToField($field, $secondField, $message = null, $w
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'lessThanOrEqualToField', $extra + [
<del> 'rule' => ['compareFields', $secondField, Validation::COMPARE_LESS_OR_EQUAL]
<add> 'rule' => ['compareFields', $secondField, Validation::COMPARE_LESS_OR_EQUAL],
<ide> ]);
<ide> }
<ide>
<ide> public function containsNonAlphaNumeric($field, $limit = 1, $message = null, $wh
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'containsNonAlphaNumeric', $extra + [
<del> 'rule' => ['containsNonAlphaNumeric', $limit]
<add> 'rule' => ['containsNonAlphaNumeric', $limit],
<ide> ]);
<ide> }
<ide>
<ide> public function date($field, $formats = ['ymd'], $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'date', $extra + [
<del> 'rule' => ['date', $formats]
<add> 'rule' => ['date', $formats],
<ide> ]);
<ide> }
<ide>
<ide> public function dateTime($field, $formats = ['ymd'], $message = null, $when = nu
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'dateTime', $extra + [
<del> 'rule' => ['datetime', $formats]
<add> 'rule' => ['datetime', $formats],
<ide> ]);
<ide> }
<ide>
<ide> public function time($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'time', $extra + [
<del> 'rule' => 'time'
<add> 'rule' => 'time',
<ide> ]);
<ide> }
<ide>
<ide> public function localizedTime($field, $type = 'datetime', $message = null, $when
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'localizedTime', $extra + [
<del> 'rule' => ['localizedTime', $type]
<add> 'rule' => ['localizedTime', $type],
<ide> ]);
<ide> }
<ide>
<ide> public function boolean($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'boolean', $extra + [
<del> 'rule' => 'boolean'
<add> 'rule' => 'boolean',
<ide> ]);
<ide> }
<ide>
<ide> public function decimal($field, $places = null, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'decimal', $extra + [
<del> 'rule' => ['decimal', $places]
<add> 'rule' => ['decimal', $places],
<ide> ]);
<ide> }
<ide>
<ide> public function email($field, $checkMX = false, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'email', $extra + [
<del> 'rule' => ['email', $checkMX]
<add> 'rule' => ['email', $checkMX],
<ide> ]);
<ide> }
<ide>
<ide> public function ip($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'ip', $extra + [
<del> 'rule' => 'ip'
<add> 'rule' => 'ip',
<ide> ]);
<ide> }
<ide>
<ide> public function ipv4($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'ipv4', $extra + [
<del> 'rule' => ['ip', 'ipv4']
<add> 'rule' => ['ip', 'ipv4'],
<ide> ]);
<ide> }
<ide>
<ide> public function ipv6($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'ipv6', $extra + [
<del> 'rule' => ['ip', 'ipv6']
<add> 'rule' => ['ip', 'ipv6'],
<ide> ]);
<ide> }
<ide>
<ide> public function minLength($field, $min, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'minLength', $extra + [
<del> 'rule' => ['minLength', $min]
<add> 'rule' => ['minLength', $min],
<ide> ]);
<ide> }
<ide>
<ide> public function minLengthBytes($field, $min, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'minLengthBytes', $extra + [
<del> 'rule' => ['minLengthBytes', $min]
<add> 'rule' => ['minLengthBytes', $min],
<ide> ]);
<ide> }
<ide>
<ide> public function maxLength($field, $max, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'maxLength', $extra + [
<del> 'rule' => ['maxLength', $max]
<add> 'rule' => ['maxLength', $max],
<ide> ]);
<ide> }
<ide>
<ide> public function maxLengthBytes($field, $max, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'maxLengthBytes', $extra + [
<del> 'rule' => ['maxLengthBytes', $max]
<add> 'rule' => ['maxLengthBytes', $max],
<ide> ]);
<ide> }
<ide>
<ide> public function numeric($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'numeric', $extra + [
<del> 'rule' => 'numeric'
<add> 'rule' => 'numeric',
<ide> ]);
<ide> }
<ide>
<ide> public function naturalNumber($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'naturalNumber', $extra + [
<del> 'rule' => ['naturalNumber', false]
<add> 'rule' => ['naturalNumber', false],
<ide> ]);
<ide> }
<ide>
<ide> public function nonNegativeInteger($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'nonNegativeInteger', $extra + [
<del> 'rule' => ['naturalNumber', true]
<add> 'rule' => ['naturalNumber', true],
<ide> ]);
<ide> }
<ide>
<ide> public function range($field, array $range, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'range', $extra + [
<del> 'rule' => ['range', array_shift($range), array_shift($range)]
<add> 'rule' => ['range', array_shift($range), array_shift($range)],
<ide> ]);
<ide> }
<ide>
<ide> public function url($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'url', $extra + [
<del> 'rule' => ['url', false]
<add> 'rule' => ['url', false],
<ide> ]);
<ide> }
<ide>
<ide> public function urlWithProtocol($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'urlWithProtocol', $extra + [
<del> 'rule' => ['url', true]
<add> 'rule' => ['url', true],
<ide> ]);
<ide> }
<ide>
<ide> public function inList($field, array $list, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'inList', $extra + [
<del> 'rule' => ['inList', $list]
<add> 'rule' => ['inList', $list],
<ide> ]);
<ide> }
<ide>
<ide> public function uuid($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'uuid', $extra + [
<del> 'rule' => 'uuid'
<add> 'rule' => 'uuid',
<ide> ]);
<ide> }
<ide>
<ide> public function uploadedFile($field, array $options, $message = null, $when = nu
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'uploadedFile', $extra + [
<del> 'rule' => ['uploadedFile', $options]
<add> 'rule' => ['uploadedFile', $options],
<ide> ]);
<ide> }
<ide>
<ide> public function latLong($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'latLong', $extra + [
<del> 'rule' => 'geoCoordinate'
<add> 'rule' => 'geoCoordinate',
<ide> ]);
<ide> }
<ide>
<ide> public function latitude($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'latitude', $extra + [
<del> 'rule' => 'latitude'
<add> 'rule' => 'latitude',
<ide> ]);
<ide> }
<ide>
<ide> public function longitude($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'longitude', $extra + [
<del> 'rule' => 'longitude'
<add> 'rule' => 'longitude',
<ide> ]);
<ide> }
<ide>
<ide> public function ascii($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'ascii', $extra + [
<del> 'rule' => 'ascii'
<add> 'rule' => 'ascii',
<ide> ]);
<ide> }
<ide>
<ide> public function utf8($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'utf8', $extra + [
<del> 'rule' => ['utf8', ['extended' => false]]
<add> 'rule' => ['utf8', ['extended' => false]],
<ide> ]);
<ide> }
<ide>
<ide> public function utf8Extended($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'utf8Extended', $extra + [
<del> 'rule' => ['utf8', ['extended' => true]]
<add> 'rule' => ['utf8', ['extended' => true]],
<ide> ]);
<ide> }
<ide>
<ide> public function integer($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'integer', $extra + [
<del> 'rule' => 'isInteger'
<add> 'rule' => 'isInteger',
<ide> ]);
<ide> }
<ide>
<ide> public function isArray($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'isArray', $extra + [
<del> 'rule' => 'isArray'
<add> 'rule' => 'isArray',
<ide> ]);
<ide> }
<ide>
<ide> public function scalar($field, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'scalar', $extra + [
<del> 'rule' => 'isScalar'
<add> 'rule' => 'isScalar',
<ide> ]);
<ide> }
<ide>
<ide> public function multipleOptions($field, array $options = [], $message = null, $w
<ide> unset($options['caseInsensitive']);
<ide>
<ide> return $this->add($field, 'multipleOptions', $extra + [
<del> 'rule' => ['multiple', $options, $caseInsensitive]
<add> 'rule' => ['multiple', $options, $caseInsensitive],
<ide> ]);
<ide> }
<ide>
<ide> public function hasAtLeast($field, $count, $message = null, $when = null)
<ide> }
<ide>
<ide> return Validation::numElements($value, Validation::COMPARE_GREATER_OR_EQUAL, $count);
<del> }
<add> },
<ide> ]);
<ide> }
<ide>
<ide> public function hasAtMost($field, $count, $message = null, $when = null)
<ide> }
<ide>
<ide> return Validation::numElements($value, Validation::COMPARE_LESS_OR_EQUAL, $count);
<del> }
<add> },
<ide> ]);
<ide> }
<ide>
<ide> public function regex($field, $regex, $message = null, $when = null)
<ide> $extra = array_filter(['on' => $when, 'message' => $message]);
<ide>
<ide> return $this->add($field, 'regex', $extra + [
<del> 'rule' => ['custom', $regex]
<add> 'rule' => ['custom', $regex],
<ide> ]);
<ide> }
<ide>
<ide> public function __debugInfo()
<ide> '_allowEmptyFlags' => $this->_allowEmptyFlags,
<ide> '_useI18n' => $this->_useI18n,
<ide> '_providers' => array_keys($this->_providers),
<del> '_fields' => $fields
<add> '_fields' => $fields,
<ide> ];
<ide> }
<ide> }
<ide><path>src/View/Cell.php
<ide> abstract class Cell
<ide> * @deprecated 3.7.0 Use ViewBuilder::setOptions() or any one of it's setter methods instead.
<ide> */
<ide> protected $_validViewOptions = [
<del> 'viewPath'
<add> 'viewPath',
<ide> ];
<ide>
<ide> /**
<ide> protected function _cacheConfig($action, $template = null)
<ide> $key = str_replace('\\', '_', $key);
<ide> $default = [
<ide> 'config' => 'default',
<del> 'key' => $key
<add> 'key' => $key,
<ide> ];
<ide> if ($this->_cache === true) {
<ide> return $default;
<ide><path>src/View/Form/ArrayContext.php
<ide> public function val($field, $options = [])
<ide> {
<ide> $options += [
<ide> 'default' => null,
<del> 'schemaDefault' => true
<add> 'schemaDefault' => true,
<ide> ];
<ide>
<ide> $val = $this->_request->getData($field);
<ide><path>src/View/Form/ContextFactory.php
<ide> public static function createWithDefaults(array $providers = [])
<ide> if (is_array($data['entity']) && empty($data['entity']['schema'])) {
<ide> return new EntityContext($request, $data);
<ide> }
<del> }
<add> },
<ide> ],
<ide> [
<ide> 'type' => 'array',
<ide> 'callable' => function ($request, $data) {
<ide> if (is_array($data['entity']) && isset($data['entity']['schema'])) {
<ide> return new ArrayContext($request, $data['entity']);
<ide> }
<del> }
<add> },
<ide> ],
<ide> [
<ide> 'type' => 'form',
<ide> 'callable' => function ($request, $data) {
<ide> if ($data['entity'] instanceof Form) {
<ide> return new FormContext($request, $data);
<ide> }
<del> }
<add> },
<ide> ],
<ide> ] + $providers;
<ide>
<ide><path>src/View/Form/EntityContext.php
<ide> public function val($field, $options = [])
<ide> {
<ide> $options += [
<ide> 'default' => null,
<del> 'schemaDefault' => true
<add> 'schemaDefault' => true,
<ide> ];
<ide>
<ide> $val = $this->_request->getData($field);
<ide><path>src/View/Form/FormContext.php
<ide> public function val($field, $options = [])
<ide> {
<ide> $options += [
<ide> 'default' => null,
<del> 'schemaDefault' => true
<add> 'schemaDefault' => true,
<ide> ];
<ide>
<ide> $val = $this->_request->getData($field);
<ide><path>src/View/Helper.php
<ide> public function implementedEvents()
<ide> 'View.beforeRender' => 'beforeRender',
<ide> 'View.afterRender' => 'afterRender',
<ide> 'View.beforeLayout' => 'beforeLayout',
<del> 'View.afterLayout' => 'afterLayout'
<add> 'View.afterLayout' => 'afterLayout',
<ide> ];
<ide> $events = [];
<ide> foreach ($eventMap as $event => $method) {
<ide><path>src/View/Helper/BreadcrumbsHelper.php
<ide> class BreadcrumbsHelper extends Helper
<ide> 'wrapper' => '<ul{{attrs}}>{{content}}</ul>',
<ide> 'item' => '<li{{attrs}}><a href="{{url}}"{{innerAttrs}}>{{title}}</a></li>{{separator}}',
<ide> 'itemWithoutLink' => '<li{{attrs}}><span{{innerAttrs}}>{{title}}</span></li>{{separator}}',
<del> 'separator' => '<li{{attrs}}><span{{innerAttrs}}>{{separator}}</span></li>'
<del> ]
<add> 'separator' => '<li{{attrs}}><span{{innerAttrs}}>{{separator}}</span></li>',
<add> ],
<ide> ];
<ide>
<ide> /**
<ide> public function render(array $attributes = [], array $separator = [])
<ide> 'title' => $title,
<ide> 'url' => $url,
<ide> 'separator' => '',
<del> 'templateVars' => isset($options['templateVars']) ? $options['templateVars'] : []
<add> 'templateVars' => isset($options['templateVars']) ? $options['templateVars'] : [],
<ide> ];
<ide>
<ide> if (!$url) {
<ide> public function render(array $attributes = [], array $separator = [])
<ide> $crumbTrail = $this->formatTemplate('wrapper', [
<ide> 'content' => $crumbTrail,
<ide> 'attrs' => $templater->formatAttributes($attributes, ['templateVars']),
<del> 'templateVars' => isset($attributes['templateVars']) ? $attributes['templateVars'] : []
<add> 'templateVars' => isset($attributes['templateVars']) ? $attributes['templateVars'] : [],
<ide> ]);
<ide>
<ide> return $crumbTrail;
<ide><path>src/View/Helper/FormHelper.php
<ide> class FormHelper extends Helper
<ide> */
<ide> protected $_datetimeOptions = [
<ide> 'interval', 'round', 'monthNames', 'minYear', 'maxYear',
<del> 'orderYear', 'timeFormat', 'second'
<add> 'orderYear', 'timeFormat', 'second',
<ide> ];
<ide>
<ide> /**
<ide> public function create($context = null, array $options = [])
<ide> $append .= $this->hidden('_method', [
<ide> 'name' => '_method',
<ide> 'value' => strtoupper($options['type']),
<del> 'secure' => static::SECURE_SKIP
<add> 'secure' => static::SECURE_SKIP,
<ide> ]);
<ide> // Default to post method
<ide> default:
<ide> public function create($context = null, array $options = [])
<ide>
<ide> return $this->formatTemplate('formStart', [
<ide> 'attrs' => $templater->formatAttributes($htmlAttributes) . $actionAttr,
<del> 'templateVars' => isset($options['templateVars']) ? $options['templateVars'] : []
<add> 'templateVars' => isset($options['templateVars']) ? $options['templateVars'] : [],
<ide> ]) . $append;
<ide> }
<ide>
<ide> public function secure(array $fields = [], array $secureAttributes = [])
<ide> 'value' => urlencode(json_encode([
<ide> $this->_lastAction,
<ide> $fields,
<del> $this->_unlockedFields
<add> $this->_unlockedFields,
<ide> ])),
<ide> ]);
<ide> $out .= $this->hidden('_Token.debug', $tokenDebug);
<ide> public function error($field, $text = null, array $options = [])
<ide> $errorText[] = $this->formatTemplate('errorItem', ['text' => $err]);
<ide> }
<ide> $error = $this->formatTemplate('errorList', [
<del> 'content' => implode('', $errorText)
<add> 'content' => implode('', $errorText),
<ide> ]);
<ide> } else {
<ide> $error = array_pop($error);
<ide> public function control($fieldName, array $options = [])
<ide> 'options' => null,
<ide> 'templates' => [],
<ide> 'templateVars' => [],
<del> 'labelOptions' => true
<add> 'labelOptions' => true,
<ide> ];
<ide> $options = $this->_parseOptions($fieldName, $options);
<ide> $options += ['id' => $this->_domId($fieldName)];
<ide> public function control($fieldName, array $options = [])
<ide> 'content' => $result,
<ide> 'error' => $error,
<ide> 'errorSuffix' => $errorSuffix,
<del> 'options' => $options
<add> 'options' => $options,
<ide> ]);
<ide>
<ide> if ($newTemplates) {
<ide> protected function _groupTemplate($options)
<ide> 'input' => isset($options['input']) ? $options['input'] : [],
<ide> 'label' => $options['label'],
<ide> 'error' => $options['error'],
<del> 'templateVars' => isset($options['options']['templateVars']) ? $options['options']['templateVars'] : []
<add> 'templateVars' => isset($options['options']['templateVars']) ? $options['options']['templateVars'] : [],
<ide> ]);
<ide> }
<ide>
<ide> protected function _inputContainerTemplate($options)
<ide> 'error' => $options['error'],
<ide> 'required' => $options['options']['required'] ? ' required' : '',
<ide> 'type' => $options['options']['type'],
<del> 'templateVars' => isset($options['options']['templateVars']) ? $options['options']['templateVars'] : []
<add> 'templateVars' => isset($options['options']['templateVars']) ? $options['options']['templateVars'] : [],
<ide> ]);
<ide> }
<ide>
<ide> protected function _magicOptions($fieldName, $options, $allowOverride)
<ide> $context = $this->_getContext();
<ide>
<ide> $options += [
<del> 'templateVars' => []
<add> 'templateVars' => [],
<ide> ];
<ide>
<ide> if (!isset($options['required']) && $options['type'] !== 'hidden') {
<ide> public function checkbox($fieldName, array $options = [])
<ide> 'name' => $options['name'],
<ide> 'value' => $options['hiddenField'] !== true && $options['hiddenField'] !== '_split' ? $options['hiddenField'] : '0',
<ide> 'form' => isset($options['form']) ? $options['form'] : null,
<del> 'secure' => false
<add> 'secure' => false,
<ide> ];
<ide> if (isset($options['disabled']) && $options['disabled']) {
<ide> $hiddenOptions['disabled'] = 'disabled';
<ide> public function postLink($title, $url = null, array $options = [])
<ide>
<ide> $action = $templater->formatAttributes([
<ide> 'action' => $this->Url->build($url),
<del> 'escape' => false
<add> 'escape' => false,
<ide> ]);
<ide>
<ide> $out = $this->formatTemplate('formStart', [
<del> 'attrs' => $templater->formatAttributes($formOptions) . $action
<add> 'attrs' => $templater->formatAttributes($formOptions) . $action,
<ide> ]);
<ide> $out .= $this->hidden('_method', [
<ide> 'value' => $requestMethod,
<del> 'secure' => static::SECURE_SKIP
<add> 'secure' => static::SECURE_SKIP,
<ide> ]);
<ide> $out .= $this->_csrfField();
<ide>
<ide> public function postLink($title, $url = null, array $options = [])
<ide> $options['onclick'] = $this->templater()->format('confirmJs', [
<ide> 'confirmMessage' => $this->_cleanConfirmMessage($confirmMessage),
<ide> 'formName' => $formName,
<del> 'confirm' => $confirm
<add> 'confirm' => $confirm,
<ide> ]);
<ide>
<ide> $out .= $this->Html->link($title, $url, $options);
<ide> public function submit($caption = null, array $options = [])
<ide> $options += [
<ide> 'type' => 'submit',
<ide> 'secure' => false,
<del> 'templateVars' => []
<add> 'templateVars' => [],
<ide> ];
<ide>
<ide> if (isset($options['name'])) {
<ide> public function submit($caption = null, array $options = [])
<ide> if (isset($options['name'])) {
<ide> $unlockFields = [
<ide> $options['name'] . '_x',
<del> $options['name'] . '_y'
<add> $options['name'] . '_y',
<ide> ];
<ide> }
<ide> foreach ($unlockFields as $ignore) {
<ide> public function submit($caption = null, array $options = [])
<ide> $input = $this->formatTemplate('inputSubmit', [
<ide> 'type' => $type,
<ide> 'attrs' => $this->templater()->formatAttributes($options),
<del> 'templateVars' => $options['templateVars']
<add> 'templateVars' => $options['templateVars'],
<ide> ]);
<ide>
<ide> return $this->formatTemplate('submitContainer', [
<ide> 'content' => $input,
<del> 'templateVars' => $options['templateVars']
<add> 'templateVars' => $options['templateVars'],
<ide> ]);
<ide> }
<ide>
<ide> public function day($fieldName = null, array $options = [])
<ide> $options['val'] = [
<ide> 'year' => date('Y'),
<ide> 'month' => date('m'),
<del> 'day' => (int)$options['val']
<add> 'day' => (int)$options['val'],
<ide> ];
<ide> }
<ide>
<ide> public function year($fieldName, array $options = [])
<ide> $options['val'] = [
<ide> 'year' => (int)$options['val'],
<ide> 'month' => date('m'),
<del> 'day' => date('d')
<add> 'day' => date('d'),
<ide> ];
<ide> }
<ide>
<ide> public function month($fieldName, array $options = [])
<ide> $options['val'] = [
<ide> 'year' => date('Y'),
<ide> 'month' => (int)$options['val'],
<del> 'day' => date('d')
<add> 'day' => date('d'),
<ide> ];
<ide> }
<ide>
<ide> public function getSourceValue($fieldname, $options = [])
<ide> {
<ide> $valueMap = [
<ide> 'data' => 'getData',
<del> 'query' => 'getQuery'
<add> 'query' => 'getQuery',
<ide> ];
<ide> foreach ($this->getValueSources() as $valuesSource) {
<ide> if ($valuesSource === 'context') {
<ide><path>src/View/Helper/HtmlHelper.php
<ide> class HtmlHelper extends Helper
<ide> 'javascriptstart' => '<script>',
<ide> 'javascriptlink' => '<script src="{{url}}"{{attrs}}></script>',
<ide> 'javascriptend' => '</script>',
<del> 'confirmJs' => '{{confirm}}'
<del> ]
<add> 'confirmJs' => '{{confirm}}',
<add> ],
<ide> ];
<ide>
<ide> /**
<ide> class HtmlHelper extends Helper
<ide> 'xhtml-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
<ide> 'xhtml-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
<ide> 'xhtml-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
<del> 'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'
<add> 'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
<ide> ];
<ide>
<ide> /**
<ide> public function meta($type, $content = null, array $options = [])
<ide> 'next' => ['rel' => 'next', 'link' => $content],
<ide> 'prev' => ['rel' => 'prev', 'link' => $content],
<ide> 'first' => ['rel' => 'first', 'link' => $content],
<del> 'last' => ['rel' => 'last', 'link' => $content]
<add> 'last' => ['rel' => 'last', 'link' => $content],
<ide> ];
<ide>
<ide> if ($type === 'icon' && $content === null) {
<ide> public function meta($type, $content = null, array $options = [])
<ide> if (isset($options['rel']) && $options['rel'] === 'icon') {
<ide> $out = $this->formatTemplate('metalink', [
<ide> 'url' => $options['link'],
<del> 'attrs' => $this->templater()->formatAttributes($options, ['block', 'link'])
<add> 'attrs' => $this->templater()->formatAttributes($options, ['block', 'link']),
<ide> ]);
<ide> $options['rel'] = 'shortcut icon';
<ide> }
<ide> $out .= $this->formatTemplate('metalink', [
<ide> 'url' => $options['link'],
<del> 'attrs' => $this->templater()->formatAttributes($options, ['block', 'link'])
<add> 'attrs' => $this->templater()->formatAttributes($options, ['block', 'link']),
<ide> ]);
<ide> } else {
<ide> $out = $this->formatTemplate('meta', [
<del> 'attrs' => $this->templater()->formatAttributes($options, ['block', 'type'])
<add> 'attrs' => $this->templater()->formatAttributes($options, ['block', 'type']),
<ide> ]);
<ide> }
<ide>
<ide> public function charset($charset = null)
<ide> }
<ide>
<ide> return $this->formatTemplate('charset', [
<del> 'charset' => !empty($charset) ? $charset : 'utf-8'
<add> 'charset' => !empty($charset) ? $charset : 'utf-8',
<ide> ]);
<ide> }
<ide>
<ide> public function link($title, $url = null, array $options = [])
<ide> $confirm = $this->_confirm($confirmMessage, 'return true;', 'return false;', $options);
<ide> $options['onclick'] = $templater->format('confirmJs', [
<ide> 'confirmMessage' => $this->_cleanConfirmMessage($confirmMessage),
<del> 'confirm' => $confirm
<add> 'confirm' => $confirm,
<ide> ]);
<ide> }
<ide>
<ide> return $templater->format('link', [
<ide> 'url' => $url,
<ide> 'attrs' => $templater->formatAttributes($options),
<del> 'content' => $title
<add> 'content' => $title,
<ide> ]);
<ide> }
<ide>
<ide> public function scriptBlock($script, array $options = [])
<ide>
<ide> $out = $this->formatTemplate('javascriptblock', [
<ide> 'attrs' => $this->templater()->formatAttributes($options, ['block']),
<del> 'content' => $script
<add> 'content' => $script,
<ide> ]);
<ide>
<ide> if (empty($options['block'])) {
<ide> public function getCrumbList(array $options = [], $startText = false)
<ide> }
<ide> $result .= $this->formatTemplate('li', [
<ide> 'content' => $elementContent,
<del> 'attrs' => $this->templater()->formatAttributes($options)
<add> 'attrs' => $this->templater()->formatAttributes($options),
<ide> ]);
<ide> }
<ide>
<ide> return $this->formatTemplate('ul', [
<ide> 'content' => $result,
<del> 'attrs' => $this->templater()->formatAttributes($ulOptions)
<add> 'attrs' => $this->templater()->formatAttributes($ulOptions),
<ide> ]);
<ide> }
<ide>
<ide> protected function _prepareCrumbs($startText, $escape = true)
<ide> if (!is_array($startText)) {
<ide> $startText = [
<ide> 'url' => '/',
<del> 'text' => $startText
<add> 'text' => $startText,
<ide> ];
<ide> }
<ide> $startText += ['url' => '/', 'text' => __d('cake', 'Home')];
<ide> public function image($path, array $options = [])
<ide> return $templater->format('link', [
<ide> 'url' => $this->Url->build($url),
<ide> 'attrs' => null,
<del> 'content' => $image
<add> 'content' => $image,
<ide> ]);
<ide> }
<ide>
<ide> public function tableHeaders(array $names, array $trOptions = null, array $thOpt
<ide> if (!is_array($arg)) {
<ide> $out[] = $this->formatTemplate('tableheader', [
<ide> 'attrs' => $this->templater()->formatAttributes($thOptions),
<del> 'content' => $arg
<add> 'content' => $arg,
<ide> ]);
<ide> } else {
<ide> $out[] = $this->formatTemplate('tableheader', [
<ide> 'attrs' => $this->templater()->formatAttributes(current($arg)),
<del> 'content' => key($arg)
<add> 'content' => key($arg),
<ide> ]);
<ide> }
<ide> }
<ide> public function tableRow($content, array $options = [])
<ide> {
<ide> return $this->formatTemplate('tablerow', [
<ide> 'attrs' => $this->templater()->formatAttributes($options),
<del> 'content' => $content
<add> 'content' => $content,
<ide> ]);
<ide> }
<ide>
<ide> public function tableCell($content, array $options = [])
<ide> {
<ide> return $this->formatTemplate('tablecell', [
<ide> 'attrs' => $this->templater()->formatAttributes($options),
<del> 'content' => $content
<add> 'content' => $content,
<ide> ]);
<ide> }
<ide>
<ide> public function media($path, array $options = [])
<ide> $options += [
<ide> 'tag' => null,
<ide> 'pathPrefix' => 'files/',
<del> 'text' => ''
<add> 'text' => '',
<ide> ];
<ide>
<ide> if (!empty($options['tag'])) {
<ide> public function media($path, array $options = [])
<ide> $source['src'] = $this->Url->assetUrl($source['src'], $options);
<ide> $sourceTags .= $this->formatTemplate('tagselfclosing', [
<ide> 'tag' => 'source',
<del> 'attrs' => $this->templater()->formatAttributes($source)
<add> 'attrs' => $this->templater()->formatAttributes($source),
<ide> ]);
<ide> }
<ide> unset($source);
<ide> public function media($path, array $options = [])
<ide> 'tag' => null,
<ide> 'fullBase' => null,
<ide> 'pathPrefix' => null,
<del> 'text' => null
<add> 'text' => null,
<ide> ]);
<ide>
<ide> return $this->tag($tag, $text, $options);
<ide> public function nestedList(array $list, array $options = [], array $itemOptions
<ide>
<ide> return $this->formatTemplate($options['tag'], [
<ide> 'attrs' => $this->templater()->formatAttributes($options, ['tag']),
<del> 'content' => $items
<add> 'content' => $items,
<ide> ]);
<ide> }
<ide>
<ide> protected function _nestedListItem($items, $options, $itemOptions)
<ide> }
<ide> $out .= $this->formatTemplate('li', [
<ide> 'attrs' => $this->templater()->formatAttributes($itemOptions, ['even', 'odd']),
<del> 'content' => $item
<add> 'content' => $item,
<ide> ]);
<ide> $index++;
<ide> }
<ide><path>src/View/Helper/NumberHelper.php
<ide> class NumberHelper extends Helper
<ide> * @var array
<ide> */
<ide> protected $_defaultConfig = [
<del> 'engine' => 'Cake\I18n\Number'
<add> 'engine' => 'Cake\I18n\Number',
<ide> ];
<ide>
<ide> /**
<ide><path>src/View/Helper/PaginatorHelper.php
<ide> class PaginatorHelper extends Helper
<ide> 'sortDesc' => '<a class="desc" href="{{url}}">{{text}}</a>',
<ide> 'sortAscLocked' => '<a class="asc locked" href="{{url}}">{{text}}</a>',
<ide> 'sortDescLocked' => '<a class="desc locked" href="{{url}}">{{text}}</a>',
<del> ]
<add> ],
<ide> ];
<ide>
<ide> /**
<ide> public function prev($title = '<< Previous', array $options = [])
<ide> $enabled = $this->hasPrev($options['model']);
<ide> $templates = [
<ide> 'active' => 'prevActive',
<del> 'disabled' => 'prevDisabled'
<add> 'disabled' => 'prevDisabled',
<ide> ];
<ide>
<ide> return $this->_toggledLink($title, $enabled, $options, $templates);
<ide> public function next($title = 'Next >>', array $options = [])
<ide> $enabled = $this->hasNext($options['model']);
<ide> $templates = [
<ide> 'active' => 'nextActive',
<del> 'disabled' => 'nextDisabled'
<add> 'disabled' => 'nextDisabled',
<ide> ];
<ide>
<ide> return $this->_toggledLink($title, $enabled, $options, $templates);
<ide> public function generateUrl(array $options = [], $model = null, $urlOptions = []
<ide> }
<ide> $urlOptions += [
<ide> 'escape' => true,
<del> 'fullBase' => false
<add> 'fullBase' => false,
<ide> ];
<ide>
<ide> return $this->Url->build($this->generateUrlParams($options, $model), $urlOptions);
<ide> public function counter($options = [])
<ide> 'current' => $paging['current'],
<ide> 'count' => $paging['count'],
<ide> 'start' => $paging['start'],
<del> 'end' => $paging['end']
<add> 'end' => $paging['end'],
<ide> ]);
<ide>
<ide> $map += [
<del> 'model' => strtolower(Inflector::humanize(Inflector::tableize($options['model'])))
<add> 'model' => strtolower(Inflector::humanize(Inflector::tableize($options['model']))),
<ide> ];
<ide>
<ide> return $this->templater()->format($template, $map);
<ide> public function numbers(array $options = [])
<ide> {
<ide> $defaults = [
<ide> 'before' => null, 'after' => null, 'model' => $this->defaultModel(),
<del> 'modulus' => 8, 'first' => null, 'last' => null, 'url' => []
<add> 'modulus' => 8, 'first' => null, 'last' => null, 'url' => [],
<ide> ];
<ide> $options += $defaults;
<ide>
<ide> public function first($first = '<< first', array $options = [])
<ide> $options += [
<ide> 'url' => [],
<ide> 'model' => $this->defaultModel(),
<del> 'escape' => true
<add> 'escape' => true,
<ide> ];
<ide>
<ide> $params = $this->params($options['model']);
<ide> public function first($first = '<< first', array $options = [])
<ide> $url = array_merge($options['url'], ['page' => $i]);
<ide> $out .= $this->templater()->format('number', [
<ide> 'url' => $this->generateUrl($url, $options['model']),
<del> 'text' => $this->Number->format($i)
<add> 'text' => $this->Number->format($i),
<ide> ]);
<ide> }
<ide> } elseif ($params['page'] > 1 && is_string($first)) {
<ide> $first = $options['escape'] ? h($first) : $first;
<ide> $out .= $this->templater()->format('first', [
<ide> 'url' => $this->generateUrl(['page' => 1], $options['model']),
<del> 'text' => $first
<add> 'text' => $first,
<ide> ]);
<ide> }
<ide>
<ide> public function last($last = 'last >>', array $options = [])
<ide> $options += [
<ide> 'model' => $this->defaultModel(),
<ide> 'escape' => true,
<del> 'url' => []
<add> 'url' => [],
<ide> ];
<ide> $params = $this->params($options['model']);
<ide>
<ide> public function last($last = 'last >>', array $options = [])
<ide> $url = array_merge($options['url'], ['page' => $i]);
<ide> $out .= $this->templater()->format('number', [
<ide> 'url' => $this->generateUrl($url, $options['model']),
<del> 'text' => $this->Number->format($i)
<add> 'text' => $this->Number->format($i),
<ide> ]);
<ide> }
<ide> } elseif ($params['page'] < $params['pageCount'] && is_string($last)) {
<ide> $last = $options['escape'] ? h($last) : $last;
<ide> $out .= $this->templater()->format('last', [
<ide> 'url' => $this->generateUrl(['page' => $params['pageCount']], $options['model']),
<del> 'text' => $last
<add> 'text' => $last,
<ide> ]);
<ide> }
<ide>
<ide> public function meta(array $options = [])
<ide> 'prev' => true,
<ide> 'next' => true,
<ide> 'first' => false,
<del> 'last' => false
<add> 'last' => false,
<ide> ];
<ide>
<ide> $model = isset($options['model']) ? $options['model'] : null;
<ide> public function limitControl(array $limits = [], $default = null, array $options
<ide> $limits = [
<ide> '20' => '20',
<ide> '50' => '50',
<del> '100' => '100'
<add> '100' => '100',
<ide> ];
<ide> }
<ide>
<ide> public function limitControl(array $limits = [], $default = null, array $options
<ide> 'default' => $default,
<ide> 'value' => $this->_View->getRequest()->getQuery('limit'),
<ide> 'options' => $limits,
<del> 'onChange' => 'this.form.submit()'
<add> 'onChange' => 'this.form.submit()',
<ide> ]);
<ide> $out .= $this->Form->end();
<ide>
<ide><path>src/View/Helper/TextHelper.php
<ide> class TextHelper extends Helper
<ide> * @var array
<ide> */
<ide> protected $_defaultConfig = [
<del> 'engine' => 'Cake\Utility\Text'
<add> 'engine' => 'Cake\Utility\Text',
<ide> ];
<ide>
<ide> /**
<ide> protected function _insertPlaceHolder($matches)
<ide> $key = hash_hmac('sha1', $match, Security::getSalt());
<ide> $this->_placeholders[$key] = [
<ide> 'content' => $match,
<del> 'envelope' => $envelope
<add> 'envelope' => $envelope,
<ide> ];
<ide>
<ide> return $key;
<ide><path>src/View/Helper/TimeHelper.php
<ide> class TimeHelper extends Helper
<ide> * @var array
<ide> */
<ide> protected $_defaultConfig = [
<del> 'outputTimezone' => null
<add> 'outputTimezone' => null,
<ide> ];
<ide>
<ide> /**
<ide> public function timeAgoInWords($dateTime, array $options = [])
<ide> $element = null;
<ide> $options += [
<ide> 'element' => null,
<del> 'timezone' => null
<add> 'timezone' => null,
<ide> ];
<ide> $options['timezone'] = $this->_getTimezone($options['timezone']);
<ide> if ($options['timezone']) {
<ide> public function timeAgoInWords($dateTime, array $options = [])
<ide> $element = [
<ide> 'tag' => 'span',
<ide> 'class' => 'time-ago-in-words',
<del> 'title' => $dateTime
<add> 'title' => $dateTime,
<ide> ];
<ide>
<ide> if (is_array($options['element'])) {
<ide><path>src/View/HelperRegistry.php
<ide> protected function _throwMissingClassError($class, $plugin)
<ide> {
<ide> throw new MissingHelperException([
<ide> 'class' => $class . 'Helper',
<del> 'plugin' => $plugin
<add> 'plugin' => $plugin,
<ide> ]);
<ide> }
<ide>
<ide><path>src/View/StringTemplate.php
<ide> public function push()
<ide> {
<ide> $this->_configStack[] = [
<ide> $this->_config,
<del> $this->_compiled
<add> $this->_compiled,
<ide> ];
<ide> }
<ide>
<ide> protected function _compileTemplates(array $templates = [])
<ide> preg_match_all('#\{\{([\w\._]+)\}\}#', $template, $matches);
<ide> $this->_compiled[$name] = [
<ide> str_replace($matches[0], '%s', $template),
<del> $matches[1]
<add> $matches[1],
<ide> ];
<ide> }
<ide> }
<ide><path>src/View/View.php
<ide> class View implements EventDispatcherInterface
<ide> */
<ide> protected $_passedVars = [
<ide> 'viewVars', 'autoLayout', 'helpers', 'template', 'layout', 'name', 'theme',
<del> 'layoutPath', 'templatePath', 'plugin', 'passedArgs'
<add> 'layoutPath', 'templatePath', 'plugin', 'passedArgs',
<ide> ];
<ide>
<ide> /**
<ide> public function __construct(
<ide> $this->request = new ServerRequest([
<ide> 'base' => '',
<ide> 'url' => '',
<del> 'webroot' => '/'
<add> 'webroot' => '/',
<ide> ]);
<ide> }
<ide> $this->Blocks = new $this->_viewBlockClass();
<ide> protected function _getLayoutFileName($name = null)
<ide> }
<ide> }
<ide> throw new MissingLayoutException([
<del> 'file' => $layoutPaths[0] . $name . $this->_ext
<add> 'file' => $layoutPaths[0] . $name . $this->_ext,
<ide> ]);
<ide> }
<ide>
<ide> protected function _elementCache($name, $data, $options)
<ide> );
<ide> $config = [
<ide> 'config' => $this->elementCache,
<del> 'key' => implode('_', $keys)
<add> 'key' => implode('_', $keys),
<ide> ];
<ide> if (is_array($cache)) {
<ide> $defaults = [
<ide> 'config' => $this->elementCache,
<del> 'key' => $config['key']
<add> 'key' => $config['key'],
<ide> ];
<ide> $config = $cache + $defaults;
<ide> }
<ide><path>src/View/ViewBuilder.php
<ide> public function jsonSerialize()
<ide> {
<ide> $properties = [
<ide> '_templatePath', '_template', '_plugin', '_theme', '_layout', '_autoLayout',
<del> '_layoutPath', '_name', '_className', '_options', '_helpers'
<add> '_layoutPath', '_name', '_className', '_options', '_helpers',
<ide> ];
<ide>
<ide> $array = [];
<ide><path>src/View/Widget/BasicWidget.php
<ide> public function render(array $data, ContextInterface $context)
<ide> 'val' => null,
<ide> 'type' => 'text',
<ide> 'escape' => true,
<del> 'templateVars' => []
<add> 'templateVars' => [],
<ide> ];
<ide> $data['value'] = $data['val'];
<ide> unset($data['val']);
<ide><path>src/View/Widget/ButtonWidget.php
<ide> public function render(array $data, ContextInterface $context)
<ide> 'text' => '',
<ide> 'type' => 'submit',
<ide> 'escape' => false,
<del> 'templateVars' => []
<add> 'templateVars' => [],
<ide> ];
<ide>
<ide> return $this->_templates->format('button', [
<ide><path>src/View/Widget/CheckboxWidget.php
<ide> public function render(array $data, ContextInterface $context)
<ide> 'value' => 1,
<ide> 'val' => null,
<ide> 'disabled' => false,
<del> 'templateVars' => []
<add> 'templateVars' => [],
<ide> ];
<ide> if ($this->_isChecked($data)) {
<ide> $data['checked'] = true;
<ide> public function render(array $data, ContextInterface $context)
<ide> 'name' => $data['name'],
<ide> 'value' => $data['value'],
<ide> 'templateVars' => $data['templateVars'],
<del> 'attrs' => $attrs
<add> 'attrs' => $attrs,
<ide> ]);
<ide> }
<ide>
<ide><path>src/View/Widget/DateTimeWidget.php
<ide> protected function _yearSelect($options, $context)
<ide> 'end' => date('Y', strtotime('+5 years')),
<ide> 'order' => 'desc',
<ide> 'templateVars' => [],
<del> 'options' => []
<add> 'options' => [],
<ide> ];
<ide>
<ide> if (!empty($options['val'])) {
<ide> protected function _generateNumbers($start, $end, $options = [])
<ide> $options += [
<ide> 'leadingZeroKey' => true,
<ide> 'leadingZeroValue' => true,
<del> 'interval' => 1
<add> 'interval' => 1,
<ide> ];
<ide>
<ide> $numbers = [];
<ide><path>src/View/Widget/FileWidget.php
<ide> public function render(array $data, ContextInterface $context)
<ide> 'attrs' => $this->_templates->formatAttributes(
<ide> $data,
<ide> ['name']
<del> )
<add> ),
<ide> ]);
<ide> }
<ide>
<ide><path>src/View/Widget/LabelWidget.php
<ide> public function render(array $data, ContextInterface $context)
<ide> 'input' => '',
<ide> 'hidden' => '',
<ide> 'escape' => true,
<del> 'templateVars' => []
<add> 'templateVars' => [],
<ide> ];
<ide>
<ide> return $this->_templates->format($this->_labelTemplate, [
<ide><path>src/View/Widget/MultiCheckboxWidget.php
<ide> public function render(array $data, ContextInterface $context)
<ide> 'val' => null,
<ide> 'idPrefix' => null,
<ide> 'templateVars' => [],
<del> 'label' => true
<add> 'label' => true,
<ide> ];
<ide> $this->_idPrefix = $data['idPrefix'];
<ide> $this->_clearIds();
<ide> protected function _renderInputs($data, $context)
<ide> $inputs = $this->_renderInputs(['options' => $val] + $data, $context);
<ide> $title = $this->_templates->format('multicheckboxTitle', ['text' => $key]);
<ide> $out[] = $this->_templates->format('multicheckboxWrapper', [
<del> 'content' => $title . implode('', $inputs)
<add> 'content' => $title . implode('', $inputs),
<ide> ]);
<ide> continue;
<ide> }
<ide> protected function _renderInput($checkbox, $context)
<ide> 'attrs' => $this->_templates->formatAttributes(
<ide> $checkbox,
<ide> ['name', 'value', 'text', 'options', 'label', 'val', 'type']
<del> )
<add> ),
<ide> ]);
<ide>
<ide> if ($checkbox['label'] === false && strpos($this->_templates->get('checkboxWrapper'), '{{input}}') === false) {
<ide> protected function _renderInput($checkbox, $context)
<ide> 'escape' => $checkbox['escape'],
<ide> 'text' => $checkbox['text'],
<ide> 'templateVars' => $checkbox['templateVars'],
<del> 'input' => $input
<add> 'input' => $input,
<ide> ];
<ide>
<ide> if ($checkbox['checked']) {
<ide> protected function _renderInput($checkbox, $context)
<ide> return $this->_templates->format('checkboxWrapper', [
<ide> 'templateVars' => $checkbox['templateVars'],
<ide> 'label' => $label,
<del> 'input' => $input
<add> 'input' => $input,
<ide> ]);
<ide> }
<ide>
<ide><path>src/View/Widget/SelectBoxWidget.php
<ide> public function render(array $data, ContextInterface $context)
<ide> 'options' => [],
<ide> 'disabled' => null,
<ide> 'val' => null,
<del> 'templateVars' => []
<add> 'templateVars' => [],
<ide> ];
<ide>
<ide> $options = $this->_renderContent($data);
<ide><path>src/View/Widget/TextareaWidget.php
<ide> public function render(array $data, ContextInterface $context)
<ide> 'name' => '',
<ide> 'escape' => true,
<ide> 'rows' => 5,
<del> 'templateVars' => []
<add> 'templateVars' => [],
<ide> ];
<ide>
<ide> return $this->_templates->format('textarea', [
<ide> public function render(array $data, ContextInterface $context)
<ide> 'attrs' => $this->_templates->formatAttributes(
<ide> $data,
<ide> ['name', 'val']
<del> )
<add> ),
<ide> ]);
<ide> }
<ide> }
<ide><path>src/basics.php
<ide> function debug($var, $showHtml = null, $showFrom = true)
<ide> $trace = Debugger::trace(['start' => 1, 'depth' => 2, 'format' => 'array']);
<ide> $location = [
<ide> 'line' => $trace[0]['line'],
<del> 'file' => $trace[0]['file']
<add> 'file' => $trace[0]['file'],
<ide> ];
<ide> }
<ide>
<ide> function dd($var, $showHtml = null)
<ide> $trace = Debugger::trace(['start' => 1, 'depth' => 2, 'format' => 'array']);
<ide> $location = [
<ide> 'line' => $trace[0]['line'],
<del> 'file' => $trace[0]['file']
<add> 'file' => $trace[0]['file'],
<ide> ];
<ide>
<ide> Debugger::printVar($var, $location, $showHtml);
<ide><path>tests/Fixture/ArticlesFixture.php
<ide> class ArticlesFixture extends TestFixture
<ide> 'title' => ['type' => 'string', 'null' => true],
<ide> 'body' => 'text',
<ide> 'published' => ['type' => 'string', 'length' => 1, 'default' => 'N'],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide> class ArticlesFixture extends TestFixture
<ide> public $records = [
<ide> ['author_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y'],
<ide> ['author_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y'],
<del> ['author_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y']
<add> ['author_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y'],
<ide> ];
<ide> }
<ide><path>tests/Fixture/ArticlesTagsFixture.php
<ide> class ArticlesTagsFixture extends TestFixture
<ide> 'references' => ['tags', 'id'],
<ide> 'update' => 'cascade',
<ide> 'delete' => 'cascade',
<del> ]
<del> ]
<add> ],
<add> ],
<ide> ];
<ide>
<ide> /**
<ide> class ArticlesTagsFixture extends TestFixture
<ide> ['article_id' => 1, 'tag_id' => 1],
<ide> ['article_id' => 1, 'tag_id' => 2],
<ide> ['article_id' => 2, 'tag_id' => 1],
<del> ['article_id' => 2, 'tag_id' => 3]
<add> ['article_id' => 2, 'tag_id' => 3],
<ide> ];
<ide> }
<ide><path>tests/Fixture/AttachmentsFixture.php
<ide> class AttachmentsFixture extends TestFixture
<ide> 'attachment' => ['type' => 'string', 'null' => false],
<ide> 'created' => 'datetime',
<ide> 'updated' => 'datetime',
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide> class AttachmentsFixture extends TestFixture
<ide> * @var array
<ide> */
<ide> public $records = [
<del> ['comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31']
<add> ['comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31'],
<ide> ];
<ide> }
<ide><path>tests/Fixture/AuthUsersFixture.php
<ide> class AuthUsersFixture extends TestFixture
<ide> 'password' => ['type' => 'string', 'null' => false],
<ide> 'created' => 'datetime',
<ide> 'updated' => 'datetime',
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/AuthorsFixture.php
<ide> class AuthorsFixture extends TestFixture
<ide> public $fields = [
<ide> 'id' => ['type' => 'integer'],
<ide> 'name' => ['type' => 'string', 'default' => null],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/AuthorsTagsFixture.php
<ide> class AuthorsTagsFixture extends TestFixture
<ide> 'tag_id' => ['type' => 'integer', 'null' => false],
<ide> '_constraints' => [
<ide> 'unique_tag' => ['type' => 'primary', 'columns' => ['author_id', 'tag_id']],
<del> ]
<add> ],
<ide> ];
<ide>
<ide> /**
<ide> class AuthorsTagsFixture extends TestFixture
<ide> ['author_id' => 3, 'tag_id' => 1],
<ide> ['author_id' => 3, 'tag_id' => 2],
<ide> ['author_id' => 2, 'tag_id' => 1],
<del> ['author_id' => 2, 'tag_id' => 3]
<add> ['author_id' => 2, 'tag_id' => 3],
<ide> ];
<ide> }
<ide><path>tests/Fixture/BinaryUuiditemsFixture.php
<ide> class BinaryUuiditemsFixture extends TestFixture
<ide> 'id' => ['type' => 'binaryuuid'],
<ide> 'name' => ['type' => 'string', 'null' => false],
<ide> 'published' => ['type' => 'boolean', 'null' => false],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/CakeSessionsFixture.php
<ide> class CakeSessionsFixture extends TestFixture
<ide> 'id' => ['type' => 'string', 'length' => 128],
<ide> 'data' => ['type' => 'text', 'null' => true],
<ide> 'expires' => ['type' => 'integer', 'length' => 11, 'null' => true],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/CategoriesFixture.php
<ide> class CategoriesFixture extends TestFixture
<ide> 'name' => ['type' => 'string', 'null' => false],
<ide> 'created' => 'datetime',
<ide> 'updated' => 'datetime',
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/CommentsFixture.php
<ide> class CommentsFixture extends TestFixture
<ide> 'published' => ['type' => 'string', 'length' => 1, 'default' => 'N'],
<ide> 'created' => ['type' => 'datetime'],
<ide> 'updated' => ['type' => 'datetime'],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide> class CommentsFixture extends TestFixture
<ide> ['article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31'],
<ide> ['article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31'],
<ide> ['article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31'],
<del> ['article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31']
<add> ['article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31'],
<ide> ];
<ide> }
<ide><path>tests/Fixture/CompositeIncrementsFixture.php
<ide> class CompositeIncrementsFixture extends TestFixture
<ide> 'id' => ['type' => 'integer', 'null' => false, 'autoIncrement' => true],
<ide> 'account_id' => ['type' => 'integer', 'null' => false],
<ide> 'name' => ['type' => 'string', 'default' => null],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id', 'account_id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id', 'account_id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/CounterCacheCategoriesFixture.php
<ide> class CounterCacheCategoriesFixture extends TestFixture
<ide> 'id' => ['type' => 'integer'],
<ide> 'name' => ['type' => 'string', 'length' => 255, 'null' => false],
<ide> 'post_count' => ['type' => 'integer', 'null' => true],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> public $records = [
<ide><path>tests/Fixture/CounterCacheCommentsFixture.php
<ide> class CounterCacheCommentsFixture extends TestFixture
<ide> 'id' => ['type' => 'integer'],
<ide> 'title' => ['type' => 'string', 'length' => 255],
<ide> 'user_id' => ['type' => 'integer', 'null' => true],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> public $records = [
<ide><path>tests/Fixture/CounterCachePostsFixture.php
<ide> class CounterCachePostsFixture extends TestFixture
<ide> 'user_id' => ['type' => 'integer', 'null' => true],
<ide> 'category_id' => ['type' => 'integer', 'null' => true],
<ide> 'published' => ['type' => 'boolean', 'null' => false, 'default' => false],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> public $records = [
<ide><path>tests/Fixture/CounterCacheUserCategoryPostsFixture.php
<ide> class CounterCacheUserCategoryPostsFixture extends TestFixture
<ide> 'category_id' => ['type' => 'integer'],
<ide> 'user_id' => ['type' => 'integer'],
<ide> 'post_count' => ['type' => 'integer', 'null' => true],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> public $records = [
<ide> ['category_id' => 1, 'user_id' => 1, 'post_count' => 1],
<ide> ['category_id' => 2, 'user_id' => 1, 'post_count' => 1],
<del> ['category_id' => 2, 'user_id' => 2, 'post_count' => 1]
<add> ['category_id' => 2, 'user_id' => 2, 'post_count' => 1],
<ide> ];
<ide> }
<ide><path>tests/Fixture/CounterCacheUsersFixture.php
<ide> class CounterCacheUsersFixture extends TestFixture
<ide> 'post_count' => ['type' => 'integer', 'null' => true],
<ide> 'comment_count' => ['type' => 'integer', 'null' => true],
<ide> 'posts_published' => ['type' => 'integer', 'null' => true],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> public $records = [
<ide><path>tests/Fixture/DatatypesFixture.php
<ide> class DatatypesFixture extends TestFixture
<ide> 'floaty' => ['type' => 'float', 'null' => true],
<ide> 'small' => ['type' => 'smallinteger', 'null' => true],
<ide> 'tiny' => ['type' => 'tinyinteger', 'null' => true],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/DateKeysFixture.php
<ide> class DateKeysFixture extends TestFixture
<ide> public $fields = [
<ide> 'id' => ['type' => 'date'],
<ide> 'title' => ['type' => 'string', 'null' => true],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/FeaturedTagsFixture.php
<ide> class FeaturedTagsFixture extends TestFixture
<ide> public $fields = [
<ide> 'tag_id' => ['type' => 'integer', 'null' => false],
<ide> 'priority' => ['type' => 'integer', 'null' => false],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['tag_id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['tag_id']]],
<ide> ];
<ide>
<ide> /**
<ide> class FeaturedTagsFixture extends TestFixture
<ide> public $records = [
<ide> ['priority' => 1],
<ide> ['priority' => 2],
<del> ['priority' => 3]
<add> ['priority' => 3],
<ide> ];
<ide> }
<ide><path>tests/Fixture/GroupsFixture.php
<ide> class GroupsFixture extends TestFixture
<ide> public $fields = [
<ide> 'id' => ['type' => 'integer'],
<ide> 'title' => ['type' => 'string'],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/GroupsMembersFixture.php
<ide> class GroupsMembersFixture extends TestFixture
<ide> 'id' => ['type' => 'integer'],
<ide> 'group_id' => ['type' => 'integer'],
<ide> 'member_id' => ['type' => 'integer'],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/MembersFixture.php
<ide> class MembersFixture extends TestFixture
<ide> public $fields = [
<ide> 'id' => ['type' => 'integer'],
<ide> 'group_count' => ['type' => 'integer'],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/MenuLinkTreesFixture.php
<ide> class MenuLinkTreesFixture extends TestFixture
<ide> 'parent_id' => 'integer',
<ide> 'url' => ['type' => 'string', 'null' => false],
<ide> 'title' => ['type' => 'string', 'null' => false],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/NumberTreesFixture.php
<ide> class NumberTreesFixture extends TestFixture
<ide> 'lft' => ['type' => 'integer'],
<ide> 'rght' => ['type' => 'integer'],
<ide> 'depth' => ['type' => 'integer'],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide> class NumberTreesFixture extends TestFixture
<ide> 'parent_id' => null,
<ide> 'lft' => '1',
<ide> 'rght' => '20',
<del> 'depth' => 0
<add> 'depth' => 0,
<ide> ],
<ide> [
<ide> 'name' => 'televisions',
<ide> 'parent_id' => '1',
<ide> 'lft' => '2',
<ide> 'rght' => '9',
<del> 'depth' => 1
<add> 'depth' => 1,
<ide> ],
<ide> [
<ide> 'name' => 'tube',
<ide> 'parent_id' => '2',
<ide> 'lft' => '3',
<ide> 'rght' => '4',
<del> 'depth' => 2
<add> 'depth' => 2,
<ide> ],
<ide> [
<ide> 'name' => 'lcd',
<ide> 'parent_id' => '2',
<ide> 'lft' => '5',
<ide> 'rght' => '6',
<del> 'depth' => 2
<add> 'depth' => 2,
<ide> ],
<ide> [
<ide> 'name' => 'plasma',
<ide> 'parent_id' => '2',
<ide> 'lft' => '7',
<ide> 'rght' => '8',
<del> 'depth' => 2
<add> 'depth' => 2,
<ide> ],
<ide> [
<ide> 'name' => 'portable',
<ide> 'parent_id' => '1',
<ide> 'lft' => '10',
<ide> 'rght' => '19',
<del> 'depth' => 1
<add> 'depth' => 1,
<ide> ],
<ide> [
<ide> 'name' => 'mp3',
<ide> 'parent_id' => '6',
<ide> 'lft' => '11',
<ide> 'rght' => '14',
<del> 'depth' => 2
<add> 'depth' => 2,
<ide> ],
<ide> [
<ide> 'name' => 'flash',
<ide> 'parent_id' => '7',
<ide> 'lft' => '12',
<ide> 'rght' => '13',
<del> 'depth' => 3
<add> 'depth' => 3,
<ide> ],
<ide> [
<ide> 'name' => 'cd',
<ide> 'parent_id' => '6',
<ide> 'lft' => '15',
<ide> 'rght' => '16',
<del> 'depth' => 2
<add> 'depth' => 2,
<ide> ],
<ide> [
<ide> 'name' => 'radios',
<ide> 'parent_id' => '6',
<ide> 'lft' => '17',
<ide> 'rght' => '18',
<del> 'depth' => 2
<add> 'depth' => 2,
<ide> ],
<ide> [
<ide> 'name' => 'alien hardware',
<ide> 'parent_id' => null,
<ide> 'lft' => '21',
<ide> 'rght' => '22',
<del> 'depth' => 0
<del> ]
<add> 'depth' => 0,
<add> ],
<ide> ];
<ide> }
<ide><path>tests/Fixture/OrderedUuidItemsFixture.php
<ide> class OrderedUuidItemsFixture extends TestFixture
<ide> 'id' => ['type' => 'string', 'length' => 32],
<ide> 'published' => ['type' => 'boolean', 'null' => false],
<ide> 'name' => ['type' => 'string', 'null' => false],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/OrdersFixture.php
<ide> class OrdersFixture extends TestFixture
<ide> '_indexes' => [
<ide> 'product_category' => [
<ide> 'type' => 'index',
<del> 'columns' => ['product_category', 'product_id']
<del> ]
<add> 'columns' => ['product_category', 'product_id'],
<add> ],
<ide> ],
<ide> '_constraints' => [
<ide> 'primary' => [
<del> 'type' => 'primary', 'columns' => ['id']
<add> 'type' => 'primary', 'columns' => ['id'],
<ide> ],
<ide> 'product_category_fk' => [
<ide> 'type' => 'foreign',
<ide> 'columns' => ['product_category', 'product_id'],
<ide> 'references' => ['products', ['category', 'id']],
<ide> 'update' => 'cascade',
<ide> 'delete' => 'cascade',
<del> ]
<del> ]
<add> ],
<add> ],
<ide> ];
<ide>
<ide> /**
<ide> class OrdersFixture extends TestFixture
<ide> * @var array
<ide> */
<ide> public $records = [
<del> ['product_category' => 1, 'product_id' => 1]
<add> ['product_category' => 1, 'product_id' => 1],
<ide> ];
<ide> }
<ide><path>tests/Fixture/PolymorphicTaggedFixture.php
<ide> class PolymorphicTaggedFixture extends TestFixture
<ide> 'foreign_key' => ['type' => 'integer'],
<ide> 'foreign_model' => ['type' => 'string'],
<ide> 'position' => ['type' => 'integer', 'null' => true],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/PostsFixture.php
<ide> class PostsFixture extends TestFixture
<ide> 'title' => ['type' => 'string', 'null' => false],
<ide> 'body' => 'text',
<ide> 'published' => ['type' => 'string', 'length' => 1, 'default' => 'N'],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide> class PostsFixture extends TestFixture
<ide> public $records = [
<ide> ['author_id' => 1, 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y'],
<ide> ['author_id' => 3, 'title' => 'Second Post', 'body' => 'Second Post Body', 'published' => 'Y'],
<del> ['author_id' => 1, 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'Y']
<add> ['author_id' => 1, 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'Y'],
<ide> ];
<ide> }
<ide><path>tests/Fixture/ProductsFixture.php
<ide> class ProductsFixture extends TestFixture
<ide> 'category' => ['type' => 'integer', 'null' => false],
<ide> 'name' => ['type' => 'string', 'null' => false],
<ide> 'price' => ['type' => 'integer'],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['category', 'id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['category', 'id']]],
<ide> ];
<ide>
<ide> /**
<ide> class ProductsFixture extends TestFixture
<ide> public $records = [
<ide> ['id' => 1, 'category' => 1, 'name' => 'First product', 'price' => 10],
<ide> ['id' => 2, 'category' => 2, 'name' => 'Second product', 'price' => 20],
<del> ['id' => 3, 'category' => 3, 'name' => 'Third product', 'price' => 30]
<add> ['id' => 3, 'category' => 3, 'name' => 'Third product', 'price' => 30],
<ide> ];
<ide> }
<ide><path>tests/Fixture/ProfilesFixture.php
<ide> class ProfilesFixture extends TestFixture
<ide> 'is_active' => ['type' => 'boolean', 'null' => false, 'default' => true],
<ide> '_constraints' => [
<ide> 'primary' => ['type' => 'primary', 'columns' => ['id']],
<del> ]
<add> ],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/SessionsFixture.php
<ide> class SessionsFixture extends TestFixture
<ide> 'id' => ['type' => 'string', 'length' => 128],
<ide> 'data' => ['type' => 'binary', 'length' => TableSchema::LENGTH_MEDIUM, 'null' => true],
<ide> 'expires' => ['type' => 'integer', 'length' => 11, 'null' => true],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/SiteArticlesFixture.php
<ide> class SiteArticlesFixture extends TestFixture
<ide> 'site_id' => ['type' => 'integer', 'null' => false],
<ide> 'title' => ['type' => 'string', 'null' => true],
<ide> 'body' => 'text',
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id', 'site_id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id', 'site_id']]],
<ide> ];
<ide>
<ide> /**
<ide> class SiteArticlesFixture extends TestFixture
<ide> 'site_id' => 1,
<ide> 'title' => 'Fourth Article',
<ide> 'body' => 'Fourth Article Body',
<del> ]
<add> ],
<ide> ];
<ide> }
<ide><path>tests/Fixture/SiteArticlesTagsFixture.php
<ide> class SiteArticlesTagsFixture extends TestFixture
<ide> 'tag_id' => ['type' => 'integer', 'null' => false],
<ide> 'site_id' => ['type' => 'integer', 'null' => false],
<ide> '_constraints' => [
<del> 'UNIQUE_TAG2' => ['type' => 'primary', 'columns' => ['article_id', 'tag_id', 'site_id']]
<del> ]
<add> 'UNIQUE_TAG2' => ['type' => 'primary', 'columns' => ['article_id', 'tag_id', 'site_id']],
<add> ],
<ide> ];
<ide>
<ide> /**
<ide> class SiteArticlesTagsFixture extends TestFixture
<ide> ['article_id' => 1, 'tag_id' => 2, 'site_id' => 2],
<ide> ['article_id' => 2, 'tag_id' => 4, 'site_id' => 2],
<ide> ['article_id' => 4, 'tag_id' => 1, 'site_id' => 1],
<del> ['article_id' => 1, 'tag_id' => 3, 'site_id' => 1]
<add> ['article_id' => 1, 'tag_id' => 3, 'site_id' => 1],
<ide> ];
<ide> }
<ide><path>tests/Fixture/SiteAuthorsFixture.php
<ide> class SiteAuthorsFixture extends TestFixture
<ide> 'id' => ['type' => 'integer'],
<ide> 'name' => ['type' => 'string', 'default' => null],
<ide> 'site_id' => ['type' => 'integer', 'null' => false],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id', 'site_id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id', 'site_id']]],
<ide> ];
<ide>
<ide> /**
<ide> class SiteAuthorsFixture extends TestFixture
<ide> ['id' => 1, 'name' => 'mark', 'site_id' => 1],
<ide> ['id' => 2, 'name' => 'juan', 'site_id' => 2],
<ide> ['id' => 3, 'name' => 'jose', 'site_id' => 2],
<del> ['id' => 4, 'name' => 'andy', 'site_id' => 1]
<add> ['id' => 4, 'name' => 'andy', 'site_id' => 1],
<ide> ];
<ide> }
<ide><path>tests/Fixture/SiteTagsFixture.php
<ide> class SiteTagsFixture extends TestFixture
<ide> 'id' => ['type' => 'integer'],
<ide> 'site_id' => ['type' => 'integer'],
<ide> 'name' => ['type' => 'string', 'null' => false],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id', 'site_id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id', 'site_id']]],
<ide> ];
<ide>
<ide> /**
<ide> class SiteTagsFixture extends TestFixture
<ide> ['id' => 1, 'site_id' => 1, 'name' => 'tag1'],
<ide> ['id' => 2, 'site_id' => 2, 'name' => 'tag2'],
<ide> ['id' => 3, 'site_id' => 1, 'name' => 'tag3'],
<del> ['id' => 4, 'site_id' => 2, 'name' => 'tag4']
<add> ['id' => 4, 'site_id' => 2, 'name' => 'tag4'],
<ide> ];
<ide> }
<ide><path>tests/Fixture/SpecialTagsFixture.php
<ide> class SpecialTagsFixture extends TestFixture
<ide> 'author_id' => ['type' => 'integer', 'null' => true],
<ide> '_constraints' => [
<ide> 'primary' => ['type' => 'primary', 'columns' => ['id']],
<del> 'UNIQUE_TAG2' => ['type' => 'unique', 'columns' => ['article_id', 'tag_id']]
<del> ]
<add> 'UNIQUE_TAG2' => ['type' => 'unique', 'columns' => ['article_id', 'tag_id']],
<add> ],
<ide> ];
<ide>
<ide> /**
<ide> class SpecialTagsFixture extends TestFixture
<ide> public $records = [
<ide> ['article_id' => 1, 'tag_id' => 3, 'highlighted' => false, 'highlighted_time' => null, 'extra_info' => 'Foo', 'author_id' => 1],
<ide> ['article_id' => 2, 'tag_id' => 1, 'highlighted' => true, 'highlighted_time' => '2014-06-01 10:10:00', 'extra_info' => 'Bar', 'author_id' => 2],
<del> ['article_id' => 10, 'tag_id' => 10, 'highlighted' => true, 'highlighted_time' => '2014-06-01 10:10:00', 'extra_info' => 'Baz', 'author_id' => null]
<add> ['article_id' => 10, 'tag_id' => 10, 'highlighted' => true, 'highlighted_time' => '2014-06-01 10:10:00', 'extra_info' => 'Baz', 'author_id' => null],
<ide> ];
<ide> }
<ide><path>tests/Fixture/TagsFixture.php
<ide> class TagsFixture extends TestFixture
<ide> 'name' => ['type' => 'string', 'null' => false],
<ide> 'description' => ['type' => 'text', 'length' => TableSchema::LENGTH_MEDIUM],
<ide> 'created' => ['type' => 'datetime', 'null' => true, 'default' => null],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide> class TagsFixture extends TestFixture
<ide> public $records = [
<ide> ['name' => 'tag1', 'description' => 'A big description', 'created' => '2016-01-01 00:00'],
<ide> ['name' => 'tag2', 'description' => 'Another big description', 'created' => '2016-01-01 00:00'],
<del> ['name' => 'tag3', 'description' => 'Yet another one', 'created' => '2016-01-01 00:00']
<add> ['name' => 'tag3', 'description' => 'Yet another one', 'created' => '2016-01-01 00:00'],
<ide> ];
<ide> }
<ide><path>tests/Fixture/TagsTranslationsFixture.php
<ide> class TagsTranslationsFixture extends TestFixture
<ide> 'id' => ['type' => 'integer', 'null' => false, 'autoIncrement' => true],
<ide> 'locale' => ['type' => 'string', 'null' => false],
<ide> 'name' => ['type' => 'string', 'null' => false],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide> class TagsTranslationsFixture extends TestFixture
<ide> public $records = [
<ide> ['locale' => 'en_us', 'name' => 'tag 1 translated into en_us'],
<ide> ['locale' => 'en_us', 'name' => 'tag 2 translated into en_us'],
<del> ['locale' => 'en_us', 'name' => 'tag 3 translated into en_us']
<add> ['locale' => 'en_us', 'name' => 'tag 3 translated into en_us'],
<ide> ];
<ide> }
<ide><path>tests/Fixture/TestPluginCommentsFixture.php
<ide> class TestPluginCommentsFixture extends TestFixture
<ide> 'published' => ['type' => 'string', 'length' => 1, 'default' => 'N'],
<ide> 'created' => 'datetime',
<ide> 'updated' => 'datetime',
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide> class TestPluginCommentsFixture extends TestFixture
<ide> ['article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Plugin Article', 'published' => 'Y', 'created' => '2008-09-24 10:49:23', 'updated' => '2008-09-24 10:51:31'],
<ide> ['article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Plugin Article', 'published' => 'N', 'created' => '2008-09-24 10:51:23', 'updated' => '2008-09-24 10:53:31'],
<ide> ['article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Plugin Article', 'published' => 'Y', 'created' => '2008-09-24 10:53:23', 'updated' => '2008-09-24 10:55:31'],
<del> ['article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Plugin Article', 'published' => 'Y', 'created' => '2008-09-24 10:55:23', 'updated' => '2008-09-24 10:57:31']
<add> ['article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Plugin Article', 'published' => 'Y', 'created' => '2008-09-24 10:55:23', 'updated' => '2008-09-24 10:57:31'],
<ide> ];
<ide> }
<ide><path>tests/Fixture/ThingsFixture.php
<ide> class ThingsFixture extends TestFixture
<ide> public $fields = [
<ide> 'id' => ['type' => 'integer'],
<ide> 'title' => ['type' => 'string', 'length' => 20],
<del> 'body' => ['type' => 'string', 'length' => 50]
<add> 'body' => ['type' => 'string', 'length' => 50],
<ide> ];
<ide>
<ide> /**
<ide> class ThingsFixture extends TestFixture
<ide> */
<ide> public $records = [
<ide> ['id' => 1, 'title' => 'a title', 'body' => 'a body'],
<del> ['id' => 2, 'title' => 'another title', 'body' => 'another body']
<add> ['id' => 2, 'title' => 'another title', 'body' => 'another body'],
<ide> ];
<ide> }
<ide><path>tests/Fixture/TranslatesFixture.php
<ide> class TranslatesFixture extends TestFixture
<ide> 'foreign_key' => ['type' => 'integer', 'null' => false],
<ide> 'field' => ['type' => 'string', 'null' => false],
<ide> 'content' => ['type' => 'text'],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/UsersFixture.php
<ide> class UsersFixture extends TestFixture
<ide> 'password' => ['type' => 'string', 'null' => true],
<ide> 'created' => ['type' => 'timestamp', 'null' => true],
<ide> 'updated' => ['type' => 'timestamp', 'null' => true],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/Fixture/UuiditemsFixture.php
<ide> class UuiditemsFixture extends TestFixture
<ide> 'id' => ['type' => 'uuid'],
<ide> 'published' => ['type' => 'boolean', 'null' => false],
<ide> 'name' => ['type' => 'string', 'null' => false],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide> class UuiditemsFixture extends TestFixture
<ide> ['id' => '482b7756-8da0-419a-b21f-27da40cf8569', 'published' => 0, 'name' => 'Item 3'],
<ide> ['id' => '482cfd4b-0e7c-4ea3-9582-4cec40cf8569', 'published' => 0, 'name' => 'Item 4'],
<ide> ['id' => '4831181b-4020-4983-a29b-131440cf8569', 'published' => 0, 'name' => 'Item 5'],
<del> ['id' => '483798c8-c7cc-430e-8cf9-4fcc40cf8569', 'published' => 0, 'name' => 'Item 6']
<add> ['id' => '483798c8-c7cc-430e-8cf9-4fcc40cf8569', 'published' => 0, 'name' => 'Item 6'],
<ide> ];
<ide> }
<ide><path>tests/Fixture/UuidportfoliosFixture.php
<ide> class UuidportfoliosFixture extends TestFixture
<ide> public $fields = [
<ide> 'id' => ['type' => 'uuid'],
<ide> 'name' => ['type' => 'string', 'null' => false],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<ide> ];
<ide>
<ide> /**
<ide><path>tests/TestCase/Auth/BasicAuthenticateTest.php
<ide> public function setUp()
<ide> $this->Collection = $this->getMockBuilder(ComponentRegistry::class)->getMock();
<ide> $this->auth = new BasicAuthenticate($this->Collection, [
<ide> 'userModel' => 'Users',
<del> 'realm' => 'localhost'
<add> 'realm' => 'localhost',
<ide> ]);
<ide>
<ide> $password = password_hash('password', PASSWORD_BCRYPT);
<ide> public function testConstructor()
<ide> {
<ide> $object = new BasicAuthenticate($this->Collection, [
<ide> 'userModel' => 'AuthUser',
<del> 'fields' => ['username' => 'user', 'password' => 'password']
<add> 'fields' => ['username' => 'user', 'password' => 'password'],
<ide> ]);
<ide> $this->assertEquals('AuthUser', $object->getConfig('userModel'));
<ide> $this->assertEquals(['username' => 'user', 'password' => 'password'], $object->getConfig('fields'));
<ide> public function testAuthenticateNoUsername()
<ide> {
<ide> $request = new ServerRequest([
<ide> 'url' => 'posts/index',
<del> 'environment' => ['PHP_AUTH_PW' => 'foobar']
<add> 'environment' => ['PHP_AUTH_PW' => 'foobar'],
<ide> ]);
<ide>
<ide> $this->assertFalse($this->auth->authenticate($request, $this->response));
<ide> public function testAuthenticateNoPassword()
<ide> {
<ide> $request = new ServerRequest([
<ide> 'url' => 'posts/index',
<del> 'environment' => ['PHP_AUTH_USER' => 'mariano']
<add> 'environment' => ['PHP_AUTH_USER' => 'mariano'],
<ide> ]);
<ide>
<ide> $this->assertFalse($this->auth->authenticate($request, $this->response));
<ide> public function testAuthenticateInjection()
<ide> 'url' => 'posts/index',
<ide> 'environment' => [
<ide> 'PHP_AUTH_USER' => '> 1',
<del> 'PHP_AUTH_PW' => "' OR 1 = 1"
<add> 'PHP_AUTH_PW' => "' OR 1 = 1",
<ide> ],
<ide> ]);
<ide>
<ide> public function testAuthenticateUsernameZero()
<ide> 'data' => [
<ide> 'User' => [
<ide> 'user' => '0',
<del> 'password' => 'password'
<del> ]
<del> ]
<add> 'password' => 'password',
<add> ],
<add> ],
<ide> ]);
<ide> $_SERVER['PHP_AUTH_USER'] = '0';
<ide> $_SERVER['PHP_AUTH_PW'] = 'password';
<ide> public function testAuthenticateSuccess()
<ide> 'url' => 'posts/index',
<ide> 'environment' => [
<ide> 'PHP_AUTH_USER' => 'mariano',
<del> 'PHP_AUTH_PW' => 'password'
<del> ]
<add> 'PHP_AUTH_PW' => 'password',
<add> ],
<ide> ]);
<ide>
<ide> $result = $this->auth->authenticate($request, $this->response);
<ide> $expected = [
<ide> 'id' => 1,
<ide> 'username' => 'mariano',
<ide> 'created' => new Time('2007-03-17 01:16:23'),
<del> 'updated' => new Time('2007-03-17 01:18:31')
<add> 'updated' => new Time('2007-03-17 01:18:31'),
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testAuthenticateFailReChallenge()
<ide> 'url' => 'posts/index',
<ide> 'environment' => [
<ide> 'PHP_AUTH_USER' => 'mariano',
<del> 'PHP_AUTH_PW' => 'password'
<del> ]
<add> 'PHP_AUTH_PW' => 'password',
<add> ],
<ide> ]);
<ide>
<ide> $this->auth->unauthenticated($request, $this->response);
<ide><path>tests/TestCase/Auth/DigestAuthenticateTest.php
<ide> public function setUp()
<ide> $this->auth = new DigestAuthenticate($this->Collection, [
<ide> 'realm' => 'localhost',
<ide> 'nonce' => 123,
<del> 'opaque' => '123abc'
<add> 'opaque' => '123abc',
<ide> ]);
<ide>
<ide> $password = DigestAuthenticate::password('mariano', 'cake', 'localhost');
<ide> public function testConstructor()
<ide> $object = new DigestAuthenticate($this->Collection, [
<ide> 'userModel' => 'AuthUser',
<ide> 'fields' => ['username' => 'user', 'password' => 'pass'],
<del> 'nonce' => 123456
<add> 'nonce' => 123456,
<ide> ]);
<ide> $this->assertEquals('AuthUser', $object->getConfig('userModel'));
<ide> $this->assertEquals(['username' => 'user', 'password' => 'pass'], $object->getConfig('fields'));
<ide> public function testAuthenticateWrongUsername()
<ide> 'uri' => '/dir/index.html',
<ide> 'qop' => 'auth',
<ide> 'nc' => 0000001,
<del> 'cnonce' => '0a4f113b'
<add> 'cnonce' => '0a4f113b',
<ide> ];
<ide> $data['response'] = $this->auth->generateResponseHash($data, '09faa9931501bf30f0d4253fa7763022', 'GET');
<ide> $request = $request->withEnv('PHP_AUTH_DIGEST', $this->digestHeader($data));
<ide> public function testAuthenticateChallenge()
<ide> {
<ide> $request = new ServerRequest([
<ide> 'url' => 'posts/index',
<del> 'environment' => ['REQUEST_METHOD' => 'GET']
<add> 'environment' => ['REQUEST_METHOD' => 'GET'],
<ide> ]);
<ide>
<ide> try {
<ide> public function testAuthenticateChallengeIncludesStaleAttributeOnStaleNonce()
<ide> {
<ide> $request = new ServerRequest([
<ide> 'url' => 'posts/index',
<del> 'environment' => ['REQUEST_METHOD' => 'GET']
<add> 'environment' => ['REQUEST_METHOD' => 'GET'],
<ide> ]);
<ide> $data = [
<ide> 'uri' => '/dir/index.html',
<ide> public function testAuthenticateFailsOnStaleNonce()
<ide> {
<ide> $request = new ServerRequest([
<ide> 'url' => 'posts/index',
<del> 'environment' => ['REQUEST_METHOD' => 'GET']
<add> 'environment' => ['REQUEST_METHOD' => 'GET'],
<ide> ]);
<ide>
<ide> $data = [
<ide> public function testAuthenticateValidUsernamePasswordNoNonce()
<ide> {
<ide> $request = new ServerRequest([
<ide> 'url' => 'posts/index',
<del> 'environment' => ['REQUEST_METHOD' => 'GET']
<add> 'environment' => ['REQUEST_METHOD' => 'GET'],
<ide> ]);
<ide>
<ide> $data = [
<ide> public function testAuthenticateSuccess()
<ide> {
<ide> $request = new ServerRequest([
<ide> 'url' => 'posts/index',
<del> 'environment' => ['REQUEST_METHOD' => 'GET']
<add> 'environment' => ['REQUEST_METHOD' => 'GET'],
<ide> ]);
<ide>
<ide> $data = [
<ide> public function testAuthenticateSuccess()
<ide> 'id' => 1,
<ide> 'username' => 'mariano',
<ide> 'created' => new Time('2007-03-17 01:16:23'),
<del> 'updated' => new Time('2007-03-17 01:18:31')
<add> 'updated' => new Time('2007-03-17 01:18:31'),
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testAuthenticateSuccessHiddenPasswordField()
<ide>
<ide> $request = new ServerRequest([
<ide> 'url' => 'posts/index',
<del> 'environment' => ['REQUEST_METHOD' => 'GET']
<add> 'environment' => ['REQUEST_METHOD' => 'GET'],
<ide> ]);
<ide>
<ide> $data = [
<ide> public function testAuthenticateSuccessHiddenPasswordField()
<ide> 'id' => 1,
<ide> 'username' => 'mariano',
<ide> 'created' => new Time('2007-03-17 01:16:23'),
<del> 'updated' => new Time('2007-03-17 01:18:31')
<add> 'updated' => new Time('2007-03-17 01:18:31'),
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testAuthenticateSuccessSimulatedRequestMethod()
<ide> $request = new ServerRequest([
<ide> 'url' => 'posts/index',
<ide> 'post' => ['_method' => 'PUT'],
<del> 'environment' => ['REQUEST_METHOD' => 'GET']
<add> 'environment' => ['REQUEST_METHOD' => 'GET'],
<ide> ]);
<ide>
<ide> $data = [
<ide> public function testAuthenticateSuccessSimulatedRequestMethod()
<ide> 'id' => 1,
<ide> 'username' => 'mariano',
<ide> 'created' => new Time('2007-03-17 01:16:23'),
<del> 'updated' => new Time('2007-03-17 01:18:31')
<add> 'updated' => new Time('2007-03-17 01:18:31'),
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testAuthenticateFailReChallenge()
<ide> $this->auth->setConfig('scope.username', 'nate');
<ide> $request = new ServerRequest([
<ide> 'url' => 'posts/index',
<del> 'environment' => ['REQUEST_METHOD' => 'GET']
<add> 'environment' => ['REQUEST_METHOD' => 'GET'],
<ide> ]);
<ide>
<ide> $data = [
<ide> public function testAuthenticateFailReChallenge()
<ide> public function testLoginHeaders()
<ide> {
<ide> $request = new ServerRequest([
<del> 'environment' => ['SERVER_NAME' => 'localhost']
<add> 'environment' => ['SERVER_NAME' => 'localhost'],
<ide> ]);
<ide> $this->auth = new DigestAuthenticate($this->Collection, [
<ide> 'realm' => 'localhost',
<ide> public function testParseAuthData()
<ide> 'nc' => '00000001',
<ide> 'cnonce' => '0a4f113b',
<ide> 'response' => '6629fae49393a05397450978507c4ef1',
<del> 'opaque' => '5ccc069c403ebaf9f0171e9517f40e41'
<add> 'opaque' => '5ccc069c403ebaf9f0171e9517f40e41',
<ide> ];
<ide> $result = $this->auth->parseAuthData($digest);
<ide> $this->assertSame($expected, $result);
<ide> public function testParseAuthEmailAddress()
<ide> 'nc' => '00000001',
<ide> 'cnonce' => '0a4f113b',
<ide> 'response' => '6629fae49393a05397450978507c4ef1',
<del> 'opaque' => '5ccc069c403ebaf9f0171e9517f40e41'
<add> 'opaque' => '5ccc069c403ebaf9f0171e9517f40e41',
<ide> ];
<ide> $result = $this->auth->parseAuthData($digest);
<ide> $this->assertSame($expected, $result);
<ide> protected function digestHeader($data)
<ide> $data += [
<ide> 'username' => 'mariano',
<ide> 'realm' => 'localhost',
<del> 'opaque' => '123abc'
<add> 'opaque' => '123abc',
<ide> ];
<ide> $digest = <<<DIGEST
<ide> Digest username="mariano",
<ide><path>tests/TestCase/Auth/FormAuthenticateTest.php
<ide> public function setUp()
<ide> parent::setUp();
<ide> $this->Collection = $this->getMockBuilder(ComponentRegistry::class)->getMock();
<ide> $this->auth = new FormAuthenticate($this->Collection, [
<del> 'userModel' => 'Users'
<add> 'userModel' => 'Users',
<ide> ]);
<ide> $password = password_hash('password', PASSWORD_DEFAULT);
<ide>
<ide> public function setUp()
<ide> $Users->updateAll(['password' => $password], []);
<ide>
<ide> $AuthUsers = $this->getTableLocator()->get('AuthUsers', [
<del> 'className' => 'TestApp\Model\Table\AuthUsersTable'
<add> 'className' => 'TestApp\Model\Table\AuthUsersTable',
<ide> ]);
<ide> $AuthUsers->updateAll(['password' => $password], []);
<ide>
<ide> public function testConstructor()
<ide> {
<ide> $object = new FormAuthenticate($this->Collection, [
<ide> 'userModel' => 'AuthUsers',
<del> 'fields' => ['username' => 'user', 'password' => 'password']
<add> 'fields' => ['username' => 'user', 'password' => 'password'],
<ide> ]);
<ide> $this->assertEquals('AuthUsers', $object->getConfig('userModel'));
<ide> $this->assertEquals(['username' => 'user', 'password' => 'password'], $object->getConfig('fields'));
<ide> public function testAuthenticatePasswordIsFalse()
<ide> 'url' => 'posts/index',
<ide> 'post' => [
<ide> 'username' => 'mariano',
<del> 'password' => null
<add> 'password' => null,
<ide> ],
<ide> ]);
<ide> $this->assertFalse($this->auth->authenticate($request, $this->response));
<ide> public function testAuthenticatePasswordIsEmptyString()
<ide> 'url' => 'posts/index',
<ide> 'post' => [
<ide> 'username' => 'mariano',
<del> 'password' => ''
<add> 'password' => '',
<ide> ],
<ide> ]);
<ide>
<ide> $this->auth = $this->getMockBuilder(FormAuthenticate::class)
<ide> ->setMethods(['_checkFields'])
<ide> ->setConstructorArgs([
<ide> $this->Collection,
<del> ['userModel' => 'Users']
<add> ['userModel' => 'Users'],
<ide> ])
<ide> ->getMock();
<ide>
<ide> public function testAuthenticateFieldsAreNotString()
<ide> 'url' => 'posts/index',
<ide> 'post' => [
<ide> 'username' => ['mariano', 'phpnut'],
<del> 'password' => 'my password'
<add> 'password' => 'my password',
<ide> ],
<ide> ]);
<ide> $this->assertFalse($this->auth->authenticate($request, $this->response));
<ide> public function testAuthenticateFieldsAreNotString()
<ide> 'url' => 'posts/index',
<ide> 'post' => [
<ide> 'username' => 'mariano',
<del> 'password' => ['password1', 'password2']
<add> 'password' => ['password1', 'password2'],
<ide> ],
<ide> ]);
<ide> $this->assertFalse($this->auth->authenticate($request, $this->response));
<ide> public function testAuthenticateInjection()
<ide> 'url' => 'posts/index',
<ide> 'post' => [
<ide> 'username' => '> 1',
<del> 'password' => "' OR 1 = 1"
<add> 'password' => "' OR 1 = 1",
<ide> ],
<ide> ]);
<ide> $this->assertFalse($this->auth->authenticate($request, $this->response));
<ide> public function testAuthenticateSuccess()
<ide> 'url' => 'posts/index',
<ide> 'post' => [
<ide> 'username' => 'mariano',
<del> 'password' => 'password'
<add> 'password' => 'password',
<ide> ],
<ide> ]);
<ide> $result = $this->auth->authenticate($request, $this->response);
<ide> $expected = [
<ide> 'id' => 1,
<ide> 'username' => 'mariano',
<ide> 'created' => new Time('2007-03-17 01:16:23'),
<del> 'updated' => new Time('2007-03-17 01:18:31')
<add> 'updated' => new Time('2007-03-17 01:18:31'),
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testAuthenticateIncludesVirtualFields()
<ide> 'url' => 'posts/index',
<ide> 'post' => [
<ide> 'username' => 'mariano',
<del> 'password' => 'password'
<add> 'password' => 'password',
<ide> ],
<ide> ]);
<ide> $result = $this->auth->authenticate($request, $this->response);
<ide> public function testAuthenticateIncludesVirtualFields()
<ide> 'username' => 'mariano',
<ide> 'bonus' => 'bonus',
<ide> 'created' => new Time('2007-03-17 01:16:23'),
<del> 'updated' => new Time('2007-03-17 01:18:31')
<add> 'updated' => new Time('2007-03-17 01:18:31'),
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testPluginModel()
<ide> 'url' => 'posts/index',
<ide> 'post' => [
<ide> 'username' => 'gwoo',
<del> 'password' => 'cake'
<add> 'password' => 'cake',
<ide> ],
<ide> ]);
<ide>
<ide> public function testPluginModel()
<ide> 'id' => 1,
<ide> 'username' => 'gwoo',
<ide> 'created' => new Time('2007-03-17 01:16:23'),
<del> 'updated' => new Time('2007-03-17 01:18:31')
<add> 'updated' => new Time('2007-03-17 01:18:31'),
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> $this->clearPlugins();
<ide> public function testFinder()
<ide> 'url' => 'posts/index',
<ide> 'post' => [
<ide> 'username' => 'mariano',
<del> 'password' => 'password'
<add> 'password' => 'password',
<ide> ],
<ide> ]);
<ide>
<ide> $this->auth->setConfig([
<ide> 'userModel' => 'AuthUsers',
<del> 'finder' => 'auth'
<add> 'finder' => 'auth',
<ide> ]);
<ide>
<ide> $result = $this->auth->authenticate($request, $this->response);
<ide> public function testFinder()
<ide> $this->assertEquals($expected, $result, 'Result should not contain "created" and "modified" fields');
<ide>
<ide> $this->auth->setConfig([
<del> 'finder' => ['auth' => ['return_created' => true]]
<add> 'finder' => ['auth' => ['return_created' => true]],
<ide> ]);
<ide>
<ide> $result = $this->auth->authenticate($request, $this->response);
<ide> public function testFinderOptions()
<ide> 'url' => 'posts/index',
<ide> 'post' => [
<ide> 'username' => 'mariano',
<del> 'password' => 'password'
<add> 'password' => 'password',
<ide> ],
<ide> ]);
<ide>
<ide> $this->auth->setConfig([
<ide> 'userModel' => 'AuthUsers',
<del> 'finder' => 'username'
<add> 'finder' => 'username',
<ide> ]);
<ide>
<ide> $result = $this->auth->authenticate($request, $this->response);
<ide> public function testFinderOptions()
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $this->auth->setConfig([
<del> 'finder' => ['username' => ['username' => 'nate']]
<add> 'finder' => ['username' => ['username' => 'nate']],
<ide> ]);
<ide>
<ide> $result = $this->auth->authenticate($request, $this->response);
<ide> public function testPasswordHasherSettings()
<ide> {
<ide> $this->auth->setConfig('passwordHasher', [
<ide> 'className' => 'Default',
<del> 'hashType' => PASSWORD_BCRYPT
<add> 'hashType' => PASSWORD_BCRYPT,
<ide> ]);
<ide>
<ide> $passwordHasher = $this->auth->passwordHasher();
<ide> public function testPasswordHasherSettings()
<ide> 'url' => 'posts/index',
<ide> 'post' => [
<ide> 'username' => 'mariano',
<del> 'password' => 'mypass'
<add> 'password' => 'mypass',
<ide> ],
<ide> ]);
<ide>
<ide> public function testPasswordHasherSettings()
<ide> 'id' => 1,
<ide> 'username' => 'mariano',
<ide> 'created' => new Time('2007-03-17 01:16:23'),
<del> 'updated' => new Time('2007-03-17 01:18:31')
<add> 'updated' => new Time('2007-03-17 01:18:31'),
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $this->auth = new FormAuthenticate($this->Collection, [
<ide> 'fields' => ['username' => 'username', 'password' => 'password'],
<del> 'userModel' => 'Users'
<add> 'userModel' => 'Users',
<ide> ]);
<ide> $this->auth->setConfig('passwordHasher', [
<del> 'className' => 'Default'
<add> 'className' => 'Default',
<ide> ]);
<ide> $this->assertEquals($expected, $this->auth->authenticate($request, $this->response));
<ide>
<ide> public function testAuthenticateNoRehash()
<ide> 'url' => 'posts/index',
<ide> 'post' => [
<ide> 'username' => 'mariano',
<del> 'password' => 'password'
<add> 'password' => 'password',
<ide> ],
<ide> ]);
<ide> $result = $this->auth->authenticate($request, $this->response);
<ide> public function testAuthenticateRehash()
<ide> {
<ide> $this->auth = new FormAuthenticate($this->Collection, [
<ide> 'userModel' => 'Users',
<del> 'passwordHasher' => 'Weak'
<add> 'passwordHasher' => 'Weak',
<ide> ]);
<ide> $password = $this->auth->passwordHasher()->hash('password');
<ide> $this->getTableLocator()->get('Users')->updateAll(['password' => $password], []);
<ide> public function testAuthenticateRehash()
<ide> 'url' => 'posts/index',
<ide> 'post' => [
<ide> 'username' => 'mariano',
<del> 'password' => 'password'
<add> 'password' => 'password',
<ide> ],
<ide> ]);
<ide> $result = $this->auth->authenticate($request, $this->response);
<ide><path>tests/TestCase/Auth/PasswordHasherFactoryTest.php
<ide> public function testBuild()
<ide>
<ide> $hasher = PasswordHasherFactory::build([
<ide> 'className' => 'Default',
<del> 'hashOptions' => ['foo' => 'bar']
<add> 'hashOptions' => ['foo' => 'bar'],
<ide> ]);
<ide> $this->assertInstanceof('Cake\Auth\DefaultPasswordHasher', $hasher);
<ide> $this->assertEquals(['foo' => 'bar'], $hasher->getConfig('hashOptions'));
<ide><path>tests/TestCase/BasicsTest.php
<ide> public function testH()
<ide> $result = h($arr);
<ide> $expected = [
<ide> '<foo>',
<del> '&nbsp;'
<add> '&nbsp;',
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $arr = ['<foo>', ' '];
<ide> $result = h($arr, false);
<ide> $expected = [
<ide> '<foo>',
<del> ' '
<add> ' ',
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $arr = ['f' => '<foo>', 'n' => ' '];
<ide> $result = h($arr, false);
<ide> $expected = [
<ide> 'f' => '<foo>',
<del> 'n' => ' '
<add> 'n' => ' ',
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide>
<ide><path>tests/TestCase/Cache/CacheTest.php
<ide> protected function _configCache()
<ide> Cache::setConfig('tests', [
<ide> 'engine' => 'File',
<ide> 'path' => CACHE,
<del> 'prefix' => 'test_'
<add> 'prefix' => 'test_',
<ide> ]);
<ide> }
<ide>
<ide> public function testCacheEngineFallback()
<ide> 'engine' => 'File',
<ide> 'path' => $filename,
<ide> 'prefix' => 'test_',
<del> 'fallback' => 'tests_fallback'
<add> 'fallback' => 'tests_fallback',
<ide> ]);
<ide> Cache::setConfig('tests_fallback', [
<ide> 'engine' => 'File',
<ide> public function testCacheEngineFallbackDisabled()
<ide> 'engine' => 'File',
<ide> 'path' => $filename,
<ide> 'prefix' => 'test_',
<del> 'fallback' => false
<add> 'fallback' => false,
<ide> ]);
<ide>
<ide> $engine = Cache::engine('tests');
<ide> public function testCacheEngineFallbackToSelf()
<ide> 'engine' => 'File',
<ide> 'path' => $filename,
<ide> 'prefix' => 'test_',
<del> 'fallback' => 'tests'
<add> 'fallback' => 'tests',
<ide> ]);
<ide>
<ide> $e = null;
<ide> public function testCacheFallbackIntegration()
<ide> 'engine' => 'File',
<ide> 'path' => $filename,
<ide> 'fallback' => 'tests_fallback',
<del> 'groups' => ['integration_group', 'integration_group_2']
<add> 'groups' => ['integration_group', 'integration_group_2'],
<ide> ]);
<ide> Cache::setConfig('tests_fallback', [
<ide> 'engine' => 'File',
<ide> public function testConfigInvalidClassType()
<ide> $this->expectExceptionMessage('Cache engines must use Cake\Cache\CacheEngine');
<ide>
<ide> Cache::setConfig('tests', [
<del> 'className' => '\StdClass'
<add> 'className' => '\StdClass',
<ide> ]);
<ide> $result = Cache::engine('tests');
<ide> $this->assertInstanceOf(NullEngine::class, $result);
<ide> public function testConfigFailedInit()
<ide> $mock = $this->getMockForAbstractClass('Cake\Cache\CacheEngine', [], '', true, true, true, ['init']);
<ide> $mock->method('init')->will($this->returnValue(false));
<ide> Cache::setConfig('tests', [
<del> 'engine' => $mock
<add> 'engine' => $mock,
<ide> ]);
<ide> $result = Cache::engine('tests');
<ide> $this->assertInstanceOf(NullEngine::class, $result);
<ide> public static function configProvider()
<ide> 'Array of data using engine key.' => [[
<ide> 'engine' => 'File',
<ide> 'path' => CACHE . 'tests',
<del> 'prefix' => 'cake_test_'
<add> 'prefix' => 'cake_test_',
<ide> ]],
<ide> 'Array of data using classname key.' => [[
<ide> 'className' => 'File',
<ide> 'path' => CACHE . 'tests',
<del> 'prefix' => 'cake_test_'
<add> 'prefix' => 'cake_test_',
<ide> ]],
<ide> 'Direct instance' => [new FileEngine()],
<ide> ];
<ide> public function testConfigInvalidObject()
<ide> ->setMockClassName('RubbishEngine')
<ide> ->getMock();
<ide> Cache::setConfig('test', [
<del> 'engine' => '\RubbishEngine'
<add> 'engine' => '\RubbishEngine',
<ide> ]);
<ide> Cache::engine('tests');
<ide> }
<ide> public function testConfigReadCompat()
<ide> $config = [
<ide> 'engine' => 'File',
<ide> 'path' => CACHE,
<del> 'prefix' => 'cake_'
<add> 'prefix' => 'cake_',
<ide> ];
<ide> Cache::config('tests', $config);
<ide> $expected = $config;
<ide> public function testConfigRead()
<ide> $config = [
<ide> 'engine' => 'File',
<ide> 'path' => CACHE,
<del> 'prefix' => 'cake_'
<add> 'prefix' => 'cake_',
<ide> ];
<ide> Cache::setConfig('tests', $config);
<ide> $expected = $config;
<ide> public function testConfigDottedAlias()
<ide> Cache::setConfig('cache.dotted', [
<ide> 'className' => 'File',
<ide> 'path' => CACHE,
<del> 'prefix' => 'cache_value_'
<add> 'prefix' => 'cache_value_',
<ide> ]);
<ide>
<ide> $engine = Cache::engine('cache.dotted');
<ide> public function testDrop()
<ide> $this->assertFalse($result, 'Drop should not succeed when config is missing.');
<ide>
<ide> Cache::setConfig('unconfigTest', [
<del> 'engine' => 'TestAppCache'
<add> 'engine' => 'TestAppCache',
<ide> ]);
<ide> $this->assertInstanceOf(
<ide> 'TestApp\Cache\Engine\TestAppCacheEngine',
<ide> public function testReadWriteMany()
<ide> 'App.trueTest' => true,
<ide> 'App.nullTest' => null,
<ide> 'App.zeroTest' => 0,
<del> 'App.zeroTest2' => '0'
<add> 'App.zeroTest2' => '0',
<ide> ];
<ide> Cache::writeMany($data, 'tests');
<ide>
<ide> public function testDeleteMany()
<ide> 'App.trueTest' => true,
<ide> 'App.nullTest' => null,
<ide> 'App.zeroTest' => 0,
<del> 'App.zeroTest2' => '0'
<add> 'App.zeroTest2' => '0',
<ide> ];
<ide> Cache::writeMany(array_merge($data, ['App.keepTest' => 'keepMe']), 'tests');
<ide>
<ide> public function testWriteTriggerError()
<ide> static::setAppNamespace();
<ide> Cache::setConfig('test_trigger', [
<ide> 'engine' => 'TestAppCache',
<del> 'prefix' => ''
<add> 'prefix' => '',
<ide> ]);
<ide>
<ide> Cache::write('fail', 'value', 'test_trigger');
<ide> public function testCacheDisable()
<ide> Cache::enable();
<ide> Cache::setConfig('test_cache_disable_1', [
<ide> 'engine' => 'File',
<del> 'path' => CACHE . 'tests'
<add> 'path' => CACHE . 'tests',
<ide> ]);
<ide>
<ide> $this->assertTrue(Cache::write('key_1', 'hello', 'test_cache_disable_1'));
<ide> public function testCacheDisable()
<ide> Cache::disable();
<ide> Cache::setConfig('test_cache_disable_2', [
<ide> 'engine' => 'File',
<del> 'path' => CACHE . 'tests'
<add> 'path' => CACHE . 'tests',
<ide> ]);
<ide>
<ide> $this->assertTrue(Cache::write('key_4', 'hello', 'test_cache_disable_2'));
<ide> public function testClearAll()
<ide> {
<ide> Cache::setConfig('configTest', [
<ide> 'engine' => 'File',
<del> 'path' => CACHE . 'tests'
<add> 'path' => CACHE . 'tests',
<ide> ]);
<ide> Cache::setConfig('anotherConfigTest', [
<ide> 'engine' => 'File',
<del> 'path' => CACHE . 'tests'
<add> 'path' => CACHE . 'tests',
<ide> ]);
<ide>
<ide> Cache::write('key_1', 'hello', 'configTest');
<ide><path>tests/TestCase/Cache/Engine/FileEngineTest.php
<ide> public function testClearWithPrefixes()
<ide> $FileOne = new FileEngine();
<ide> $FileOne->init([
<ide> 'prefix' => 'prefix_one_',
<del> 'duration' => DAY
<add> 'duration' => DAY,
<ide> ]);
<ide> $FileTwo = new FileEngine();
<ide> $FileTwo->init([
<ide> 'prefix' => 'prefix_two_',
<del> 'duration' => DAY
<add> 'duration' => DAY,
<ide> ]);
<ide>
<ide> $dataOne = $dataTwo = $expected = 'content to cache';
<ide> public function testClearWithGroups()
<ide> $engine->init([
<ide> 'prefix' => 'cake_test_',
<ide> 'duration' => DAY,
<del> 'groups' => ['short', 'round']
<add> 'groups' => ['short', 'round'],
<ide> ]);
<ide> $key = 'cake_test_test_key';
<ide> $engine->write($key, 'it works');
<ide> public function testClearWithNoKeys()
<ide> $engine->init([
<ide> 'prefix' => 'cake_test_',
<ide> 'duration' => DAY,
<del> 'groups' => ['one', 'two']
<add> 'groups' => ['one', 'two'],
<ide> ]);
<ide> $key = 'cake_test_test_key';
<ide> $engine->clear(false);
<ide> public function testRemoveWindowsSlashesFromCache()
<ide> 'engine' => 'File',
<ide> 'isWindows' => true,
<ide> 'prefix' => null,
<del> 'path' => CACHE
<add> 'path' => CACHE,
<ide> ]);
<ide>
<ide> $expected = [
<ide> public function testRemoveWindowsSlashesFromCache()
<ide> 6 => 'C:\dev\prj2\sites\vendors\simpletest\extensions\testdox', 7 => 'C:\dev\prj2\sites\vendors\simpletest\docs',
<ide> 8 => 'C:\dev\prj2\sites\vendors\simpletest\docs\fr', 9 => 'C:\dev\prj2\sites\vendors\simpletest\docs\en'],
<ide> 'C:\dev\prj2\sites\main_site\views\helpers' => [
<del> 0 => 'C:\dev\prj2\sites\main_site\views\helpers']
<add> 0 => 'C:\dev\prj2\sites\main_site\views\helpers'],
<ide> ];
<ide>
<ide> Cache::write('test_dir_map', $expected, 'windows_test');
<ide> public function testWriteQuotedString()
<ide> Cache::setConfig('file_test', [
<ide> 'className' => 'File',
<ide> 'isWindows' => true,
<del> 'path' => TMP . 'tests'
<add> 'path' => TMP . 'tests',
<ide> ]);
<ide>
<ide> $this->assertSame(Cache::read('App.doubleQuoteTest', 'file_test'), '"this is a quoted string"');
<ide> public function testPathDoesNotExist()
<ide> Cache::drop('file_test');
<ide> Cache::setConfig('file_test', [
<ide> 'engine' => 'File',
<del> 'path' => $dir
<add> 'path' => $dir,
<ide> ]);
<ide>
<ide> Cache::read('Test', 'file_test');
<ide> public function testPathDoesNotExistDebugOff()
<ide> Cache::drop('file_test');
<ide> Cache::setConfig('file_test', [
<ide> 'engine' => 'File',
<del> 'path' => $dir
<add> 'path' => $dir,
<ide> ]);
<ide>
<ide> Cache::read('Test', 'file_test');
<ide> public function testGroupsReadWrite()
<ide> Cache::setConfig('file_groups', [
<ide> 'engine' => 'File',
<ide> 'duration' => 3600,
<del> 'groups' => ['group_a', 'group_b']
<add> 'groups' => ['group_a', 'group_b'],
<ide> ]);
<ide> $this->assertTrue(Cache::write('test_groups', 'value', 'file_groups'));
<ide> $this->assertEquals('value', Cache::read('test_groups', 'file_groups'));
<ide> public function testClearingWithRepeatWrites()
<ide> {
<ide> Cache::setConfig('repeat', [
<ide> 'engine' => 'File',
<del> 'groups' => ['users']
<add> 'groups' => ['users'],
<ide> ]);
<ide>
<ide> $this->assertTrue(Cache::write('user', 'rchavik', 'repeat'));
<ide> public function testGroupDelete()
<ide> Cache::setConfig('file_groups', [
<ide> 'engine' => 'File',
<ide> 'duration' => 3600,
<del> 'groups' => ['group_a', 'group_b']
<add> 'groups' => ['group_a', 'group_b'],
<ide> ]);
<ide> $this->assertTrue(Cache::write('test_groups', 'value', 'file_groups'));
<ide> $this->assertEquals('value', Cache::read('test_groups', 'file_groups'));
<ide> public function testGroupClear()
<ide> Cache::setConfig('file_groups', [
<ide> 'engine' => 'File',
<ide> 'duration' => 3600,
<del> 'groups' => ['group_a', 'group_b']
<add> 'groups' => ['group_a', 'group_b'],
<ide> ]);
<ide> Cache::setConfig('file_groups2', [
<ide> 'engine' => 'File',
<ide> 'duration' => 3600,
<del> 'groups' => ['group_b']
<add> 'groups' => ['group_b'],
<ide> ]);
<ide> Cache::setConfig('file_groups3', [
<ide> 'engine' => 'File',
<ide> public function testGroupClearNoPrefix()
<ide> 'className' => 'File',
<ide> 'duration' => 3600,
<ide> 'prefix' => '',
<del> 'groups' => ['group_a', 'group_b']
<add> 'groups' => ['group_a', 'group_b'],
<ide> ]);
<ide> Cache::write('key_1', 'value', 'file_groups');
<ide> Cache::write('key_2', 'value', 'file_groups');
<ide><path>tests/TestCase/Cache/Engine/MemcachedEngineTest.php
<ide> protected function _configCache($config = [])
<ide> $defaults = [
<ide> 'className' => 'Memcached',
<ide> 'prefix' => 'cake_',
<del> 'duration' => 3600
<add> 'duration' => 3600,
<ide> ];
<ide> Cache::drop('memcached');
<ide> Cache::setConfig('memcached', array_merge($defaults, $config));
<ide> public function testCompressionSetting()
<ide> $Memcached->init([
<ide> 'engine' => 'Memcached',
<ide> 'servers' => ['127.0.0.1:11211'],
<del> 'compress' => false
<add> 'compress' => false,
<ide> ]);
<ide>
<ide> $this->assertFalse($Memcached->getOption(\Memcached::OPT_COMPRESSION));
<ide> public function testCompressionSetting()
<ide> $MemcachedCompressed->init([
<ide> 'engine' => 'Memcached',
<ide> 'servers' => ['127.0.0.1:11211'],
<del> 'compress' => true
<add> 'compress' => true,
<ide> ]);
<ide>
<ide> $this->assertTrue($MemcachedCompressed->getOption(\Memcached::OPT_COMPRESSION));
<ide> public function testOptionsSetting()
<ide> 'engine' => 'Memcached',
<ide> 'servers' => ['127.0.0.1:11211'],
<ide> 'options' => [
<del> Memcached::OPT_BINARY_PROTOCOL => true
<del> ]
<add> Memcached::OPT_BINARY_PROTOCOL => true,
<add> ],
<ide> ]);
<ide> $this->assertEquals(1, $memcached->getOption(Memcached::OPT_BINARY_PROTOCOL));
<ide> }
<ide> public function testInvalidSerializerSetting()
<ide> 'className' => 'Memcached',
<ide> 'servers' => ['127.0.0.1:11211'],
<ide> 'persistent' => false,
<del> 'serialize' => 'invalid_serializer'
<add> 'serialize' => 'invalid_serializer',
<ide> ];
<ide> $Memcached->init($config);
<ide> }
<ide> public function testPhpSerializerSetting()
<ide> 'className' => 'Memcached',
<ide> 'servers' => ['127.0.0.1:11211'],
<ide> 'persistent' => false,
<del> 'serialize' => 'php'
<add> 'serialize' => 'php',
<ide> ];
<ide>
<ide> $Memcached->init($config);
<ide> public function testJsonSerializerSetting()
<ide> 'engine' => 'Memcached',
<ide> 'servers' => ['127.0.0.1:11211'],
<ide> 'persistent' => false,
<del> 'serialize' => 'json'
<add> 'serialize' => 'json',
<ide> ];
<ide>
<ide> $Memcached->init($config);
<ide> public function testIgbinarySerializerSetting()
<ide> 'engine' => 'Memcached',
<ide> 'servers' => ['127.0.0.1:11211'],
<ide> 'persistent' => false,
<del> 'serialize' => 'igbinary'
<add> 'serialize' => 'igbinary',
<ide> ];
<ide>
<ide> $Memcached->init($config);
<ide> public function testMsgpackSerializerSetting()
<ide> 'engine' => 'Memcached',
<ide> 'servers' => ['127.0.0.1:11211'],
<ide> 'persistent' => false,
<del> 'serialize' => 'msgpack'
<add> 'serialize' => 'msgpack',
<ide> ];
<ide>
<ide> $Memcached->init($config);
<ide> public function testJsonSerializerThrowException()
<ide> 'className' => 'Memcached',
<ide> 'servers' => ['127.0.0.1:11211'],
<ide> 'persistent' => false,
<del> 'serialize' => 'json'
<add> 'serialize' => 'json',
<ide> ];
<ide>
<ide> $this->expectException(\InvalidArgumentException::class);
<ide> public function testMsgpackSerializerThrowException()
<ide> 'engine' => 'Memcached',
<ide> 'servers' => ['127.0.0.1:11211'],
<ide> 'persistent' => false,
<del> 'serialize' => 'msgpack'
<add> 'serialize' => 'msgpack',
<ide> ];
<ide>
<ide> $this->expectException(\InvalidArgumentException::class);
<ide> public function testIgbinarySerializerThrowException()
<ide> 'engine' => 'Memcached',
<ide> 'servers' => ['127.0.0.1:11211'],
<ide> 'persistent' => false,
<del> 'serialize' => 'igbinary'
<add> 'serialize' => 'igbinary',
<ide> ];
<ide>
<ide> $this->expectException(\InvalidArgumentException::class);
<ide> public function testSaslAuthException()
<ide> 'servers' => ['127.0.0.1:11211'],
<ide> 'persistent' => false,
<ide> 'username' => 'test',
<del> 'password' => 'password'
<add> 'password' => 'password',
<ide> ];
<ide> $this->expectException(\InvalidArgumentException::class);
<ide> $this->expectExceptionMessage('Memcached extension is not built with SASL support');
<ide> public function testConnectIpv6()
<ide> 'duration' => 200,
<ide> 'engine' => 'Memcached',
<ide> 'servers' => [
<del> '[::1]:11211'
<del> ]
<add> '[::1]:11211',
<add> ],
<ide> ]);
<ide> $this->assertTrue($result);
<ide> }
<ide> public function testReadMany()
<ide> 'App.trueTest' => true,
<ide> 'App.nullTest' => null,
<ide> 'App.zeroTest' => 0,
<del> 'App.zeroTest2' => '0'
<add> 'App.zeroTest2' => '0',
<ide> ];
<ide> foreach ($data as $key => $value) {
<ide> Cache::write($key, $value, 'memcached');
<ide> public function testWriteMany()
<ide> 'App.trueTest' => true,
<ide> 'App.nullTest' => null,
<ide> 'App.zeroTest' => 0,
<del> 'App.zeroTest2' => '0'
<add> 'App.zeroTest2' => '0',
<ide> ];
<ide> Cache::writeMany($data, 'memcached');
<ide>
<ide> public function testDecrementCompressedKeys()
<ide> 'engine' => 'Memcached',
<ide> 'duration' => '+2 seconds',
<ide> 'servers' => ['127.0.0.1:11211'],
<del> 'compress' => true
<add> 'compress' => true,
<ide> ]);
<ide>
<ide> $result = Cache::write('test_decrement', 5, 'compressed_memcached');
<ide> public function testIncrementCompressedKeys()
<ide> 'engine' => 'Memcached',
<ide> 'duration' => '+2 seconds',
<ide> 'servers' => ['127.0.0.1:11211'],
<del> 'compress' => true
<add> 'compress' => true,
<ide> ]);
<ide>
<ide> $result = Cache::write('test_increment', 5, 'compressed_memcached');
<ide> public function testClear()
<ide> Cache::setConfig('memcached2', [
<ide> 'engine' => 'Memcached',
<ide> 'prefix' => 'cake2_',
<del> 'duration' => 3600
<add> 'duration' => 3600,
<ide> ]);
<ide>
<ide> Cache::write('some_value', 'cache1', 'memcached');
<ide> public function testGroupReadWrite()
<ide> 'engine' => 'Memcached',
<ide> 'duration' => 3600,
<ide> 'groups' => ['group_a', 'group_b'],
<del> 'prefix' => 'test_'
<add> 'prefix' => 'test_',
<ide> ]);
<ide> Cache::setConfig('memcached_helper', [
<ide> 'engine' => 'Memcached',
<ide> 'duration' => 3600,
<del> 'prefix' => 'test_'
<add> 'prefix' => 'test_',
<ide> ]);
<ide> $this->assertTrue(Cache::write('test_groups', 'value', 'memcached_groups'));
<ide> $this->assertEquals('value', Cache::read('test_groups', 'memcached_groups'));
<ide> public function testGroupDelete()
<ide> Cache::setConfig('memcached_groups', [
<ide> 'engine' => 'Memcached',
<ide> 'duration' => 3600,
<del> 'groups' => ['group_a', 'group_b']
<add> 'groups' => ['group_a', 'group_b'],
<ide> ]);
<ide> $this->assertTrue(Cache::write('test_groups', 'value', 'memcached_groups'));
<ide> $this->assertEquals('value', Cache::read('test_groups', 'memcached_groups'));
<ide> public function testGroupClear()
<ide> Cache::setConfig('memcached_groups', [
<ide> 'engine' => 'Memcached',
<ide> 'duration' => 3600,
<del> 'groups' => ['group_a', 'group_b']
<add> 'groups' => ['group_a', 'group_b'],
<ide> ]);
<ide>
<ide> $this->assertTrue(Cache::write('test_groups', 'value', 'memcached_groups'));
<ide><path>tests/TestCase/Cache/Engine/RedisEngineTest.php
<ide> protected function _configCache($config = [])
<ide> $defaults = [
<ide> 'className' => 'Redis',
<ide> 'prefix' => 'cake_',
<del> 'duration' => 3600
<add> 'duration' => 3600,
<ide> ];
<ide> Cache::drop('redis');
<ide> Cache::setConfig('redis', array_merge($defaults, $config));
<ide> public function testConfig()
<ide> public function testConfigDsn()
<ide> {
<ide> Cache::setConfig('redis_dsn', [
<del> 'url' => 'redis://localhost:6379?database=1&prefix=redis_'
<add> 'url' => 'redis://localhost:6379?database=1&prefix=redis_',
<ide> ]);
<ide>
<ide> $config = Cache::engine('redis_dsn')->getConfig();
<ide> public function testClear()
<ide> Cache::setConfig('redis2', [
<ide> 'engine' => 'Redis',
<ide> 'prefix' => 'cake2_',
<del> 'duration' => 3600
<add> 'duration' => 3600,
<ide> ]);
<ide>
<ide> Cache::write('some_value', 'cache1', 'redis');
<ide> public function testGroupReadWrite()
<ide> 'engine' => 'Redis',
<ide> 'duration' => 3600,
<ide> 'groups' => ['group_a', 'group_b'],
<del> 'prefix' => 'test_'
<add> 'prefix' => 'test_',
<ide> ]);
<ide> Cache::setConfig('redis_helper', [
<ide> 'engine' => 'Redis',
<ide> 'duration' => 3600,
<del> 'prefix' => 'test_'
<add> 'prefix' => 'test_',
<ide> ]);
<ide> $this->assertTrue(Cache::write('test_groups', 'value', 'redis_groups'));
<ide> $this->assertEquals('value', Cache::read('test_groups', 'redis_groups'));
<ide> public function testGroupDelete()
<ide> Cache::setConfig('redis_groups', [
<ide> 'engine' => 'Redis',
<ide> 'duration' => 3600,
<del> 'groups' => ['group_a', 'group_b']
<add> 'groups' => ['group_a', 'group_b'],
<ide> ]);
<ide> $this->assertTrue(Cache::write('test_groups', 'value', 'redis_groups'));
<ide> $this->assertEquals('value', Cache::read('test_groups', 'redis_groups'));
<ide> public function testGroupClear()
<ide> Cache::setConfig('redis_groups', [
<ide> 'engine' => 'Redis',
<ide> 'duration' => 3600,
<del> 'groups' => ['group_a', 'group_b']
<add> 'groups' => ['group_a', 'group_b'],
<ide> ]);
<ide>
<ide> $this->assertTrue(Cache::write('test_groups', 'value', 'redis_groups'));
<ide><path>tests/TestCase/Cache/Engine/WincacheEngineTest.php
<ide> protected function _configCache($config = [])
<ide> {
<ide> $defaults = [
<ide> 'className' => 'Wincache',
<del> 'prefix' => 'cake_'
<add> 'prefix' => 'cake_',
<ide> ];
<ide> Cache::drop('wincache');
<ide> Cache::setConfig('wincache', array_merge($defaults, $config));
<ide> public function testGroupsReadWrite()
<ide> 'engine' => 'Wincache',
<ide> 'duration' => 0,
<ide> 'groups' => ['group_a', 'group_b'],
<del> 'prefix' => 'test_'
<add> 'prefix' => 'test_',
<ide> ]);
<ide> $this->assertTrue(Cache::write('test_groups', 'value', 'wincache_groups'));
<ide> $this->assertEquals('value', Cache::read('test_groups', 'wincache_groups'));
<ide> public function testGroupDelete()
<ide> 'engine' => 'Wincache',
<ide> 'duration' => 0,
<ide> 'groups' => ['group_a', 'group_b'],
<del> 'prefix' => 'test_'
<add> 'prefix' => 'test_',
<ide> ]);
<ide> $this->assertTrue(Cache::write('test_groups', 'value', 'wincache_groups'));
<ide> $this->assertEquals('value', Cache::read('test_groups', 'wincache_groups'));
<ide> public function testGroupClear()
<ide> 'engine' => 'Wincache',
<ide> 'duration' => 0,
<ide> 'groups' => ['group_a', 'group_b'],
<del> 'prefix' => 'test_'
<add> 'prefix' => 'test_',
<ide> ]);
<ide>
<ide> $this->assertTrue(Cache::write('test_groups', 'value', 'wincache_groups'));
<ide><path>tests/TestCase/Cache/Engine/XcacheEngineTest.php
<ide> public function testGroupsReadWrite()
<ide> 'engine' => 'Xcache',
<ide> 'duration' => 0,
<ide> 'groups' => ['group_a', 'group_b'],
<del> 'prefix' => 'test_'
<add> 'prefix' => 'test_',
<ide> ]);
<ide> $this->assertTrue(Cache::write('test_groups', 'value', 'xcache_groups'));
<ide> $this->assertEquals('value', Cache::read('test_groups', 'xcache_groups'));
<ide> public function testGroupDelete()
<ide> 'engine' => 'Xcache',
<ide> 'duration' => 0,
<ide> 'groups' => ['group_a', 'group_b'],
<del> 'prefix' => 'test_'
<add> 'prefix' => 'test_',
<ide> ]);
<ide> $this->assertTrue(Cache::write('test_groups', 'value', 'xcache_groups'));
<ide> $this->assertEquals('value', Cache::read('test_groups', 'xcache_groups'));
<ide> public function testGroupClear()
<ide> 'engine' => 'Xcache',
<ide> 'duration' => 0,
<ide> 'groups' => ['group_a', 'group_b'],
<del> 'prefix' => 'test_'
<add> 'prefix' => 'test_',
<ide> ]);
<ide>
<ide> $this->assertTrue(Cache::write('test_groups', 'value', 'xcache_groups'));
<ide><path>tests/TestCase/Cache/SimpleCacheEngineTest.php
<ide> public function setUp()
<ide> 'prefix' => '',
<ide> 'path' => TMP . 'tests',
<ide> 'duration' => 5,
<del> 'groups' => ['blog', 'category']
<add> 'groups' => ['blog', 'category'],
<ide> ]);
<ide> $this->cache = new SimpleCacheEngine($this->innerEngine);
<ide> }
<ide><path>tests/TestCase/Collection/CollectionTest.php
<ide> public function avgProvider()
<ide>
<ide> return [
<ide> 'array' => [$items],
<del> 'iterator' => [$this->yieldItems($items)]
<add> 'iterator' => [$this->yieldItems($items)],
<ide> ];
<ide> }
<ide>
<ide> public function avgWithMatcherProvider()
<ide>
<ide> return [
<ide> 'array' => [$items],
<del> 'iterator' => [$this->yieldItems($items)]
<add> 'iterator' => [$this->yieldItems($items)],
<ide> ];
<ide> }
<ide>
<ide> public function medianProvider()
<ide>
<ide> return [
<ide> 'array' => [$items],
<del> 'iterator' => [$this->yieldItems($items)]
<add> 'iterator' => [$this->yieldItems($items)],
<ide> ];
<ide> }
<ide>
<ide> public function medianWithMatcherProvider()
<ide> ['invoice' => ['total' => 500]],
<ide> ['invoice' => ['total' => 200]],
<ide> ['invoice' => ['total' => 100]],
<del> ['invoice' => ['total' => 333]]
<add> ['invoice' => ['total' => 333]],
<ide> ];
<ide>
<ide> return [
<ide> 'array' => [$items],
<del> 'iterator' => [$this->yieldItems($items)]
<add> 'iterator' => [$this->yieldItems($items)],
<ide> ];
<ide> }
<ide>
<ide> public function filterProvider()
<ide>
<ide> return [
<ide> 'array' => [$items],
<del> 'iterator' => [$this->yieldItems($items)]
<add> 'iterator' => [$this->yieldItems($items)],
<ide> ];
<ide> }
<ide>
<ide> public function simpleProvider()
<ide>
<ide> return [
<ide> 'array' => [$items],
<del> 'iterator' => [$this->yieldItems($items)]
<add> 'iterator' => [$this->yieldItems($items)],
<ide> ];
<ide> }
<ide>
<ide> public function extractProvider()
<ide>
<ide> return [
<ide> 'array' => [$items],
<del> 'iterator' => [$this->yieldItems($items)]
<add> 'iterator' => [$this->yieldItems($items)],
<ide> ];
<ide> }
<ide>
<ide> public function sortProvider()
<ide> $items = [
<ide> ['a' => ['b' => ['c' => 4]]],
<ide> ['a' => ['b' => ['c' => 10]]],
<del> ['a' => ['b' => ['c' => 6]]]
<add> ['a' => ['b' => ['c' => 6]]],
<ide> ];
<ide>
<ide> return [
<ide> 'array' => [$items],
<del> 'iterator' => [$this->yieldItems($items)]
<add> 'iterator' => [$this->yieldItems($items)],
<ide> ];
<ide> }
<ide>
<ide> public function testMaxWithEntities()
<ide> new Entity(['id' => 2, 'count' => 9]),
<ide> new Entity(['id' => 3, 'count' => 42]),
<ide> new Entity(['id' => 4, 'count' => 4]),
<del> new Entity(['id' => 5, 'count' => 22])
<add> new Entity(['id' => 5, 'count' => 22]),
<ide> ]);
<ide>
<ide> $expected = new Entity(['id' => 3, 'count' => 42]);
<ide> public function testMinWithEntities()
<ide> new Entity(['id' => 2, 'count' => 9]),
<ide> new Entity(['id' => 3, 'count' => 42]),
<ide> new Entity(['id' => 4, 'count' => 4]),
<del> new Entity(['id' => 5, 'count' => 22])
<add> new Entity(['id' => 5, 'count' => 22]),
<ide> ]);
<ide>
<ide> $expected = new Entity(['id' => 4, 'count' => 4]);
<ide> public function groupByProvider()
<ide>
<ide> return [
<ide> 'array' => [$items],
<del> 'iterator' => [$this->yieldItems($items)]
<add> 'iterator' => [$this->yieldItems($items)],
<ide> ];
<ide> }
<ide>
<ide> public function testGroupBy($items)
<ide> ],
<ide> 11 => [
<ide> ['id' => 2, 'name' => 'bar', 'parent_id' => 11],
<del> ]
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, iterator_to_array($grouped));
<ide> $this->assertInstanceOf('Cake\Collection\Collection', $grouped);
<ide> public function testGroupByCallback($items)
<ide> ],
<ide> 11 => [
<ide> ['id' => 2, 'name' => 'bar', 'parent_id' => 11],
<del> ]
<add> ],
<ide> ];
<ide> $grouped = $collection->groupBy(function ($element) {
<ide> return $element['parent_id'];
<ide> public function testGroupByDeepKey()
<ide> ],
<ide> 11 => [
<ide> ['id' => 2, 'name' => 'bar', 'thing' => ['parent_id' => 11]],
<del> ]
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, iterator_to_array($grouped));
<ide> }
<ide> public function indexByProvider()
<ide>
<ide> return [
<ide> 'array' => [$items],
<del> 'iterator' => [$this->yieldItems($items)]
<add> 'iterator' => [$this->yieldItems($items)],
<ide> ];
<ide> }
<ide>
<ide> public function testCountBy($items)
<ide> $grouped = $collection->countBy('parent_id');
<ide> $expected = [
<ide> 10 => 2,
<del> 11 => 1
<add> 11 => 1,
<ide> ];
<ide> $result = iterator_to_array($grouped);
<ide> $this->assertInstanceOf('Cake\Collection\Collection', $grouped);
<ide> public function testCountByCallback($items)
<ide> {
<ide> $expected = [
<ide> 10 => 2,
<del> 11 => 1
<add> 11 => 1,
<ide> ];
<ide> $collection = new Collection($items);
<ide> $grouped = $collection->countBy(function ($element) {
<ide> public function testCombine()
<ide> $items = [
<ide> ['id' => 1, 'name' => 'foo', 'parent' => 'a'],
<ide> ['id' => 2, 'name' => 'bar', 'parent' => 'b'],
<del> ['id' => 3, 'name' => 'baz', 'parent' => 'a']
<add> ['id' => 3, 'name' => 'baz', 'parent' => 'a'],
<ide> ];
<ide> $collection = (new Collection($items))->combine('id', 'name');
<ide> $expected = [1 => 'foo', 2 => 'bar', 3 => 'baz'];
<ide> public function testCombine()
<ide> $expected = [
<ide> '0-1' => ['foo-0-1' => '0-1-foo'],
<ide> '1-2' => ['bar-1-2' => '1-2-bar'],
<del> '2-3' => ['baz-2-3' => '2-3-baz']
<add> '2-3' => ['baz-2-3' => '2-3-baz'],
<ide> ];
<ide> $collection = (new Collection($items))->combine(
<ide> function ($value, $key) {
<ide> public function testNest()
<ide> ['id' => 7, 'parent_id' => 1],
<ide> ['id' => 8, 'parent_id' => 6],
<ide> ['id' => 9, 'parent_id' => 6],
<del> ['id' => 10, 'parent_id' => 6]
<add> ['id' => 10, 'parent_id' => 6],
<ide> ];
<ide> $collection = (new Collection($items))->nest('id', 'parent_id');
<ide> $expected = [
<ide> public function testNest()
<ide> ['id' => 2, 'parent_id' => 1, 'children' => []],
<ide> ['id' => 3, 'parent_id' => 1, 'children' => []],
<ide> ['id' => 4, 'parent_id' => 1, 'children' => []],
<del> ['id' => 7, 'parent_id' => 1, 'children' => []]
<del> ]
<add> ['id' => 7, 'parent_id' => 1, 'children' => []],
<add> ],
<ide> ],
<ide> [
<ide> 'id' => 6,
<ide> public function testNest()
<ide> ['id' => 5, 'parent_id' => 6, 'children' => []],
<ide> ['id' => 8, 'parent_id' => 6, 'children' => []],
<ide> ['id' => 9, 'parent_id' => 6, 'children' => []],
<del> ['id' => 10, 'parent_id' => 6, 'children' => []]
<del> ]
<del> ]
<add> ['id' => 10, 'parent_id' => 6, 'children' => []],
<add> ],
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, $collection->toArray());
<ide> }
<ide> public function testNestAlternateNestingKey()
<ide> ['id' => 7, 'parent_id' => 1],
<ide> ['id' => 8, 'parent_id' => 6],
<ide> ['id' => 9, 'parent_id' => 6],
<del> ['id' => 10, 'parent_id' => 6]
<add> ['id' => 10, 'parent_id' => 6],
<ide> ];
<ide> $collection = (new Collection($items))->nest('id', 'parent_id', 'nodes');
<ide> $expected = [
<ide> public function testNestAlternateNestingKey()
<ide> ['id' => 2, 'parent_id' => 1, 'nodes' => []],
<ide> ['id' => 3, 'parent_id' => 1, 'nodes' => []],
<ide> ['id' => 4, 'parent_id' => 1, 'nodes' => []],
<del> ['id' => 7, 'parent_id' => 1, 'nodes' => []]
<del> ]
<add> ['id' => 7, 'parent_id' => 1, 'nodes' => []],
<add> ],
<ide> ],
<ide> [
<ide> 'id' => 6,
<ide> public function testNestAlternateNestingKey()
<ide> ['id' => 5, 'parent_id' => 6, 'nodes' => []],
<ide> ['id' => 8, 'parent_id' => 6, 'nodes' => []],
<ide> ['id' => 9, 'parent_id' => 6, 'nodes' => []],
<del> ['id' => 10, 'parent_id' => 6, 'nodes' => []]
<del> ]
<del> ]
<add> ['id' => 10, 'parent_id' => 6, 'nodes' => []],
<add> ],
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, $collection->toArray());
<ide> }
<ide> public function testNestMultiLevel()
<ide> ['id' => 7, 'parent_id' => 3],
<ide> ['id' => 8, 'parent_id' => 4],
<ide> ['id' => 9, 'parent_id' => 6],
<del> ['id' => 10, 'parent_id' => 6]
<add> ['id' => 10, 'parent_id' => 6],
<ide> ];
<ide> $collection = (new Collection($items))->nest('id', 'parent_id', 'nodes');
<ide> $expected = [
<ide> public function testNestMultiLevel()
<ide> 'parent_id' => 2,
<ide> 'nodes' => [
<ide> ['id' => 5, 'parent_id' => 3, 'nodes' => []],
<del> ['id' => 7, 'parent_id' => 3, 'nodes' => []]
<del> ]
<add> ['id' => 7, 'parent_id' => 3, 'nodes' => []],
<add> ],
<ide> ],
<ide> [
<ide> 'id' => 4,
<ide> 'parent_id' => 2,
<ide> 'nodes' => [
<del> ['id' => 8, 'parent_id' => 4, 'nodes' => []]
<del> ]
<del> ]
<del> ]
<del> ]
<del> ]
<add> ['id' => 8, 'parent_id' => 4, 'nodes' => []],
<add> ],
<add> ],
<add> ],
<add> ],
<add> ],
<ide> ],
<ide> [
<ide> 'id' => 6,
<ide> 'parent_id' => null,
<ide> 'nodes' => [
<ide> ['id' => 9, 'parent_id' => 6, 'nodes' => []],
<del> ['id' => 10, 'parent_id' => 6, 'nodes' => []]
<del> ]
<del> ]
<add> ['id' => 10, 'parent_id' => 6, 'nodes' => []],
<add> ],
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, $collection->toArray());
<ide> }
<ide> public function testNestMultiLevelAlternateNestingKey()
<ide> ['id' => 7, 'parent_id' => 3],
<ide> ['id' => 8, 'parent_id' => 4],
<ide> ['id' => 9, 'parent_id' => 6],
<del> ['id' => 10, 'parent_id' => 6]
<add> ['id' => 10, 'parent_id' => 6],
<ide> ];
<ide> $collection = (new Collection($items))->nest('id', 'parent_id');
<ide> $expected = [
<ide> public function testNestMultiLevelAlternateNestingKey()
<ide> 'parent_id' => 2,
<ide> 'children' => [
<ide> ['id' => 5, 'parent_id' => 3, 'children' => []],
<del> ['id' => 7, 'parent_id' => 3, 'children' => []]
<del> ]
<add> ['id' => 7, 'parent_id' => 3, 'children' => []],
<add> ],
<ide> ],
<ide> [
<ide> 'id' => 4,
<ide> 'parent_id' => 2,
<ide> 'children' => [
<del> ['id' => 8, 'parent_id' => 4, 'children' => []]
<del> ]
<del> ]
<del> ]
<del> ]
<del> ]
<add> ['id' => 8, 'parent_id' => 4, 'children' => []],
<add> ],
<add> ],
<add> ],
<add> ],
<add> ],
<ide> ],
<ide> [
<ide> 'id' => 6,
<ide> 'parent_id' => null,
<ide> 'children' => [
<ide> ['id' => 9, 'parent_id' => 6, 'children' => []],
<del> ['id' => 10, 'parent_id' => 6, 'children' => []]
<del> ]
<del> ]
<add> ['id' => 10, 'parent_id' => 6, 'children' => []],
<add> ],
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, $collection->toArray());
<ide> }
<ide> public function testNestObjects()
<ide> new ArrayObject(['id' => 7, 'parent_id' => 3]),
<ide> new ArrayObject(['id' => 8, 'parent_id' => 4]),
<ide> new ArrayObject(['id' => 9, 'parent_id' => 6]),
<del> new ArrayObject(['id' => 10, 'parent_id' => 6])
<add> new ArrayObject(['id' => 10, 'parent_id' => 6]),
<ide> ];
<ide> $collection = (new Collection($items))->nest('id', 'parent_id');
<ide> $expected = [
<ide> public function testNestObjects()
<ide> 'parent_id' => 2,
<ide> 'children' => [
<ide> new ArrayObject(['id' => 5, 'parent_id' => 3, 'children' => []]),
<del> new ArrayObject(['id' => 7, 'parent_id' => 3, 'children' => []])
<del> ]
<add> new ArrayObject(['id' => 7, 'parent_id' => 3, 'children' => []]),
<add> ],
<ide> ]),
<ide> new ArrayObject([
<ide> 'id' => 4,
<ide> 'parent_id' => 2,
<ide> 'children' => [
<del> new ArrayObject(['id' => 8, 'parent_id' => 4, 'children' => []])
<del> ]
<del> ])
<del> ]
<del> ])
<del> ]
<add> new ArrayObject(['id' => 8, 'parent_id' => 4, 'children' => []]),
<add> ],
<add> ]),
<add> ],
<add> ]),
<add> ],
<ide> ]),
<ide> new ArrayObject([
<ide> 'id' => 6,
<ide> 'parent_id' => null,
<ide> 'children' => [
<ide> new ArrayObject(['id' => 9, 'parent_id' => 6, 'children' => []]),
<del> new ArrayObject(['id' => 10, 'parent_id' => 6, 'children' => []])
<del> ]
<del> ])
<add> new ArrayObject(['id' => 10, 'parent_id' => 6, 'children' => []]),
<add> ],
<add> ]),
<ide> ];
<ide> $this->assertEquals($expected, $collection->toArray());
<ide> }
<ide> public function testNestObjectsAlternateNestingKey()
<ide> new ArrayObject(['id' => 7, 'parent_id' => 3]),
<ide> new ArrayObject(['id' => 8, 'parent_id' => 4]),
<ide> new ArrayObject(['id' => 9, 'parent_id' => 6]),
<del> new ArrayObject(['id' => 10, 'parent_id' => 6])
<add> new ArrayObject(['id' => 10, 'parent_id' => 6]),
<ide> ];
<ide> $collection = (new Collection($items))->nest('id', 'parent_id', 'nodes');
<ide> $expected = [
<ide> public function testNestObjectsAlternateNestingKey()
<ide> 'parent_id' => 2,
<ide> 'nodes' => [
<ide> new ArrayObject(['id' => 5, 'parent_id' => 3, 'nodes' => []]),
<del> new ArrayObject(['id' => 7, 'parent_id' => 3, 'nodes' => []])
<del> ]
<add> new ArrayObject(['id' => 7, 'parent_id' => 3, 'nodes' => []]),
<add> ],
<ide> ]),
<ide> new ArrayObject([
<ide> 'id' => 4,
<ide> 'parent_id' => 2,
<ide> 'nodes' => [
<del> new ArrayObject(['id' => 8, 'parent_id' => 4, 'nodes' => []])
<del> ]
<del> ])
<del> ]
<del> ])
<del> ]
<add> new ArrayObject(['id' => 8, 'parent_id' => 4, 'nodes' => []]),
<add> ],
<add> ]),
<add> ],
<add> ]),
<add> ],
<ide> ]),
<ide> new ArrayObject([
<ide> 'id' => 6,
<ide> 'parent_id' => null,
<ide> 'nodes' => [
<ide> new ArrayObject(['id' => 9, 'parent_id' => 6, 'nodes' => []]),
<del> new ArrayObject(['id' => 10, 'parent_id' => 6, 'nodes' => []])
<del> ]
<del> ])
<add> new ArrayObject(['id' => 10, 'parent_id' => 6, 'nodes' => []]),
<add> ],
<add> ]),
<ide> ];
<ide> $this->assertEquals($expected, $collection->toArray());
<ide> }
<ide> public function nestedListProvider()
<ide> return [
<ide> ['desc', [1, 2, 3, 5, 7, 4, 8, 6, 9, 10]],
<ide> ['asc', [5, 7, 3, 8, 4, 2, 1, 9, 10, 6]],
<del> ['leaves', [5, 7, 8, 9, 10]]
<add> ['leaves', [5, 7, 8, 9, 10]],
<ide> ];
<ide> }
<ide>
<ide> public function testListNested($dir, $expected)
<ide> ['id' => 7, 'parent_id' => 3],
<ide> ['id' => 8, 'parent_id' => 4],
<ide> ['id' => 9, 'parent_id' => 6],
<del> ['id' => 10, 'parent_id' => 6]
<add> ['id' => 10, 'parent_id' => 6],
<ide> ];
<ide> $collection = (new Collection($items))->nest('id', 'parent_id')->listNested($dir);
<ide> $this->assertEquals($expected, $collection->extract('id')->toArray(false));
<ide> public function testListNestedCustomKey()
<ide> {
<ide> $items = [
<ide> ['id' => 1, 'stuff' => [['id' => 2, 'stuff' => [['id' => 3]]]]],
<del> ['id' => 4, 'stuff' => [['id' => 5]]]
<add> ['id' => 4, 'stuff' => [['id' => 5]]],
<ide> ];
<ide> $collection = (new Collection($items))->listNested('desc', 'stuff');
<ide> $this->assertEquals(range(1, 5), $collection->extract('id')->toArray(false));
<ide> public function testListNestedWithCallable()
<ide> {
<ide> $items = [
<ide> ['id' => 1, 'stuff' => [['id' => 2, 'stuff' => [['id' => 3]]]]],
<del> ['id' => 4, 'stuff' => [['id' => 5]]]
<add> ['id' => 4, 'stuff' => [['id' => 5]]],
<ide> ];
<ide> $collection = (new Collection($items))->listNested('desc', function ($item) {
<ide> return isset($item['stuff']) ? $item['stuff'] : [];
<ide> public function sumOfProvider()
<ide> {
<ide> $items = [
<ide> ['invoice' => ['total' => 100]],
<del> ['invoice' => ['total' => 200]]
<add> ['invoice' => ['total' => 200]],
<ide> ];
<ide>
<ide> return [
<ide> 'array' => [$items],
<del> 'iterator' => [$this->yieldItems($items)]
<add> 'iterator' => [$this->yieldItems($items)],
<ide> ];
<ide> }
<ide>
<ide> public function testStopWhenWithArray()
<ide> $items = [
<ide> ['foo' => 'bar'],
<ide> ['foo' => 'baz'],
<del> ['foo' => 'foo']
<add> ['foo' => 'foo'],
<ide> ];
<ide> $collection = (new Collection($items))->stopWhen(['foo' => 'baz']);
<ide> $this->assertEquals([['foo' => 'bar']], $collection->toArray());
<ide> public function testUnfold()
<ide> $items = [
<ide> [1, 2, 3, 4],
<ide> [5, 6],
<del> [7, 8]
<add> [7, 8],
<ide> ];
<ide>
<ide> $collection = (new Collection($items))->unfold();
<ide> $this->assertEquals(range(1, 8), $collection->toArray(false));
<ide>
<ide> $items = [
<ide> [1, 2],
<del> new Collection([3, 4])
<add> new Collection([3, 4]),
<ide> ];
<ide> $collection = (new Collection($items))->unfold();
<ide> $this->assertEquals(range(1, 4), $collection->toArray(false));
<ide> public function testComplexSortBy()
<ide> ->unfold(function ($value) {
<ide> return [
<ide> ['sorting' => $value * 2],
<del> ['sorting' => $value * 2]
<add> ['sorting' => $value * 2],
<ide> ];
<ide> })
<ide> ->sortBy('sorting')
<ide> public function testZip()
<ide> $zipped = $collection->zip([3, 4], [5, 6], [7, 8], [9, 10, 11]);
<ide> $this->assertEquals([
<ide> [1, 3, 5, 7, 9],
<del> [2, 4, 6, 8, 10]
<add> [2, 4, 6, 8, 10],
<ide> ], $zipped->toList());
<ide> }
<ide>
<ide> public function testUnfoldedExtract()
<ide> [
<ide> 'comments' => [
<ide> [
<del> 'voters' => [['id' => 1], ['id' => 2]]
<del> ]
<del> ]
<add> 'voters' => [['id' => 1], ['id' => 2]],
<add> ],
<add> ],
<ide> ],
<ide> [
<ide> 'comments' => [
<ide> [
<del> 'voters' => [['id' => 3], ['id' => 4]]
<del> ]
<del> ]
<add> 'voters' => [['id' => 3], ['id' => 4]],
<add> ],
<add> ],
<ide> ],
<ide> [
<ide> 'comments' => [
<ide> [
<del> 'voters' => [['id' => 5], ['nope' => 'fail'], ['id' => 6]]
<del> ]
<del> ]
<add> 'voters' => [['id' => 5], ['nope' => 'fail'], ['id' => 6]],
<add> ],
<add> ],
<ide> ],
<ide> [
<ide> 'comments' => [
<ide> [
<del> 'not_voters' => [['id' => 5]]
<del> ]
<del> ]
<add> 'not_voters' => [['id' => 5]],
<add> ],
<add> ],
<ide> ],
<del> ['not_comments' => []]
<add> ['not_comments' => []],
<ide> ];
<ide> $extracted = (new Collection($items))->extract('comments.{*}.voters.{*}.id');
<ide> $expected = [1, 2, 3, 4, 5, null, 6];
<ide> public function chunkProvider()
<ide>
<ide> return [
<ide> 'array' => [$items],
<del> 'iterator' => [$this->yieldItems($items)]
<add> 'iterator' => [$this->yieldItems($items)],
<ide> ];
<ide> }
<ide>
<ide> public function testCartesianProductMultidimensionalArray()
<ide> $collection = new Collection([
<ide> [
<ide> 'names' => [
<del> 'alex', 'kostas', 'leon'
<del> ]
<add> 'alex', 'kostas', 'leon',
<add> ],
<ide> ],
<ide> [
<ide> 'locations' => [
<del> 'crete', 'london', 'paris'
<del> ]
<add> 'crete', 'london', 'paris',
<add> ],
<ide> ],
<ide> ]);
<ide>
<ide><path>tests/TestCase/Collection/Iterator/BufferedIteratorTest.php
<ide> public function testBuffer()
<ide> $items = new ArrayObject([
<ide> 'a' => 1,
<ide> 'b' => 2,
<del> 'c' => 3
<add> 'c' => 3,
<ide> ]);
<ide> $iterator = new BufferedIterator($items);
<ide> $expected = (array)$items;
<ide> public function testCount()
<ide> $items = new ArrayObject([
<ide> 'a' => 1,
<ide> 'b' => 2,
<del> 'c' => 3
<add> 'c' => 3,
<ide> ]);
<ide> $iterator = new BufferedIterator($items);
<ide> $this->assertCount(3, $iterator);
<ide><path>tests/TestCase/Collection/Iterator/ExtractIteratorTest.php
<ide> public function testExtractFromArrayShallow()
<ide> {
<ide> $items = [
<ide> ['a' => 1, 'b' => 2],
<del> ['a' => 3, 'b' => 4]
<add> ['a' => 3, 'b' => 4],
<ide> ];
<ide> $extractor = new ExtractIterator($items, 'a');
<ide> $this->assertEquals([1, 3], iterator_to_array($extractor));
<ide> public function testExtractFromObjectShallow()
<ide> {
<ide> $items = [
<ide> new ArrayObject(['a' => 1, 'b' => 2]),
<del> new ArrayObject(['a' => 3, 'b' => 4])
<add> new ArrayObject(['a' => 3, 'b' => 4]),
<ide> ];
<ide> $extractor = new ExtractIterator($items, 'a');
<ide> $this->assertEquals([1, 3], iterator_to_array($extractor));
<ide> public function testExtractWithCallable()
<ide> {
<ide> $items = [
<ide> ['a' => 1, 'b' => 2],
<del> ['a' => 3, 'b' => 4]
<add> ['a' => 3, 'b' => 4],
<ide> ];
<ide> $extractor = new ExtractIterator($items, function ($item) {
<ide> return $item['b'];
<ide><path>tests/TestCase/Collection/Iterator/InsertIteratorTest.php
<ide> public function testInsertSimplePath()
<ide> {
<ide> $items = [
<ide> 'a' => ['name' => 'Derp'],
<del> 'b' => ['name' => 'Derpina']
<add> 'b' => ['name' => 'Derpina'],
<ide> ];
<ide> $values = [20, 21];
<ide> $iterator = new InsertIterator($items, 'age', $values);
<ide> $result = $iterator->toArray();
<ide> $expected = [
<ide> 'a' => ['name' => 'Derp', 'age' => 20],
<del> 'b' => ['name' => 'Derpina', 'age' => 21]
<add> 'b' => ['name' => 'Derpina', 'age' => 21],
<ide> ];
<ide> $this->assertSame($expected, $result);
<ide> }
<ide> public function testInsertTargetCountBigger()
<ide> {
<ide> $items = [
<ide> 'a' => ['name' => 'Derp'],
<del> 'b' => ['name' => 'Derpina']
<add> 'b' => ['name' => 'Derpina'],
<ide> ];
<ide> $values = [20];
<ide> $iterator = new InsertIterator($items, 'age', $values);
<ide> $result = $iterator->toArray();
<ide> $expected = [
<ide> 'a' => ['name' => 'Derp', 'age' => 20],
<del> 'b' => ['name' => 'Derpina']
<add> 'b' => ['name' => 'Derpina'],
<ide> ];
<ide> $this->assertSame($expected, $result);
<ide> }
<ide> public function testInsertSourceBigger()
<ide> {
<ide> $items = [
<ide> 'a' => ['name' => 'Derp'],
<del> 'b' => ['name' => 'Derpina']
<add> 'b' => ['name' => 'Derpina'],
<ide> ];
<ide> $values = [20, 21, 23];
<ide> $iterator = new InsertIterator($items, 'age', $values);
<ide> $result = $iterator->toArray();
<ide> $expected = [
<ide> 'a' => ['name' => 'Derp', 'age' => 20],
<del> 'b' => ['name' => 'Derpina', 'age' => 21]
<add> 'b' => ['name' => 'Derpina', 'age' => 21],
<ide> ];
<ide> $this->assertSame($expected, $result);
<ide> }
<ide> public function testRewind()
<ide> $result = $iterator->toArray();
<ide> $expected = [
<ide> 'a' => ['name' => 'Derp', 'age' => 20],
<del> 'b' => ['name' => 'Derpina', 'age' => 21]
<add> 'b' => ['name' => 'Derpina', 'age' => 21],
<ide> ];
<ide> $this->assertSame($expected, $result);
<ide> }
<ide><path>tests/TestCase/Collection/Iterator/MapReduceTest.php
<ide> public function testInvertedIndexCreation()
<ide> $data = [
<ide> 'document_1' => 'Dogs are the most amazing animal in history',
<ide> 'document_2' => 'History is not only amazing but boring',
<del> 'document_3' => 'One thing that is not boring is dogs'
<add> 'document_3' => 'One thing that is not boring is dogs',
<ide> ];
<ide> $mapper = function ($row, $document, $mr) {
<ide> $words = array_map('strtolower', explode(' ', $row));
<ide> public function testInvertedIndexCreation()
<ide> 'boring' => ['document_2', 'document_3'],
<ide> 'one' => ['document_3'],
<ide> 'thing' => ['document_3'],
<del> 'that' => ['document_3']
<add> 'that' => ['document_3'],
<ide> ];
<ide> $this->assertEquals($expected, iterator_to_array($results));
<ide> }
<ide><path>tests/TestCase/Collection/Iterator/SortIteratorTest.php
<ide> public function testSortDateTime()
<ide> $items = new ArrayObject([
<ide> new \DateTime('2014-07-21'),
<ide> new \DateTime('2015-06-30'),
<del> new \DateTimeImmutable('2013-08-12')
<add> new \DateTimeImmutable('2013-08-12'),
<ide> ]);
<ide>
<ide> $callback = function ($a) {
<ide> public function testSortDateTime()
<ide> $expected = [
<ide> new \DateTime('2016-06-30'),
<ide> new \DateTime('2015-07-21'),
<del> new \DateTimeImmutable('2013-08-12')
<add> new \DateTimeImmutable('2013-08-12'),
<ide>
<ide> ];
<ide> $this->assertEquals($expected, $sorted->toList());
<ide>
<ide> $items = new ArrayObject([
<ide> new \DateTime('2014-07-21'),
<ide> new \DateTime('2015-06-30'),
<del> new \DateTimeImmutable('2013-08-12')
<add> new \DateTimeImmutable('2013-08-12'),
<ide> ]);
<ide>
<ide> $sorted = new SortIterator($items, $callback, SORT_ASC);
<ide><path>tests/TestCase/Collection/Iterator/TreeIteratorTest.php
<ide> public function testPrinter()
<ide> 'id' => 1,
<ide> 'name' => 'a',
<ide> 'stuff' => [
<del> ['id' => 2, 'name' => 'b', 'stuff' => [['id' => 3, 'name' => 'c']]]
<del> ]
<add> ['id' => 2, 'name' => 'b', 'stuff' => [['id' => 3, 'name' => 'c']]],
<add> ],
<ide> ],
<del> ['id' => 4, 'name' => 'd', 'stuff' => [['id' => 5, 'name' => 'e']]]
<add> ['id' => 4, 'name' => 'd', 'stuff' => [['id' => 5, 'name' => 'e']]],
<ide> ];
<ide> $items = new NestIterator($items, 'stuff');
<ide> $result = (new TreeIterator($items))->printer('name')->toArray();
<ide> public function testPrinter()
<ide> '__b',
<ide> '____c',
<ide> 'd',
<del> '__e'
<add> '__e',
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testPrinterCustomKeyAndSpacer()
<ide> 'id' => 1,
<ide> 'name' => 'a',
<ide> 'stuff' => [
<del> ['id' => 2, 'name' => 'b', 'stuff' => [['id' => 3, 'name' => 'c']]]
<del> ]
<add> ['id' => 2, 'name' => 'b', 'stuff' => [['id' => 3, 'name' => 'c']]],
<add> ],
<ide> ],
<del> ['id' => 4, 'name' => 'd', 'stuff' => [['id' => 5, 'name' => 'e']]]
<add> ['id' => 4, 'name' => 'd', 'stuff' => [['id' => 5, 'name' => 'e']]],
<ide> ];
<ide> $items = new NestIterator($items, 'stuff');
<ide> $result = (new TreeIterator($items))->printer('id', 'name', '@@')->toArray();
<ide> public function testPrinterCustomKeyAndSpacer()
<ide> 'b' => '@@2',
<ide> 'c' => '3',
<ide> 'd' => '4',
<del> 'e' => '@@5'
<add> 'e' => '@@5',
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testPrinterWithClosure()
<ide> 'id' => 1,
<ide> 'name' => 'a',
<ide> 'stuff' => [
<del> ['id' => 2, 'name' => 'b', 'stuff' => [['id' => 3, 'name' => 'c']]]
<del> ]
<add> ['id' => 2, 'name' => 'b', 'stuff' => [['id' => 3, 'name' => 'c']]],
<add> ],
<ide> ],
<del> ['id' => 4, 'name' => 'd', 'stuff' => [['id' => 5, 'name' => 'e']]]
<add> ['id' => 4, 'name' => 'd', 'stuff' => [['id' => 5, 'name' => 'e']]],
<ide> ];
<ide> $items = new NestIterator($items, 'stuff');
<ide> $result = (new TreeIterator($items))
<ide> public function testPrinterWithClosure()
<ide> '2.0 b',
<ide> '3.0 c',
<ide> '1.1 d',
<del> '2.0 e'
<add> '2.0 e',
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide><path>tests/TestCase/Console/ArgumentsTest.php
<ide> public function testGetOptions()
<ide> $options = [
<ide> 'verbose' => true,
<ide> 'off' => false,
<del> 'empty' => ''
<add> 'empty' => '',
<ide> ];
<ide> $args = new Arguments([], $options, []);
<ide> $this->assertSame($options, $args->getOptions());
<ide> public function testHasOption()
<ide> 'verbose' => true,
<ide> 'off' => false,
<ide> 'zero' => 0,
<del> 'empty' => ''
<add> 'empty' => '',
<ide> ];
<ide> $args = new Arguments([], $options, []);
<ide> $this->assertTrue($args->hasOption('verbose'));
<ide> public function testGetOption()
<ide> 'verbose' => true,
<ide> 'off' => false,
<ide> 'zero' => 0,
<del> 'empty' => ''
<add> 'empty' => '',
<ide> ];
<ide> $args = new Arguments([], $options, []);
<ide> $this->assertTrue($args->getOption('verbose'));
<ide><path>tests/TestCase/Console/CommandCollectionTest.php
<ide> public function testConstructor()
<ide> {
<ide> $collection = new CommandCollection([
<ide> 'i18n' => I18nShell::class,
<del> 'routes' => RoutesShell::class
<add> 'routes' => RoutesShell::class,
<ide> ]);
<ide> $this->assertTrue($collection->has('routes'));
<ide> $this->assertTrue($collection->has('i18n'));
<ide> public function testConstructorInvalidClass()
<ide> $this->expectExceptionMessage('Cannot use \'stdClass\' for command \'nope\' it is not a subclass of Cake\Console\Shell');
<ide> new CommandCollection([
<ide> 'i18n' => I18nShell::class,
<del> 'nope' => stdClass::class
<add> 'nope' => stdClass::class,
<ide> ]);
<ide> }
<ide>
<ide> public function testGetIterator()
<ide> {
<ide> $in = [
<ide> 'i18n' => I18nShell::class,
<del> 'routes' => RoutesShell::class
<add> 'routes' => RoutesShell::class,
<ide> ];
<ide> $collection = new CommandCollection($in);
<ide> $out = [];
<ide><path>tests/TestCase/Console/CommandRunnerTest.php
<ide> public function testRunValidCommandSubcommandName()
<ide> {
<ide> $app = $this->makeAppWithCommands([
<ide> 'tool build' => DemoCommand::class,
<del> 'tool' => AbortCommand::class
<add> 'tool' => AbortCommand::class,
<ide> ]);
<ide> $output = new ConsoleOutput();
<ide>
<ide> public function testRunValidCommandNestedName()
<ide> {
<ide> $app = $this->makeAppWithCommands([
<ide> 'tool build assets' => DemoCommand::class,
<del> 'tool' => AbortCommand::class
<add> 'tool' => AbortCommand::class,
<ide> ]);
<ide> $output = new ConsoleOutput();
<ide>
<ide> public function testRunCallsPluginHookMethods()
<ide> $app = $this->getMockBuilder(BaseApplication::class)
<ide> ->setMethods([
<ide> 'middleware', 'bootstrap', 'routes',
<del> 'pluginBootstrap', 'pluginConsole', 'pluginRoutes'
<add> 'pluginBootstrap', 'pluginConsole', 'pluginRoutes',
<ide> ])
<ide> ->setConstructorArgs([$this->config])
<ide> ->getMock();
<ide><path>tests/TestCase/Console/ConsoleOptionParserTest.php
<ide> public function testAddOptionLong()
<ide> {
<ide> $parser = new ConsoleOptionParser('test', false);
<ide> $parser->addOption('test', [
<del> 'short' => 't'
<add> 'short' => 't',
<ide> ]);
<ide> $result = $parser->parse(['--test', 'value']);
<ide> $this->assertEquals(['test' => 'value', 'help' => false], $result[0], 'Long parameter did not parse out');
<ide> public function testAddOptionLongEquals()
<ide> {
<ide> $parser = new ConsoleOptionParser('test', false);
<ide> $parser->addOption('test', [
<del> 'short' => 't'
<add> 'short' => 't',
<ide> ]);
<ide> $result = $parser->parse(['--test=value']);
<ide> $this->assertEquals(['test' => 'value', 'help' => false], $result[0], 'Long parameter did not parse out');
<ide> public function testAddOptionShort()
<ide> {
<ide> $parser = new ConsoleOptionParser('test', false);
<ide> $parser->addOption('test', [
<del> 'short' => 't'
<add> 'short' => 't',
<ide> ]);
<ide> $result = $parser->parse(['-t', 'value']);
<ide> $this->assertEquals(['test' => 'value', 'help' => false], $result[0], 'Short parameter did not parse out');
<ide> public function testAddOptionWithMultipleShort()
<ide> $parser = new ConsoleOptionParser('test', false);
<ide> $parser->addOption('source', [
<ide> 'multiple' => true,
<del> 'short' => 's'
<add> 'short' => 's',
<ide> ]);
<ide> $result = $parser->parse(['-s', 'mysql', '-s', 'postgres']);
<ide> $this->assertEquals(
<ide> [
<ide> 'source' => ['mysql', 'postgres'],
<del> 'help' => false
<add> 'help' => false,
<ide> ],
<ide> $result[0],
<ide> 'Short parameter did not parse out'
<ide> public function testAddOptionWithMultiple()
<ide> $expected = [
<ide> 'source' => [
<ide> 'mysql',
<del> 'postgres'
<add> 'postgres',
<ide> ],
<del> 'help' => false
<add> 'help' => false,
<ide> ];
<ide> $this->assertEquals($expected, $result[0], 'options with multiple values did not parse');
<ide> }
<ide> public function testAddMultipleOptionsWithMultiple()
<ide> 'export' => true,
<ide> 'source' => [
<ide> 'mysql',
<del> 'postgres'
<add> 'postgres',
<ide> ],
<ide> 'name' => 'annual-report',
<del> 'help' => false
<add> 'help' => false,
<ide> ];
<ide> $this->assertEquals($expected, $result[0], 'options with multiple values did not parse');
<ide> }
<ide> public function testAddOptions()
<ide> $parser = new ConsoleOptionParser('something', false);
<ide> $result = $parser->addOptions([
<ide> 'name' => ['help' => 'The name'],
<del> 'other' => ['help' => 'The other arg']
<add> 'other' => ['help' => 'The other arg'],
<ide> ]);
<ide> $this->assertEquals($parser, $result, 'addOptions is not chainable.');
<ide>
<ide> public function testAddArguments()
<ide> $parser = new ConsoleOptionParser('test', false);
<ide> $result = $parser->addArguments([
<ide> 'name' => ['help' => 'The name'],
<del> 'other' => ['help' => 'The other arg']
<add> 'other' => ['help' => 'The other arg'],
<ide> ]);
<ide> $this->assertEquals($parser, $result, 'addArguments is not chainable.');
<ide>
<ide> public function testSubcommand()
<ide> {
<ide> $parser = new ConsoleOptionParser('test', false);
<ide> $result = $parser->addSubcommand('initdb', [
<del> 'help' => 'Initialize the database'
<add> 'help' => 'Initialize the database',
<ide> ]);
<ide> $this->assertEquals($parser, $result, 'Adding a subcommand is not chainable');
<ide> }
<ide> public function testSubcommandCamelBacked()
<ide> {
<ide> $parser = new ConsoleOptionParser('test', false);
<ide> $result = $parser->addSubcommand('initMyDb', [
<del> 'help' => 'Initialize the database'
<add> 'help' => 'Initialize the database',
<ide> ]);
<ide>
<ide> $subcommands = array_keys($result->subcommands());
<ide> public function testAddSubcommands()
<ide> $parser = new ConsoleOptionParser('test', false);
<ide> $result = $parser->addSubcommands([
<ide> 'initdb' => ['help' => 'Initialize the database'],
<del> 'create' => ['help' => 'Create something']
<add> 'create' => ['help' => 'Create something'],
<ide> ]);
<ide> $this->assertEquals($parser, $result, 'Adding a subcommands is not chainable');
<ide> $result = $parser->subcommands();
<ide> public function testHelpSubcommandHelp()
<ide> $parser = new ConsoleOptionParser('mycommand', false);
<ide> $parser->addSubcommand('method', [
<ide> 'help' => 'This is another command',
<del> 'parser' => $subParser
<add> 'parser' => $subParser,
<ide> ])
<ide> ->addOption('test', ['help' => 'A test option.']);
<ide>
<ide> public function testHelpSubcommandInheritOptions()
<ide> {
<ide> $parser = new ConsoleOptionParser('mycommand', false);
<ide> $parser->addSubcommand('build', [
<del> 'help' => 'Build things.'
<add> 'help' => 'Build things.',
<ide> ])->addSubcommand('destroy', [
<del> 'help' => 'Destroy things.'
<add> 'help' => 'Destroy things.',
<ide> ])->addOption('connection', [
<ide> 'help' => 'Db connection.',
<ide> 'short' => 'c',
<ide> public function testHelpSubcommandHelpArray()
<ide> 'short' => 'f',
<ide> 'help' => 'Foo.',
<ide> 'boolean' => true,
<del> ]
<add> ],
<ide> ],
<ide> ];
<ide>
<ide> $parser = new ConsoleOptionParser('mycommand', false);
<ide> $parser->addSubcommand('method', [
<ide> 'help' => 'This is a subcommand',
<del> 'parser' => $subParser
<add> 'parser' => $subParser,
<ide> ])
<ide> ->setRootName('tool')
<ide> ->addOption('test', ['help' => 'A test option.']);
<ide> public function testHelpSubcommandInheritParser()
<ide> $parser = new ConsoleOptionParser('mycommand', false);
<ide> $parser->addSubcommand('method', [
<ide> 'help' => 'This is another command',
<del> 'parser' => $subParser
<add> 'parser' => $subParser,
<ide> ])
<ide> ->addOption('test', ['help' => 'A test option.']);
<ide>
<ide> public function testHelpUnknownSubcommand()
<ide> 'short' => 'f',
<ide> 'help' => 'Foo.',
<ide> 'boolean' => true,
<del> ]
<add> ],
<ide> ],
<ide> ];
<ide>
<ide> $parser = new ConsoleOptionParser('mycommand', false);
<ide> $parser
<ide> ->addSubcommand('method', [
<ide> 'help' => 'This is a subcommand',
<del> 'parser' => $subParser
<add> 'parser' => $subParser,
<ide> ])
<ide> ->addOption('test', ['help' => 'A test option.'])
<ide> ->addSubcommand('unstash');
<ide> public function testBuildFromArray()
<ide> 'command' => 'test',
<ide> 'arguments' => [
<ide> 'name' => ['help' => 'The name'],
<del> 'other' => ['help' => 'The other arg']
<add> 'other' => ['help' => 'The other arg'],
<ide> ],
<ide> 'options' => [
<ide> 'name' => ['help' => 'The name'],
<del> 'other' => ['help' => 'The other arg']
<add> 'other' => ['help' => 'The other arg'],
<ide> ],
<ide> 'subcommands' => [
<del> 'initdb' => ['help' => 'make database']
<add> 'initdb' => ['help' => 'make database'],
<ide> ],
<ide> 'description' => 'description text',
<del> 'epilog' => 'epilog text'
<add> 'epilog' => 'epilog text',
<ide> ];
<ide> $parser = ConsoleOptionParser::buildFromArray($spec);
<ide>
<ide> public function testParsingWithSubParser()
<ide> 'parser' => [
<ide> 'options' => [
<ide> 'secondary' => ['boolean' => true],
<del> 'fourth' => ['help' => 'fourth option']
<add> 'fourth' => ['help' => 'fourth option'],
<ide> ],
<ide> 'arguments' => [
<del> 'sub_arg' => ['choices' => ['c', 'd']]
<del> ]
<del> ]
<add> 'sub_arg' => ['choices' => ['c', 'd']],
<add> ],
<add> ],
<ide> ]);
<ide>
<ide> $result = $parser->parse(['sub', '--secondary', '--fourth', '4', 'c']);
<ide> public function testToArray()
<ide> 'command' => 'test',
<ide> 'arguments' => [
<ide> 'name' => ['help' => 'The name'],
<del> 'other' => ['help' => 'The other arg']
<add> 'other' => ['help' => 'The other arg'],
<ide> ],
<ide> 'options' => [
<ide> 'name' => ['help' => 'The name'],
<del> 'other' => ['help' => 'The other arg']
<add> 'other' => ['help' => 'The other arg'],
<ide> ],
<ide> 'subcommands' => [
<del> 'initdb' => ['help' => 'make database']
<add> 'initdb' => ['help' => 'make database'],
<ide> ],
<ide> 'description' => 'description text',
<del> 'epilog' => 'epilog text'
<add> 'epilog' => 'epilog text',
<ide> ];
<ide> $parser = ConsoleOptionParser::buildFromArray($spec);
<ide> $result = $parser->toArray();
<ide><path>tests/TestCase/Console/ConsoleOutputTest.php
<ide> public function testFormattingCustom()
<ide> 'text' => 'magenta',
<ide> 'background' => 'cyan',
<ide> 'blink' => true,
<del> 'underline' => true
<add> 'underline' => true,
<ide> ]);
<ide>
<ide> $this->output->expects($this->once())->method('_write')
<ide><path>tests/TestCase/Console/HelpFormatterTest.php
<ide> public function testHelpWithChoices()
<ide> ->addArgument('type', [
<ide> 'help' => 'Resource type.',
<ide> 'choices' => ['aco', 'aro'],
<del> 'required' => true
<add> 'required' => true,
<ide> ])
<ide> ->addArgument('other_longer', ['help' => 'Another argument.']);
<ide>
<ide> public function testHelpWithOptions()
<ide> $parser = new ConsoleOptionParser('mycommand', false);
<ide> $parser->addOption('test', ['help' => 'A test option.'])
<ide> ->addOption('connection', [
<del> 'short' => 'c', 'help' => 'The connection to use.', 'default' => 'default'
<add> 'short' => 'c', 'help' => 'The connection to use.', 'default' => 'default',
<ide> ]);
<ide>
<ide> $formatter = new HelpFormatter($parser);
<ide> public function testXmlHelpWithChoices()
<ide> ->addArgument('type', [
<ide> 'help' => 'Resource type.',
<ide> 'choices' => ['aco', 'aro'],
<del> 'required' => true
<add> 'required' => true,
<ide> ])
<ide> ->addArgument('other_longer', ['help' => 'Another argument.']);
<ide>
<ide> public function testXmlHelpWithOptions()
<ide> $parser = new ConsoleOptionParser('mycommand', false);
<ide> $parser->addOption('test', ['help' => 'A test option.'])
<ide> ->addOption('connection', [
<del> 'short' => 'c', 'help' => 'The connection to use.', 'default' => 'default'
<add> 'short' => 'c', 'help' => 'The connection to use.', 'default' => 'default',
<ide> ]);
<ide>
<ide> $formatter = new HelpFormatter($parser);
<ide><path>tests/TestCase/Console/ShellDispatcherTest.php
<ide> public function testAddShortPluginAlias()
<ide> {
<ide> $expected = [
<ide> 'Company' => 'Company/TestPluginThree.company',
<del> 'Example' => 'TestPlugin.example'
<add> 'Example' => 'TestPlugin.example',
<ide> ];
<ide> $result = $this->dispatcher->addShortPluginAliases();
<ide> $this->assertSame($expected, $result, 'Should return the list of aliased plugin shells');
<ide>
<ide> ShellDispatcher::alias('Example', 'SomeOther.PluginsShell');
<ide> $expected = [
<ide> 'Company' => 'Company/TestPluginThree.company',
<del> 'Example' => 'SomeOther.PluginsShell'
<add> 'Example' => 'SomeOther.PluginsShell',
<ide> ];
<ide> $result = $this->dispatcher->addShortPluginAliases();
<ide> $this->assertSame($expected, $result, 'Should not overwrite existing aliases');
<ide><path>tests/TestCase/Console/ShellTest.php
<ide> class ShellTest extends TestCase
<ide> 'core.Comments',
<ide> 'core.Posts',
<ide> 'core.Tags',
<del> 'core.Users'
<add> 'core.Users',
<ide> ];
<ide>
<ide> /** @var \Cake\Console\Shell */
<ide> public function testCreateFileOverwriteAll()
<ide> $files = [
<ide> $path . DS . 'file1.php' => 'My first content',
<ide> $path . DS . 'file2.php' => 'My second content',
<del> $path . DS . 'file3.php' => 'My third content'
<add> $path . DS . 'file3.php' => 'My third content',
<ide> ];
<ide>
<ide> new Folder($path, true);
<ide> public function testDispatchShellArgsParser()
<ide>
<ide> // Shell::dispatchShell(['command' => 'schema create DbAcl']);
<ide> $result = $Shell->parseDispatchArguments([[
<del> 'command' => 'schema create DbAcl'
<add> 'command' => 'schema create DbAcl',
<ide> ]]);
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> // Shell::dispatchShell(['command' => ['schema', 'create', 'DbAcl']]);
<ide> $result = $Shell->parseDispatchArguments([[
<del> 'command' => ['schema', 'create', 'DbAcl']
<add> 'command' => ['schema', 'create', 'DbAcl'],
<ide> ]]);
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $expected[1] = ['param' => 'value'];
<ide> // Shell::dispatchShell(['command' => 'schema create DbAcl', 'extra' => ['param' => 'value']]);
<ide> $result = $Shell->parseDispatchArguments([[
<ide> 'command' => 'schema create DbAcl',
<del> 'extra' => ['param' => 'value']
<add> 'extra' => ['param' => 'value'],
<ide> ]]);
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> // Shell::dispatchShell(['command' => ['schema', 'create', 'DbAcl'], 'extra' => ['param' => 'value']]);
<ide> $result = $Shell->parseDispatchArguments([[
<ide> 'command' => ['schema', 'create', 'DbAcl'],
<del> 'extra' => ['param' => 'value']
<add> 'extra' => ['param' => 'value'],
<ide> ]]);
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testParamReading($toRead, $expected)
<ide> 'key' => 'value',
<ide> 'help' => false,
<ide> 'emptykey' => '',
<del> 'truthy' => true
<add> 'truthy' => true,
<ide> ];
<ide> $this->assertSame($expected, $this->Shell->param($toRead));
<ide> }
<ide> public function paramReadingDataProvider()
<ide> [
<ide> 'does_not_exist',
<ide> null,
<del> ]
<add> ],
<ide> ];
<ide> }
<ide>
<ide> public function testDebugInfo()
<ide> 'tasks' => [],
<ide> 'params' => [],
<ide> 'args' => [],
<del> 'interactive' => true
<add> 'interactive' => true,
<ide> ];
<ide> $result = $this->Shell->__debugInfo();
<ide> $this->assertEquals($expected, $result);
<ide><path>tests/TestCase/Controller/Component/AuthComponentTest.php
<ide> public function setUp()
<ide> $request = new ServerRequest([
<ide> 'url' => '/auth_test',
<ide> 'environment' => [
<del> 'REQUEST_METHOD' => 'GET'
<add> 'REQUEST_METHOD' => 'GET',
<ide> ],
<ide> 'params' => [
<ide> 'plugin' => null,
<ide> 'controller' => 'AuthTest',
<del> 'action' => 'index'
<add> 'action' => 'index',
<ide> ],
<del> 'webroot' => '/'
<add> 'webroot' => '/',
<ide> ]);
<ide>
<ide> $response = new Response();
<ide> public function testIdentify()
<ide> ->getMock();
<ide> $this->Auth->authenticate = [
<ide> 'AuthLoginForm' => [
<del> 'userModel' => 'AuthUsers'
<del> ]
<add> 'userModel' => 'AuthUsers',
<add> ],
<ide> ];
<ide>
<ide> $this->Auth->setAuthenticateObject(0, $AuthLoginFormAuthenticate);
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 'AuthUsers' => [
<ide> 'username' => 'mark',
<del> 'password' => Security::hash('cake', null, true)
<del> ]
<add> 'password' => Security::hash('cake', null, true),
<add> ],
<ide> ]);
<ide>
<ide> $user = [
<ide> 'id' => 1,
<del> 'username' => 'mark'
<add> 'username' => 'mark',
<ide> ];
<ide>
<ide> $AuthLoginFormAuthenticate->expects($this->once())
<ide> public function testIdentifyArrayAccess()
<ide> ->getMock();
<ide> $this->Auth->authenticate = [
<ide> 'AuthLoginForm' => [
<del> 'userModel' => 'AuthUsers'
<del> ]
<add> 'userModel' => 'AuthUsers',
<add> ],
<ide> ];
<ide>
<ide> $this->Auth->setAuthenticateObject(0, $AuthLoginFormAuthenticate);
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 'AuthUsers' => [
<ide> 'username' => 'mark',
<del> 'password' => Security::hash('cake', null, true)
<del> ]
<add> 'password' => Security::hash('cake', null, true),
<add> ],
<ide> ]);
<ide>
<ide> $user = new \ArrayObject([
<ide> 'id' => 1,
<del> 'username' => 'mark'
<add> 'username' => 'mark',
<ide> ]);
<ide>
<ide> $AuthLoginFormAuthenticate->expects($this->once())
<ide> public function testAllConfigWithAuthenticate()
<ide> {
<ide> $this->Controller->Auth->setConfig('authenticate', [
<ide> AuthComponent::ALL => ['userModel' => 'AuthUsers'],
<del> 'Form'
<add> 'Form',
<ide> ]);
<ide> $objects = array_values($this->Controller->Auth->constructAuthenticate());
<ide> $result = $objects[0];
<ide> public function testAllowedActionsSetWithAllowMethod()
<ide> public function testLoginRedirect()
<ide> {
<ide> $this->Auth->session->write('Auth', [
<del> 'AuthUsers' => ['id' => '1', 'username' => 'nate']
<add> 'AuthUsers' => ['id' => '1', 'username' => 'nate'],
<ide> ]);
<ide>
<ide> $this->Controller->request = $this->Controller->request = new ServerRequest([
<ide> 'params' => ['controller' => 'Users', 'action' => 'login'],
<ide> 'url' => '/users/login',
<ide> 'environment' => ['HTTP_REFERER' => false],
<del> 'session' => $this->Auth->session
<add> 'session' => $this->Auth->session,
<ide> ]);
<ide>
<ide> $this->Auth->setConfig('loginRedirect', [
<ide> 'controller' => 'pages',
<ide> 'action' => 'display',
<del> 'welcome'
<add> 'welcome',
<ide> ]);
<ide> $event = new Event('Controller.startup', $this->Controller);
<ide> $this->Auth->startup($event);
<ide> public function testLoginRedirect()
<ide> 'params' => ['controller' => 'Posts', 'action' => 'view', 'pass' => [1]],
<ide> 'url' => '/posts/view/1',
<ide> 'environment' => ['HTTP_REFERER' => false, 'REQUEST_METHOD' => 'GET'],
<del> 'session' => $this->Auth->session
<add> 'session' => $this->Auth->session,
<ide> ]);
<ide>
<ide> $this->Auth->setConfig('authorize', 'controller');
<ide>
<ide> $this->Auth->setConfig('loginAction', [
<del> 'controller' => 'AuthTest', 'action' => 'login'
<add> 'controller' => 'AuthTest', 'action' => 'login',
<ide> ]);
<ide> $event = new Event('Controller.startup', $this->Controller);
<ide> $response = $this->Auth->startup($event);
<ide> $expected = Router::url([
<ide> 'controller' => 'AuthTest',
<ide> 'action' => 'login',
<del> '?' => ['redirect' => '/posts/view/1']
<add> '?' => ['redirect' => '/posts/view/1'],
<ide> ], true);
<ide> $redirectHeader = $response->getHeaderLine('Location');
<ide> $this->assertEquals($expected, $redirectHeader);
<ide> public function testLoginRedirect()
<ide> 'params' => ['controller' => 'Posts', 'action' => 'view', 'pass' => [1]],
<ide> 'url' => '/posts/view/1',
<ide> 'environment' => ['HTTP_REFERER' => false, 'REQUEST_METHOD' => 'GET'],
<del> 'session' => $this->Auth->session
<add> 'session' => $this->Auth->session,
<ide> ]);
<ide> $this->Auth->setConfig('loginAction', ['controller' => 'AuthTest', 'action' => 'login']);
<ide> $event = new Event('Controller.startup', $this->Controller);
<ide> public function testLoginRedirectPost()
<ide> $this->Controller->request = new ServerRequest([
<ide> 'environment' => [
<ide> 'HTTP_REFERER' => Router::url('/foo/bar', true),
<del> 'REQUEST_METHOD' => 'POST'
<add> 'REQUEST_METHOD' => 'POST',
<ide> ],
<ide> 'params' => ['controller' => 'Posts', 'action' => 'view', 'pass' => [1]],
<ide> 'url' => '/posts/view/1?print=true&refer=menu',
<del> 'session' => $this->Auth->session
<add> 'session' => $this->Auth->session,
<ide> ]);
<ide> $this->Auth->setConfig('loginAction', ['controller' => 'AuthTest', 'action' => 'login']);
<ide> $event = new Event('Controller.startup', $this->Controller);
<ide> public function testLoginRedirectPostNoReferer()
<ide> 'environment' => ['REQUEST_METHOD' => 'POST'],
<ide> 'params' => ['controller' => 'Posts', 'action' => 'view', 'pass' => [1]],
<ide> 'url' => '/posts/view/1?print=true&refer=menu',
<del> 'session' => $this->Auth->session
<add> 'session' => $this->Auth->session,
<ide> ]);
<ide> $this->Auth->setConfig('loginAction', ['controller' => 'AuthTest', 'action' => 'login']);
<ide> $event = new Event('Controller.startup', $this->Controller);
<ide> public function testLoginRedirectQueryString()
<ide> 'environment' => ['REQUEST_METHOD' => 'GET'],
<ide> 'params' => ['controller' => 'Posts', 'action' => 'view', 'pass' => [29]],
<ide> 'url' => '/posts/view/29?print=true&refer=menu',
<del> 'session' => $this->Auth->session
<add> 'session' => $this->Auth->session,
<ide> ]);
<ide>
<ide> $this->Auth->setConfig('loginAction', ['controller' => 'AuthTest', 'action' => 'login']);
<ide> public function testLoginRedirectQueryString()
<ide> $expected = Router::url([
<ide> 'controller' => 'AuthTest',
<ide> 'action' => 'login',
<del> '?' => ['redirect' => '/posts/view/29?print=true&refer=menu']
<add> '?' => ['redirect' => '/posts/view/29?print=true&refer=menu'],
<ide> ], true);
<ide> $redirectHeader = $response->getHeaderLine('Location');
<ide> $this->assertEquals($expected, $redirectHeader);
<ide> public function testLoginRedirectQueryStringWithComplexLoginActionUrl()
<ide> 'environment' => ['REQUEST_METHOD' => 'GET'],
<ide> 'params' => ['controller' => 'Posts', 'action' => 'view', 'pass' => [29]],
<ide> 'url' => '/posts/view/29?print=true&refer=menu',
<del> 'session' => $this->Auth->session
<add> 'session' => $this->Auth->session,
<ide> ]);
<ide>
<ide> $this->Auth->session->delete('Auth');
<ide> public function testLoginRedirectQueryStringWithComplexLoginActionUrl()
<ide> 'controller' => 'AuthTest',
<ide> 'action' => 'login',
<ide> 'passed-param',
<del> '?' => ['a' => 'b', 'redirect' => '/posts/view/29?print=true&refer=menu']
<add> '?' => ['a' => 'b', 'redirect' => '/posts/view/29?print=true&refer=menu'],
<ide> ], true);
<ide> $this->assertEquals($expected, $redirectHeader);
<ide> }
<ide> public function testLoginRedirectDifferentBaseUrl()
<ide> 'dir' => APP_DIR,
<ide> 'webroot' => 'webroot',
<ide> 'base' => false,
<del> 'baseUrl' => '/cake/index.php'
<add> 'baseUrl' => '/cake/index.php',
<ide> ]);
<ide>
<ide> $this->Auth->session->delete('Auth');
<ide> public function testLoginRedirectDifferentBaseUrl()
<ide> 'params' => [
<ide> 'plugin' => null,
<ide> 'controller' => 'Posts',
<del> 'action' => 'add'
<add> 'action' => 'add',
<ide> ],
<ide> 'environment' => [
<del> 'REQUEST_METHOD' => 'GET'
<add> 'REQUEST_METHOD' => 'GET',
<ide> ],
<ide> 'session' => $this->Auth->session,
<ide> 'base' => '',
<del> 'webroot' => '/'
<add> 'webroot' => '/',
<ide> ]);
<ide> $this->Controller->request = $request;
<ide>
<ide> public function testNoLoginRedirectForAuthenticatedUser()
<ide> 'params' => [
<ide> 'plugin' => null,
<ide> 'controller' => 'auth_test',
<del> 'action' => 'login'
<add> 'action' => 'login',
<ide> ],
<ide> 'url' => '/auth_test/login',
<del> 'session' => $this->Auth->session
<add> 'session' => $this->Auth->session,
<ide> ]);
<ide> $this->Controller->request = $request;
<ide>
<ide> public function testStartupLoginActionIgnoreQueryString()
<ide> 'params' => [
<ide> 'plugin' => null,
<ide> 'controller' => 'auth_test',
<del> 'action' => 'login'
<add> 'action' => 'login',
<ide> ],
<ide> 'query' => ['redirect' => '/admin/articles'],
<ide> 'url' => '/auth_test/login?redirect=%2Fadmin%2Farticles',
<del> 'session' => $this->Auth->session
<add> 'session' => $this->Auth->session,
<ide> ]);
<ide> $this->Controller->request = $request;
<ide>
<ide> public function testDefaultToLoginRedirect()
<ide> 'params' => [
<ide> 'plugin' => null,
<ide> 'controller' => 'Part',
<del> 'action' => 'on'
<add> 'action' => 'on',
<ide> ],
<ide> 'base' => 'dirname',
<del> 'webroot' => '/dirname/'
<add> 'webroot' => '/dirname/',
<ide> ]);
<ide> Router::pushRequest($request);
<ide>
<ide> $this->Auth->setConfig('authorize', ['Controller']);
<ide> $this->Auth->setUser(['username' => 'mariano', 'password' => 'cake']);
<ide> $this->Auth->setConfig('loginRedirect', [
<ide> 'controller' => 'something',
<del> 'action' => 'else'
<add> 'action' => 'else',
<ide> ]);
<ide>
<ide> $response = new Response();
<ide> public function testRedirectToUnauthorizedRedirect()
<ide> $request = new ServerRequest([
<ide> 'url' => $url,
<ide> 'session' => $this->Auth->session,
<del> 'params' => ['controller' => 'Party', 'action' => 'on']
<add> 'params' => ['controller' => 'Party', 'action' => 'on'],
<ide> ]);
<ide> $this->Auth->setConfig('authorize', ['Controller']);
<ide> $this->Auth->setUser(['username' => 'admad', 'password' => 'cake']);
<ide> public function testRedirectToUnauthorizedRedirectLoginAction()
<ide> $request = new ServerRequest([
<ide> 'url' => $url,
<ide> 'session' => $this->Auth->session,
<del> 'params' => ['controller' => 'Party', 'action' => 'on']
<add> 'params' => ['controller' => 'Party', 'action' => 'on'],
<ide> ]);
<ide> $this->Auth->setConfig('authorize', ['Controller']);
<ide> $this->Auth->setUser(['username' => 'admad', 'password' => 'cake']);
<ide> public function testRedirectToUnauthorizedRedirectSuppressedAuthError()
<ide> ->getMock();
<ide> $request = new ServerRequest([
<ide> 'url' => $url,
<del> 'params' => ['controller' => 'Party', 'action' => 'on']
<add> 'params' => ['controller' => 'Party', 'action' => 'on'],
<ide> ]);
<ide> $this->Auth->setConfig('authorize', ['Controller']);
<ide> $this->Auth->setUser(['username' => 'admad', 'password' => 'cake']);
<ide> public function testForbiddenException()
<ide> $this->expectException(\Cake\Http\Exception\ForbiddenException::class);
<ide> $this->Auth->setConfig([
<ide> 'authorize' => ['Controller'],
<del> 'unauthorizedRedirect' => false
<add> 'unauthorizedRedirect' => false,
<ide> ]);
<ide> $this->Auth->setUser(['username' => 'baker', 'password' => 'cake']);
<ide>
<ide> public function testNoRedirectOnLoginAction()
<ide>
<ide> $this->Auth->setConfig([
<ide> 'loginAction', ['controller' => 'AuthTest', 'action' => 'login'],
<del> 'authorize', ['Controller']
<add> 'authorize', ['Controller'],
<ide> ]);
<ide>
<ide> $controller->expects($this->never())
<ide> public function testAdminRoute()
<ide> 'controller' => 'AuthTest',
<ide> 'action' => 'add',
<ide> 'plugin' => null,
<del> 'prefix' => 'admin'
<add> 'prefix' => 'admin',
<ide> ],
<ide> 'url' => '/admin/auth_test/add',
<del> 'session' => $this->Auth->session
<add> 'session' => $this->Auth->session,
<ide> ]);
<ide>
<ide> Router::setRequestInfo($this->Controller->request);
<ide>
<ide> $this->Auth->setConfig('loginAction', [
<ide> 'prefix' => 'admin',
<ide> 'controller' => 'auth_test',
<del> 'action' => 'login'
<add> 'action' => 'login',
<ide> ]);
<ide>
<ide> $response = $this->Auth->startup($event);
<ide> public function testAdminRoute()
<ide> 'prefix' => 'admin',
<ide> 'controller' => 'auth_test',
<ide> 'action' => 'login',
<del> '?' => ['redirect' => '/admin/auth_test/add']
<add> '?' => ['redirect' => '/admin/auth_test/add'],
<ide> ], true);
<ide> $this->assertEquals($expected, $redirectHeader);
<ide> }
<ide> public function testLoginActionRedirect()
<ide> 'pass' => [],
<ide> ],
<ide> 'webroot' => '/',
<del> 'url' => $url
<add> 'url' => $url,
<ide> ]);
<ide> Router::setRequestInfo($request);
<ide>
<ide> $this->Auth->setConfig('loginAction', [
<ide> 'prefix' => 'admin',
<ide> 'controller' => 'auth_test',
<del> 'action' => 'login'
<add> 'action' => 'login',
<ide> ]);
<ide> $result = $this->Auth->startup($event);
<ide>
<ide> public function testStatelessAuthWorksWithUser()
<ide> ],
<ide> 'params' => ['controller' => 'AuthTest', 'action' => 'add'],
<ide> 'url' => '/auth_test/add',
<del> 'session' => $this->Auth->session
<add> 'session' => $this->Auth->session,
<ide> ]);
<ide>
<ide> $this->Auth->setConfig('authenticate', [
<del> 'Basic' => ['userModel' => 'AuthUsers']
<add> 'Basic' => ['userModel' => 'AuthUsers'],
<ide> ]);
<ide> $this->Auth->setConfig('storage', 'Memory');
<ide> $this->Auth->startup($event);
<ide> public function testLogout()
<ide> public function testEventTriggering()
<ide> {
<ide> $this->Auth->setConfig('authenticate', [
<del> 'Test' => ['className' => 'TestApp\Auth\TestAuthenticate']
<add> 'Test' => ['className' => 'TestApp\Auth\TestAuthenticate'],
<ide> ]);
<ide>
<ide> $user = $this->Auth->identify();
<ide> public function testAfterIdentifyForStatelessAuthentication()
<ide> ->withEnv('PHP_AUTH_PW', 'cake');
<ide>
<ide> $this->Auth->setConfig('authenticate', [
<del> 'Basic' => ['userModel' => 'AuthUsers']
<add> 'Basic' => ['userModel' => 'AuthUsers'],
<ide> ]);
<ide> $this->Auth->setConfig('storage', 'Memory');
<ide>
<ide> public function testGettingUserAfterSetUser()
<ide> 'username' => 'mariano',
<ide> 'password' => '$2a$10$u05j8FjsvLBNdfhBhc21LOuVMpzpabVXQ9OpC2wO3pSO0q6t7HHMO',
<ide> 'created' => new \DateTime('2007-03-17 01:16:23'),
<del> 'updated' => new \DateTime('2007-03-17 01:18:31')
<add> 'updated' => new \DateTime('2007-03-17 01:18:31'),
<ide> ];
<ide> $this->Auth->setUser($user);
<ide> $this->assertTrue((bool)$this->Auth->user());
<ide> public function testFlashSettings()
<ide> [
<ide> 'key' => 'auth-key',
<ide> 'element' => 'error',
<del> 'params' => ['class' => 'error']
<add> 'params' => ['class' => 'error'],
<ide> ]
<ide> );
<ide>
<ide> public function testFlashSettings()
<ide> ->with('Auth failure', ['key' => 'auth-key', 'element' => 'custom']);
<ide>
<ide> $this->Auth->setConfig('flash', [
<del> 'key' => 'auth-key'
<add> 'key' => 'auth-key',
<ide> ]);
<ide> $this->Auth->flash('Auth failure');
<ide>
<ide> $this->Auth->setConfig('flash', [
<ide> 'key' => 'auth-key',
<del> 'element' => 'custom'
<add> 'element' => 'custom',
<ide> ], false);
<ide> $this->Auth->flash('Auth failure');
<ide> }
<ide> public function testRedirectQueryStringReadEqualToLoginAction()
<ide> {
<ide> $this->Auth->setConfig([
<ide> 'loginAction' => ['controller' => 'users', 'action' => 'login'],
<del> 'loginRedirect' => ['controller' => 'users', 'action' => 'home']
<add> 'loginRedirect' => ['controller' => 'users', 'action' => 'home'],
<ide> ]);
<ide> $this->Controller->request = $this->Controller->request->withQueryParams(['redirect' => '/users/login']);
<ide>
<ide> public function testRedirectQueryStringInvalid()
<ide> {
<ide> $this->Auth->setConfig([
<ide> 'loginAction' => ['controller' => 'users', 'action' => 'login'],
<del> 'loginRedirect' => ['controller' => 'users', 'action' => 'home']
<add> 'loginRedirect' => ['controller' => 'users', 'action' => 'home'],
<ide> ]);
<ide> $this->Controller->request = $this->Controller->request->withQueryParams(['redirect' => 'http://some.domain.example/users/login']);
<ide>
<ide> public function testRedirectUrlWithBaseSet()
<ide> 'dir' => APP_DIR,
<ide> 'webroot' => 'webroot',
<ide> 'base' => false,
<del> 'baseUrl' => '/cake/index.php'
<add> 'baseUrl' => '/cake/index.php',
<ide> ]);
<ide>
<ide> $url = '/users/login';
<ide> $this->Controller->request = $this->Controller->request = new ServerRequest([
<ide> 'url' => $url,
<del> 'params' => ['plugin' => null, 'controller' => 'Users', 'action' => 'login']
<add> 'params' => ['plugin' => null, 'controller' => 'Users', 'action' => 'login'],
<ide> ]);
<ide> Router::setRequestInfo($this->Controller->request);
<ide>
<ide> public function testUser()
<ide> 'group_id' => 1,
<ide> 'Group' => [
<ide> 'id' => '1',
<del> 'name' => 'Members'
<add> 'name' => 'Members',
<ide> ],
<ide> 'is_admin' => false,
<ide> ]];
<ide><path>tests/TestCase/Controller/Component/CookieComponentTest.php
<ide> public function testConfigKeyArray()
<ide> {
<ide> $this->Cookie->configKey('User', [
<ide> 'expires' => '+3 days',
<del> 'path' => '/shop'
<add> 'path' => '/shop',
<ide> ]);
<ide> $result = $this->Cookie->configKey('User');
<ide> $expected = [
<ide> public function testSettings()
<ide> {
<ide> $settings = [
<ide> 'time' => '5 days',
<del> 'path' => '/'
<add> 'path' => '/',
<ide> ];
<ide> $Cookie = new CookieComponent(new ComponentRegistry(), $settings);
<ide> $this->assertEquals($Cookie->getConfig('time'), $settings['time']);
<ide> public function testReadMultipleNames()
<ide> {
<ide> $this->Controller->request = $this->request->withCookieParams([
<ide> 'CakeCookie' => [
<del> 'key' => 'value'
<add> 'key' => 'value',
<ide> ],
<ide> 'OtherCookie' => [
<del> 'key' => 'other value'
<del> ]
<add> 'key' => 'other value',
<add> ],
<ide> ]);
<ide> $this->assertEquals('value', $this->Cookie->read('CakeCookie.key'));
<ide> $this->assertEquals(['key' => 'value'], $this->Cookie->read('CakeCookie'));
<ide> public function testWriteInvalidCipher()
<ide> public function testWriteThanRead()
<ide> {
<ide> $this->Controller->request = $this->request->withCookieParams([
<del> 'User' => ['name' => 'mark']
<add> 'User' => ['name' => 'mark'],
<ide> ]);
<ide> $this->Cookie->write('Testing', 'value');
<ide> $this->assertEquals('mark', $this->Cookie->read('User.name'));
<ide> public function testWriteHttpOnly()
<ide> {
<ide> $this->Cookie->setConfig([
<ide> 'httpOnly' => true,
<del> 'secure' => false
<add> 'secure' => false,
<ide> ]);
<ide> $this->Cookie->write('Testing', 'value', false);
<ide> $expected = [
<ide> public function testWriteMulitMixedEncryption()
<ide> 'path' => '/',
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httpOnly' => false
<add> 'httpOnly' => false,
<ide> ];
<ide> $result = $this->Controller->response->getCookie('Open');
<ide> unset($result['expire']);
<ide> public function testDeleteHttpOnly()
<ide> {
<ide> $this->Cookie->setConfig([
<ide> 'httpOnly' => true,
<del> 'secure' => false
<add> 'secure' => false,
<ide> ]);
<ide> $this->Cookie->delete('Testing');
<ide> $expected = [
<ide> public function testWriteArrayValues()
<ide> 'path' => '/',
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httpOnly' => false
<add> 'httpOnly' => false,
<ide> ];
<ide> $result = $this->Controller->response->getCookie('Testing');
<ide>
<ide> public function testWriteMixedArray()
<ide> 'path' => '/',
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httpOnly' => false
<add> 'httpOnly' => false,
<ide> ];
<ide> $result = $this->Controller->response->getCookie('User');
<ide> unset($result['expire']);
<ide> public function testWriteMixedArray()
<ide> 'path' => '/',
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httpOnly' => false
<add> 'httpOnly' => false,
<ide> ];
<ide> $result = $this->Controller->response->getCookie('User');
<ide> unset($result['expire']);
<ide> public function testReadingDataFromRequest()
<ide> 'Encrypted_multi_cookies' => [
<ide> 'name' => $this->_encrypt('CakePHP'),
<ide> 'version' => $this->_encrypt('1.2.0.x'),
<del> 'tag' => $this->_encrypt('CakePHP Rocks!')
<add> 'tag' => $this->_encrypt('CakePHP Rocks!'),
<ide> ],
<ide> 'Plain_array' => '{"name":"CakePHP","version":"1.2.0.x","tag":"CakePHP Rocks!"}',
<ide> 'Plain_multi_cookies' => [
<ide> 'name' => 'CakePHP',
<ide> 'version' => '1.2.0.x',
<del> 'tag' => 'CakePHP Rocks!'
<del> ]
<add> 'tag' => 'CakePHP Rocks!',
<add> ],
<ide> ]);
<ide>
<ide> $data = $this->Cookie->read('Encrypted_array');
<ide> public function testReadingMalformedEncryptedCookies()
<ide> public function testReadLegacyCookieValue()
<ide> {
<ide> $this->Controller->request = $this->request->withCookieParams([
<del> 'Legacy' => ['value' => $this->_oldImplode([1, 2, 3])]
<add> 'Legacy' => ['value' => $this->_oldImplode([1, 2, 3])],
<ide> ]);
<ide> $result = $this->Cookie->read('Legacy.value');
<ide> $expected = [1, 2, 3];
<ide> public function testReadEmpty()
<ide> 'JSON' => '{"name":"value"}',
<ide> 'Empty' => '',
<ide> 'String' => '{"somewhat:"broken"}',
<del> 'Array' => '{}'
<add> 'Array' => '{}',
<ide> ]);
<ide> $this->assertEquals(['name' => 'value'], $this->Cookie->read('JSON'));
<ide> $this->assertEquals('value', $this->Cookie->read('JSON.name'));
<ide> public function testDeleteRemovesChildren()
<ide> {
<ide> $this->Controller->request = $this->request->withCookieParams([
<ide> 'User' => ['email' => '[email protected]', 'name' => 'mark'],
<del> 'other' => 'value'
<add> 'other' => 'value',
<ide> ]);
<ide> $this->assertEquals('mark', $this->Cookie->read('User.name'));
<ide>
<ide><path>tests/TestCase/Controller/Component/CsrfComponentTest.php
<ide> public function testSafeMethodNoCsrfRequired($method)
<ide> 'REQUEST_METHOD' => $method,
<ide> 'HTTP_X_CSRF_TOKEN' => 'nope',
<ide> ],
<del> 'cookies' => ['csrfToken' => 'testing123']
<add> 'cookies' => ['csrfToken' => 'testing123'],
<ide> ]);
<ide> $controller->response = new Response();
<ide>
<ide> public function testSafeMethodNoCsrfRequired($method)
<ide> public static function httpMethodProvider()
<ide> {
<ide> return [
<del> ['OPTIONS'], ['PATCH'], ['PUT'], ['POST'], ['DELETE'], ['PURGE'], ['INVALIDMETHOD']
<add> ['OPTIONS'], ['PATCH'], ['PUT'], ['POST'], ['DELETE'], ['PURGE'], ['INVALIDMETHOD'],
<ide> ];
<ide> }
<ide>
<ide> public function testValidTokenInHeader($method)
<ide> 'HTTP_X_CSRF_TOKEN' => 'testing123',
<ide> ],
<ide> 'post' => ['a' => 'b'],
<del> 'cookies' => ['csrfToken' => 'testing123']
<add> 'cookies' => ['csrfToken' => 'testing123'],
<ide> ]);
<ide> $controller->response = new Response();
<ide>
<ide> public function testInvalidTokenInHeader($method)
<ide> 'HTTP_X_CSRF_TOKEN' => 'nope',
<ide> ],
<ide> 'post' => ['a' => 'b'],
<del> 'cookies' => ['csrfToken' => 'testing123']
<add> 'cookies' => ['csrfToken' => 'testing123'],
<ide> ]);
<ide> $controller->response = new Response();
<ide>
<ide> public function testValidTokenRequestData($method)
<ide> 'REQUEST_METHOD' => $method,
<ide> ],
<ide> 'post' => ['_csrfToken' => 'testing123'],
<del> 'cookies' => ['csrfToken' => 'testing123']
<add> 'cookies' => ['csrfToken' => 'testing123'],
<ide> ]);
<ide> $controller->response = new Response();
<ide>
<ide> public function testInvalidTokenRequestData($method)
<ide> 'REQUEST_METHOD' => $method,
<ide> ],
<ide> 'post' => ['_csrfToken' => 'nope'],
<del> 'cookies' => ['csrfToken' => 'testing123']
<add> 'cookies' => ['csrfToken' => 'testing123'],
<ide> ]);
<ide> $controller->response = new Response();
<ide>
<ide> public function testInvalidTokenRequestDataMissing()
<ide> 'REQUEST_METHOD' => 'POST',
<ide> ],
<ide> 'post' => [],
<del> 'cookies' => ['csrfToken' => 'testing123']
<add> 'cookies' => ['csrfToken' => 'testing123'],
<ide> ]);
<ide> $controller->response = new Response();
<ide>
<ide> public function testInvalidTokenMissingCookie($method)
<ide> ->getMock();
<ide> $controller->request = new ServerRequest([
<ide> 'environment' => [
<del> 'REQUEST_METHOD' => $method
<add> 'REQUEST_METHOD' => $method,
<ide> ],
<ide> 'post' => ['_csrfToken' => 'could-be-valid'],
<del> 'cookies' => []
<add> 'cookies' => [],
<ide> ]);
<ide> $controller->response = new Response();
<ide>
<ide> public function testCsrfValidationSkipsRequestAction()
<ide> 'environment' => ['REQUEST_METHOD' => 'POST'],
<ide> 'params' => ['requested' => 1],
<ide> 'post' => ['_csrfToken' => 'nope'],
<del> 'cookies' => ['csrfToken' => 'testing123']
<add> 'cookies' => ['csrfToken' => 'testing123'],
<ide> ]);
<ide> $controller->response = new Response();
<ide>
<ide> public function testConfigurationCookieCreate()
<ide> ->getMock();
<ide> $controller->request = new ServerRequest([
<ide> 'environment' => ['REQUEST_METHOD' => 'GET'],
<del> 'webroot' => '/dir/'
<add> 'webroot' => '/dir/',
<ide> ]);
<ide> $controller->response = new Response();
<ide>
<ide> $component = new CsrfComponent($this->registry, [
<ide> 'cookieName' => 'token',
<ide> 'expiry' => '+1 hour',
<ide> 'secure' => true,
<del> 'httpOnly' => true
<add> 'httpOnly' => true,
<ide> ]);
<ide>
<ide> $event = new Event('Controller.startup', $controller);
<ide><path>tests/TestCase/Controller/Component/FlashComponentTest.php
<ide> public function testSet()
<ide> 'message' => 'This is a test message',
<ide> 'key' => 'flash',
<ide> 'element' => 'Flash/default',
<del> 'params' => []
<del> ]
<add> 'params' => [],
<add> ],
<ide> ];
<ide> $result = $this->Session->read('Flash.flash');
<ide> $this->assertEquals($expected, $result);
<ide> public function testSet()
<ide> 'message' => 'This is a test message',
<ide> 'key' => 'flash',
<ide> 'element' => 'Flash/test',
<del> 'params' => ['foo' => 'bar']
<add> 'params' => ['foo' => 'bar'],
<ide> ];
<ide> $result = $this->Session->read('Flash.flash');
<ide> $this->assertEquals($expected, $result);
<ide> public function testSet()
<ide> 'message' => 'This is a test message',
<ide> 'key' => 'flash',
<ide> 'element' => 'MyPlugin.Flash/alert',
<del> 'params' => []
<add> 'params' => [],
<ide> ];
<ide> $result = $this->Session->read('Flash.flash');
<ide> $this->assertEquals($expected, $result);
<ide> public function testSet()
<ide> 'message' => 'This is a test message',
<ide> 'key' => 'foobar',
<ide> 'element' => 'Flash/default',
<del> 'params' => []
<del> ]
<add> 'params' => [],
<add> ],
<ide> ];
<ide> $result = $this->Session->read('Flash.foobar');
<ide> $this->assertEquals($expected, $result);
<ide> public function testSetEscape()
<ide> 'message' => 'This is a <b>test</b> message',
<ide> 'key' => 'flash',
<ide> 'element' => 'Flash/default',
<del> 'params' => ['foo' => 'bar', 'escape' => false]
<del> ]
<add> 'params' => ['foo' => 'bar', 'escape' => false],
<add> ],
<ide> ];
<ide> $result = $this->Session->read('Flash.flash');
<ide> $this->assertEquals($expected, $result);
<ide> public function testSetEscape()
<ide> 'message' => 'This is a test message',
<ide> 'key' => 'escaped',
<ide> 'element' => 'Flash/default',
<del> 'params' => ['foo' => 'bar', 'escape' => true]
<del> ]
<add> 'params' => ['foo' => 'bar', 'escape' => true],
<add> ],
<ide> ];
<ide> $result = $this->Session->read('Flash.escaped');
<ide> $this->assertEquals($expected, $result);
<ide> public function testSetWithClear()
<ide> 'message' => 'This is a test message',
<ide> 'key' => 'flash',
<ide> 'element' => 'Flash/default',
<del> 'params' => []
<del> ]
<add> 'params' => [],
<add> ],
<ide> ];
<ide> $result = $this->Session->read('Flash.flash');
<ide> $this->assertEquals($expected, $result);
<ide> public function testSetWithClear()
<ide> 'message' => 'This is another test message',
<ide> 'key' => 'flash',
<ide> 'element' => 'Flash/default',
<del> 'params' => []
<del> ]
<add> 'params' => [],
<add> ],
<ide> ];
<ide> $result = $this->Session->read('Flash.flash');
<ide> $this->assertEquals($expected, $result);
<ide> public function testSetWithException()
<ide> 'message' => 'This is a test message',
<ide> 'key' => 'flash',
<ide> 'element' => 'Flash/default',
<del> 'params' => ['code' => 404]
<del> ]
<add> 'params' => ['code' => 404],
<add> ],
<ide> ];
<ide> $result = $this->Session->read('Flash.flash');
<ide> $this->assertEquals($expected, $result);
<ide> public function testSetWithComponentConfiguration()
<ide> 'message' => 'This is a test message',
<ide> 'key' => 'flash',
<ide> 'element' => 'Flash/test',
<del> 'params' => []
<del> ]
<add> 'params' => [],
<add> ],
<ide> ];
<ide> $result = $this->Session->read('Flash.flash');
<ide> $this->assertEquals($expected, $result);
<ide> public function testCall()
<ide> 'message' => 'It worked',
<ide> 'key' => 'flash',
<ide> 'element' => 'Flash/success',
<del> 'params' => []
<del> ]
<add> 'params' => [],
<add> ],
<ide> ];
<ide> $result = $this->Session->read('Flash.flash');
<ide> $this->assertEquals($expected, $result);
<ide> public function testCall()
<ide> 'message' => 'It did not work',
<ide> 'key' => 'flash',
<ide> 'element' => 'Flash/error',
<del> 'params' => []
<add> 'params' => [],
<ide> ];
<ide> $result = $this->Session->read('Flash.flash');
<ide> $this->assertEquals($expected, $result, 'Element is ignored in magic call.');
<ide> public function testCall()
<ide> 'message' => 'It worked',
<ide> 'key' => 'flash',
<ide> 'element' => 'MyPlugin.Flash/success',
<del> 'params' => []
<add> 'params' => [],
<ide> ];
<ide> $result = $this->Session->read('Flash.flash');
<ide> $this->assertEquals($expected, $result);
<ide> public function testCallWithClear()
<ide> 'message' => 'It worked',
<ide> 'key' => 'flash',
<ide> 'element' => 'Flash/success',
<del> 'params' => []
<del> ]
<add> 'params' => [],
<add> ],
<ide> ];
<ide> $result = $this->Session->read('Flash.flash');
<ide> $this->assertEquals($expected, $result);
<ide> public function testCallWithClear()
<ide> 'message' => 'It worked too',
<ide> 'key' => 'flash',
<ide> 'element' => 'Flash/success',
<del> 'params' => []
<del> ]
<add> 'params' => [],
<add> ],
<ide> ];
<ide> $result = $this->Session->read('Flash.flash');
<ide> $this->assertEquals($expected, $result);
<ide><path>tests/TestCase/Controller/Component/PaginatorComponentTest.php
<ide> class PaginatorComponentTest extends TestCase
<ide> */
<ide> public $fixtures = [
<ide> 'core.Posts', 'core.Articles', 'core.ArticlesTags',
<del> 'core.Authors', 'core.AuthorsTags', 'core.Tags'
<add> 'core.Authors', 'core.AuthorsTags', 'core.Tags',
<ide> ];
<ide>
<ide> /**
<ide> public function testPaginatorSetting()
<ide> {
<ide> $paginator = new CustomPaginator();
<ide> $component = new PaginatorComponent($this->registry, [
<del> 'paginator' => $paginator
<add> 'paginator' => $paginator,
<ide> ]);
<ide>
<ide> $this->assertSame($paginator, $component->getPaginator());
<ide> public function testInvalidPaginatorOption()
<ide> $this->expectException(\InvalidArgumentException::class);
<ide> $this->expectExceptionMessage('Paginator must be an instance of Cake\Datasource\Paginator');
<ide> new PaginatorComponent($this->registry, [
<del> 'paginator' => new stdClass()
<add> 'paginator' => new stdClass(),
<ide> ]);
<ide> }
<ide>
<ide> public function testPaginateExtraParams()
<ide> 'contain' => ['PaginatorAuthor'],
<ide> 'maxLimit' => 10,
<ide> 'group' => 'PaginatorPosts.published',
<del> 'order' => ['PaginatorPosts.id' => 'ASC']
<add> 'order' => ['PaginatorPosts.id' => 'ASC'],
<ide> ],
<ide> ];
<ide> $table = $this->_getMockPosts(['query']);
<ide> public function testPaginateCustomFinderOptions()
<ide> $this->loadFixtures('Posts');
<ide> $settings = [
<ide> 'PaginatorPosts' => [
<del> 'finder' => ['author' => ['author_id' => 1]]
<del> ]
<add> 'finder' => ['author' => ['author_id' => 1]],
<add> ],
<ide> ];
<ide> $table = $this->getTableLocator()->get('PaginatorPosts');
<ide>
<ide> $expected = $table
<ide> ->find('author', [
<ide> 'conditions' => [
<del> 'PaginatorPosts.author_id' => 1
<del> ]
<add> 'PaginatorPosts.author_id' => 1,
<add> ],
<ide> ])
<ide> ->count();
<ide> $result = $this->Paginator->paginate($table, $settings)->count();
<ide> public function testRequestParamsSetting()
<ide> $settings = [
<ide> 'PaginatorPosts' => [
<ide> 'limit' => 10,
<del> ]
<add> ],
<ide> ];
<ide>
<ide> $table = $this->getTableLocator()->get('PaginatorPosts');
<ide> public function testPaginateCustomFinder()
<ide> 'finder' => 'popular',
<ide> 'fields' => ['id', 'title'],
<ide> 'maxLimit' => 10,
<del> ]
<add> ],
<ide> ];
<ide>
<ide> $table = $this->_getMockPosts(['findPopular']);
<ide> public function testMergeOptionsCustomScope()
<ide> 'scope' => [
<ide> 'page' => 2,
<ide> 'limit' => 5,
<del> ]
<add> ],
<ide> ]);
<ide>
<ide> $settings = [
<ide> public function testMergeOptionsCustomFindKey()
<ide> {
<ide> $this->controller->request = $this->controller->request->withQueryParams([
<ide> 'page' => 10,
<del> 'limit' => 10
<add> 'limit' => 10,
<ide> ]);
<ide> $settings = [
<ide> 'page' => 1,
<ide> 'limit' => 20,
<ide> 'maxLimit' => 100,
<del> 'finder' => 'myCustomFind'
<add> 'finder' => 'myCustomFind',
<ide> ];
<ide> $result = $this->Paginator->mergeOptions('Post', $settings);
<ide> $expected = [
<ide> public function testMergeOptionsQueryString()
<ide> {
<ide> $this->controller->request = $this->controller->request->withQueryParams([
<ide> 'page' => 99,
<del> 'limit' => 75
<add> 'limit' => 75,
<ide> ]);
<ide> $settings = [
<ide> 'page' => 1,
<ide> public function testMergeOptionsDefaultWhiteList()
<ide> 'fields' => ['bad.stuff'],
<ide> 'recursive' => 1000,
<ide> 'conditions' => ['bad.stuff'],
<del> 'contain' => ['bad']
<add> 'contain' => ['bad'],
<ide> ]);
<ide> $settings = [
<ide> 'page' => 1,
<ide> public function testMergeOptionsExtraWhitelist()
<ide> 'fields' => ['bad.stuff'],
<ide> 'recursive' => 1000,
<ide> 'conditions' => ['bad.stuff'],
<del> 'contain' => ['bad']
<add> 'contain' => ['bad'],
<ide> ]);
<ide> $settings = [
<ide> 'page' => 1,
<ide> public function testMergeOptionsExtraWhitelist()
<ide> $this->Paginator->setConfig('whitelist', ['fields']);
<ide> $result = $this->Paginator->mergeOptions('Post', $settings);
<ide> $expected = [
<del> 'page' => 10, 'limit' => 10, 'maxLimit' => 100, 'fields' => ['bad.stuff'], 'whitelist' => ['limit', 'sort', 'page', 'direction', 'fields']
<add> 'page' => 10, 'limit' => 10, 'maxLimit' => 100, 'fields' => ['bad.stuff'], 'whitelist' => ['limit', 'sort', 'page', 'direction', 'fields'],
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testMergeOptionsMaxLimit()
<ide> 'limit' => 100,
<ide> 'maxLimit' => 100,
<ide> 'paramType' => 'named',
<del> 'whitelist' => ['limit', 'sort', 'page', 'direction']
<add> 'whitelist' => ['limit', 'sort', 'page', 'direction'],
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> public function testMergeOptionsMaxLimit()
<ide> 'limit' => 10,
<ide> 'maxLimit' => 10,
<ide> 'paramType' => 'named',
<del> 'whitelist' => ['limit', 'sort', 'page', 'direction']
<add> 'whitelist' => ['limit', 'sort', 'page', 'direction'],
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testGetDefaultMaxLimit()
<ide> 'limit' => 2,
<ide> 'maxLimit' => 10,
<ide> 'order' => [
<del> 'Users.username' => 'asc'
<add> 'Users.username' => 'asc',
<ide> ],
<ide> ];
<ide> $result = $this->Paginator->mergeOptions('Post', $settings);
<ide> public function testGetDefaultMaxLimit()
<ide> 'limit' => 2,
<ide> 'maxLimit' => 10,
<ide> 'order' => [
<del> 'Users.username' => 'asc'
<add> 'Users.username' => 'asc',
<ide> ],
<del> 'whitelist' => ['limit', 'sort', 'page', 'direction']
<add> 'whitelist' => ['limit', 'sort', 'page', 'direction'],
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> public function testGetDefaultMaxLimit()
<ide> 'limit' => 100,
<ide> 'maxLimit' => 10,
<ide> 'order' => [
<del> 'Users.username' => 'asc'
<add> 'Users.username' => 'asc',
<ide> ],
<ide> ];
<ide> $result = $this->Paginator->mergeOptions('Post', $settings);
<ide> public function testGetDefaultMaxLimit()
<ide> 'limit' => 10,
<ide> 'maxLimit' => 10,
<ide> 'order' => [
<del> 'Users.username' => 'asc'
<add> 'Users.username' => 'asc',
<ide> ],
<del> 'whitelist' => ['limit', 'sort', 'page', 'direction']
<add> 'whitelist' => ['limit', 'sort', 'page', 'direction'],
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testValidateSortInvalid()
<ide> $this->controller->request = $this->controller->request->withQueryParams([
<ide> 'page' => 1,
<ide> 'sort' => 'id',
<del> 'direction' => 'herp'
<add> 'direction' => 'herp',
<ide> ]);
<ide> $this->Paginator->paginate($table);
<ide> $this->assertEquals('id', $this->controller->request->getParam('paging.PaginatorPosts.sort'));
<ide> public function testValidateSortWhitelistFailure()
<ide> $options = [
<ide> 'sort' => 'body',
<ide> 'direction' => 'asc',
<del> 'sortWhitelist' => ['title', 'id']
<add> 'sortWhitelist' => ['title', 'id'],
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide>
<ide> public function testValidateSortWhitelistTrusted()
<ide> $options = [
<ide> 'sort' => 'body',
<ide> 'direction' => 'asc',
<del> 'sortWhitelist' => ['body']
<add> 'sortWhitelist' => ['body'],
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide>
<ide> public function testValidateSortWhitelistEmpty()
<ide> $options = [
<ide> 'order' => [
<ide> 'body' => 'asc',
<del> 'foo.bar' => 'asc'
<add> 'foo.bar' => 'asc',
<ide> ],
<ide> 'sort' => 'body',
<ide> 'direction' => 'asc',
<del> 'sortWhitelist' => []
<add> 'sortWhitelist' => [],
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide>
<ide> public function testValidateSortWhitelistNotInSchema()
<ide> $options = [
<ide> 'sort' => 'score',
<ide> 'direction' => 'asc',
<del> 'sortWhitelist' => ['score']
<add> 'sortWhitelist' => ['score'],
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide>
<ide> public function testValidateSortWhitelistMultiple()
<ide> $options = [
<ide> 'order' => [
<ide> 'body' => 'asc',
<del> 'foo.bar' => 'asc'
<add> 'foo.bar' => 'asc',
<ide> ],
<del> 'sortWhitelist' => ['body', 'foo.bar']
<add> 'sortWhitelist' => ['body', 'foo.bar'],
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide>
<ide> $expected = [
<ide> 'model.body' => 'asc',
<del> 'foo.bar' => 'asc'
<add> 'foo.bar' => 'asc',
<ide> ];
<ide> $this->assertEquals($expected, $result['order']);
<ide> }
<ide> public function testValidateSortMultiple()
<ide> $options = [
<ide> 'order' => [
<ide> 'author_id' => 'asc',
<del> 'title' => 'asc'
<del> ]
<add> 'title' => 'asc',
<add> ],
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide>
<ide> $expected = [
<ide> 'model.author_id' => 'asc',
<del> 'model.title' => 'asc'
<add> 'model.title' => 'asc',
<ide> ];
<ide>
<ide> $this->assertEquals($expected, $result['order']);
<ide> public function testValidateSortWithString()
<ide> $model->expects($this->any())->method('hasField')->will($this->returnValue(true));
<ide>
<ide> $options = [
<del> 'order' => 'model.author_id DESC'
<add> 'order' => 'model.author_id DESC',
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide> $expected = 'model.author_id DESC';
<ide> public function testPaginateMaxLimit()
<ide> 'maxLimit' => 100,
<ide> ];
<ide> $this->controller->request = $this->controller->request->withQueryParams([
<del> 'limit' => '1000'
<add> 'limit' => '1000',
<ide> ]);
<ide> $this->Paginator->paginate($table, $settings);
<ide> $this->assertEquals(100, $this->controller->request->getParam('paging.PaginatorPosts.limit'));
<ide> $this->assertEquals(100, $this->controller->request->getParam('paging.PaginatorPosts.perPage'));
<ide>
<ide> $this->controller->request = $this->controller->request->withQueryParams([
<del> 'limit' => '10'
<add> 'limit' => '10',
<ide> ]);
<ide> $this->Paginator->paginate($table, $settings);
<ide> $this->assertEquals(10, $this->controller->request->getParam('paging.PaginatorPosts.limit'));
<ide> public function testPaginateCustomFindFieldsArray()
<ide> $settings = [
<ide> 'finder' => 'list',
<ide> 'conditions' => ['PaginatorPosts.published' => 'Y'],
<del> 'limit' => 2
<add> 'limit' => 2,
<ide> ];
<ide> $results = $this->Paginator->paginate($table, $settings);
<ide>
<ide> public function testPaginateCustomFindCount()
<ide> {
<ide> $settings = [
<ide> 'finder' => 'published',
<del> 'limit' => 2
<add> 'limit' => 2,
<ide> ];
<ide> $table = $this->_getMockPosts(['query']);
<ide> $query = $this->_getMockFindQuery();
<ide> public function testPaginateQuery()
<ide> 'contain' => ['PaginatorAuthor'],
<ide> 'maxLimit' => 10,
<ide> 'group' => 'PaginatorPosts.published',
<del> 'order' => ['PaginatorPosts.id' => 'ASC']
<del> ]
<add> 'order' => ['PaginatorPosts.id' => 'ASC'],
<add> ],
<ide> ];
<ide> $table = $this->_getMockPosts(['find']);
<ide> $query = $this->_getMockFindQuery($table);
<ide> public function testPaginateQueryWithLimit()
<ide> 'maxLimit' => 10,
<ide> 'limit' => 5,
<ide> 'group' => 'PaginatorPosts.published',
<del> 'order' => ['PaginatorPosts.id' => 'ASC']
<del> ]
<add> 'order' => ['PaginatorPosts.id' => 'ASC'],
<add> ],
<ide> ];
<ide> $table = $this->_getMockPosts(['find']);
<ide> $query = $this->_getMockFindQuery($table);
<ide> protected function _getMockPosts($methods = [])
<ide> 'title' => ['type' => 'string', 'null' => false],
<ide> 'body' => 'text',
<ide> 'published' => ['type' => 'string', 'length' => 1, 'default' => 'N'],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<del> ]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<add> ],
<ide> ]])
<ide> ->getMock();
<ide> }
<ide> protected function getMockRepository()
<ide> $model = $this->getMockBuilder('Cake\Datasource\RepositoryInterface')
<ide> ->setMethods([
<ide> 'getAlias', 'hasField', 'alias', 'find', 'get', 'query', 'updateAll', 'deleteAll',
<del> 'exists', 'save', 'delete', 'newEntity', 'newEntities', 'patchEntity', 'patchEntities'
<add> 'exists', 'save', 'delete', 'newEntity', 'newEntities', 'patchEntity', 'patchEntities',
<ide> ])
<ide> ->getMock();
<ide>
<ide><path>tests/TestCase/Controller/Component/RequestHandlerComponentTest.php
<ide> public function tearDown()
<ide> public function testConstructorConfig()
<ide> {
<ide> $config = [
<del> 'viewClassMap' => ['json' => 'MyPlugin.MyJson']
<add> 'viewClassMap' => ['json' => 'MyPlugin.MyJson'],
<ide> ];
<ide> $controller = $this->getMockBuilder('Cake\Controller\Controller')
<ide> ->setMethods(['redirect'])
<ide> public function testViewClassMap()
<ide> $expected = [
<ide> 'json' => 'CustomJson',
<ide> 'xml' => 'Xml',
<del> 'ajax' => 'Ajax'
<add> 'ajax' => 'Ajax',
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> $this->RequestHandler->setConfig(['viewClassMap' => ['xls' => 'Excel.Excel']]);
<ide> public function testViewClassMap()
<ide> 'json' => 'CustomJson',
<ide> 'xml' => 'Xml',
<ide> 'ajax' => 'Ajax',
<del> 'xls' => 'Excel.Excel'
<add> 'xls' => 'Excel.Excel',
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> public function testViewClassMapMethod()
<ide> $expected = [
<ide> 'json' => 'CustomJson',
<ide> 'xml' => 'Xml',
<del> 'ajax' => 'Ajax'
<add> 'ajax' => 'Ajax',
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> public function testViewClassMapMethod()
<ide> 'json' => 'CustomJson',
<ide> 'xml' => 'Xml',
<ide> 'ajax' => 'Ajax',
<del> 'xls' => 'Excel.Excel'
<add> 'xls' => 'Excel.Excel',
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> public function testStartupProcessDataInvalid()
<ide> $this->Controller->request = new ServerRequest([
<ide> 'environment' => [
<ide> 'REQUEST_METHOD' => 'POST',
<del> 'CONTENT_TYPE' => 'application/json'
<del> ]
<add> 'CONTENT_TYPE' => 'application/json',
<add> ],
<ide> ]);
<ide>
<ide> $event = new Event('Controller.startup', $this->Controller);
<ide> public function testStartupProcessData()
<ide> $this->Controller->request = new ServerRequest([
<ide> 'environment' => [
<ide> 'REQUEST_METHOD' => 'POST',
<del> 'CONTENT_TYPE' => 'application/json'
<del> ]
<add> 'CONTENT_TYPE' => 'application/json',
<add> ],
<ide> ]);
<ide>
<ide> $stream = new Stream('php://memory', 'w');
<ide> public function testStartupIgnoreFileAsXml()
<ide> 'input' => '/dev/random',
<ide> 'environment' => [
<ide> 'REQUEST_METHOD' => 'POST',
<del> 'CONTENT_TYPE' => 'application/xml'
<del> ]
<add> 'CONTENT_TYPE' => 'application/xml',
<add> ],
<ide> ]);
<ide>
<ide> $event = new Event('Controller.startup', $this->Controller);
<ide> public function testStartupConvertXmlDataWrapper()
<ide> 'data' => [
<ide> 'article' => [
<ide> '@id' => 1,
<del> '@title' => 'first'
<del> ]
<del> ]
<add> '@title' => 'first',
<add> ],
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, $this->Controller->request->getData());
<ide> }
<ide> public function testStartupConvertXmlElements()
<ide> $expected = [
<ide> 'article' => [
<ide> 'id' => 1,
<del> 'title' => 'first'
<del> ]
<add> 'title' => 'first',
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, $this->Controller->request->getData());
<ide> }
<ide> public function testStartupCustomTypeProcess()
<ide> 'input' => '"A","csv","string"',
<ide> 'environment' => [
<ide> 'REQUEST_METHOD' => 'POST',
<del> 'CONTENT_TYPE' => 'text/csv'
<del> ]
<add> 'CONTENT_TYPE' => 'text/csv',
<add> ],
<ide> ]);
<ide> $this->RequestHandler->addInputType('csv', ['str_getcsv']);
<ide> $event = new Event('Controller.startup', $this->Controller);
<ide> $this->RequestHandler->startup($event);
<ide> $expected = [
<del> 'A', 'csv', 'string'
<add> 'A', 'csv', 'string',
<ide> ];
<ide> $this->assertEquals($expected, $this->Controller->request->getData());
<ide> });
<ide> public function testStartupSkipDataProcess()
<ide> $this->Controller->request = new ServerRequest([
<ide> 'environment' => [
<ide> 'REQUEST_METHOD' => 'POST',
<del> 'CONTENT_TYPE' => 'application/json'
<del> ]
<add> 'CONTENT_TYPE' => 'application/json',
<add> ],
<ide> ]);
<ide>
<ide> $event = new Event('Controller.startup', $this->Controller);
<ide> public function testAjaxRedirectAsRequestActionWithCookieData()
<ide> $this->Controller->request->expects($this->any())->method('is')->will($this->returnValue(true));
<ide>
<ide> $cookies = [
<del> 'foo' => 'bar'
<add> 'foo' => 'bar',
<ide> ];
<ide> $this->Controller->request->cookies = $cookies;
<ide>
<ide> public function testBeforeRedirectCallbackWithArrayUrl()
<ide>
<ide> Router::setRequestInfo([
<ide> ['plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => []],
<del> ['base' => '', 'here' => '/accounts/', 'webroot' => '/']
<add> ['base' => '', 'here' => '/accounts/', 'webroot' => '/'],
<ide> ]);
<ide>
<ide> $RequestHandler = new RequestHandlerComponent($this->Controller->components());
<ide> public function testConstructReplaceOptions()
<ide> $this->Controller->components(),
<ide> [
<ide> 'viewClassMap' => ['json' => 'Json'],
<del> 'inputTypeMap' => ['json' => ['json_decode', true]]
<add> 'inputTypeMap' => ['json' => ['json_decode', true]],
<ide> ]
<ide> );
<ide> $viewClass = $requestHandler->getConfig('viewClassMap');
<ide><path>tests/TestCase/Controller/Component/SecurityComponentTest.php
<ide> class SecurityTestController extends Controller
<ide> * @var array
<ide> */
<ide> public $components = [
<del> 'TestSecurity' => ['className' => 'Cake\Test\TestCase\Controller\Component\TestSecurityComponent']
<add> 'TestSecurity' => ['className' => 'Cake\Test\TestCase\Controller\Component\TestSecurityComponent'],
<ide> ];
<ide>
<ide> /**
<ide> public function setUp()
<ide> $request = new ServerRequest([
<ide> 'url' => '/articles/index',
<ide> 'session' => $session,
<del> 'params' => ['controller' => 'articles', 'action' => 'index']
<add> 'params' => ['controller' => 'articles', 'action' => 'index'],
<ide> ]);
<ide>
<ide> $this->Controller = new SecurityTestController($request);
<ide> public function testBlackholeWithBrokenCallback()
<ide> 'session' => $this->Security->session,
<ide> 'params' => [
<ide> 'controller' => 'posts',
<del> 'action' => 'index'
<del> ]
<add> 'action' => 'index',
<add> ],
<ide> ]);
<ide> $Controller = new \TestApp\Controller\SomePagesController($request);
<ide> $event = new Event('Controller.startup', $Controller);
<ide> public function testBlackholeReturnResponse()
<ide> 'method' => 'POST',
<ide> 'params' => [
<ide> 'controller' => 'posts',
<del> 'action' => 'index'
<add> 'action' => 'index',
<ide> ],
<ide> 'post' => [
<del> 'key' => 'value'
<del> ]
<add> 'key' => 'value',
<add> ],
<ide> ]);
<ide> $Controller = new \TestApp\Controller\SomePagesController($request);
<ide> $event = new Event('Controller.startup', $Controller);
<ide> public function testRequireAuthFail()
<ide> $this->assertTrue($this->Controller->failed);
<ide>
<ide> $this->Controller->request->getSession()->write('_Token', [
<del> 'allowedControllers' => ['SecurityTest'], 'allowedActions' => ['posted2']
<add> 'allowedControllers' => ['SecurityTest'], 'allowedActions' => ['posted2'],
<ide> ]);
<ide> $this->Security->requireAuth('posted');
<ide> $this->Security->startup($event);
<ide> public function testRequireAuthSucceed()
<ide>
<ide> $event = new Event('Controller.startup', $this->Controller);
<ide> $this->Controller->request->addParams([
<del> 'action' => 'posted'
<add> 'action' => 'posted',
<ide> ]);
<ide> $this->Security->requireAuth('posted');
<ide> $this->Security->startup($event);
<ide> public function testRequireAuthSucceed()
<ide> ]);
<ide> $this->Controller->request->addParams([
<ide> 'controller' => 'SecurityTest',
<del> 'action' => 'posted'
<add> 'action' => 'posted',
<ide> ]);
<ide>
<ide> $this->Controller->request->data = [
<ide> 'username' => 'willy',
<ide> 'password' => 'somePass',
<del> '_Token' => ''
<add> '_Token' => '',
<ide> ];
<ide> $this->Controller->action = 'posted';
<ide> $this->Controller->Security->requireAuth('posted');
<ide> public function testValidatePostOnGetWithData()
<ide> $debug = urlencode(json_encode([
<ide> 'some-action',
<ide> [],
<del> []
<add> [],
<ide> ]));
<ide>
<ide> $this->Controller->request = $this->Controller->request
<ide> public function testValidatePostNoSession()
<ide> $debug = urlencode(json_encode([
<ide> '/articles/index',
<ide> [],
<del> []
<add> [],
<ide> ]));
<ide>
<ide> $fields = 'a5475372b40f6e3ccbf9f8af191f20e1642fd877%3AModel.valid';
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 'Model' => ['username' => 'nate', 'password' => 'foo', 'valid' => '0'],
<del> '_Token' => compact('fields', 'unlocked', 'debug')
<add> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide> $this->assertFalse($this->validatePost('AuthSecurityException', 'Unexpected field \'Model.password\' in POST data, Unexpected field \'Model.username\' in POST data'));
<ide> }
<ide> public function testValidatePostNoUnlockedInRequestData()
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 'Model' => ['username' => 'nate', 'password' => 'foo', 'valid' => '0'],
<del> '_Token' => compact('fields')
<add> '_Token' => compact('fields'),
<ide> ]);
<ide> $this->assertFalse($this->validatePost('AuthSecurityException', '\'_Token.unlocked\' was not found in request data.'));
<ide> }
<ide> public function testValidatePostFormHacking()
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 'Model' => ['username' => 'nate', 'password' => 'foo', 'valid' => '0'],
<del> '_Token' => compact('unlocked')
<add> '_Token' => compact('unlocked'),
<ide> ]);
<ide> $result = $this->validatePost('AuthSecurityException', '\'_Token.fields\' was not found in request data.');
<ide> $this->assertFalse($result, 'validatePost passed when fields were missing. %s');
<ide> public function testValidatePostObjectDeserialize()
<ide> $debug = urlencode(json_encode([
<ide> '/articles/index',
<ide> ['Model.password', 'Model.username', 'Model.valid'],
<del> []
<add> [],
<ide> ]));
<ide>
<ide> // a corrupted serialized object, so we can see if it ever gets to deserialize
<ide> public function testValidatePostObjectDeserialize()
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 'Model' => ['username' => 'mark', 'password' => 'foo', 'valid' => '0'],
<del> '_Token' => compact('fields', 'unlocked', 'debug')
<add> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide> $result = $this->validatePost('SecurityException', 'Bad Request');
<ide> $this->assertFalse($result, 'validatePost passed when key was missing. %s');
<ide> public function testValidatePostIgnoresCsrfToken()
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> '_csrfToken' => 'abc123',
<ide> 'Model' => ['multi_field' => ['1', '3']],
<del> '_Token' => compact('fields', 'unlocked', 'debug')
<add> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide> $this->assertTrue($this->validatePost());
<ide> }
<ide> public function testValidatePostArray()
<ide> $debug = urlencode(json_encode([
<ide> 'some-action',
<ide> [],
<del> []
<add> [],
<ide> ]));
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 'Model' => ['multi_field' => ['1', '3']],
<del> '_Token' => compact('fields', 'unlocked', 'debug')
<add> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide> $this->assertTrue($this->validatePost());
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 'Model' => ['multi_field' => [12 => '1', 20 => '3']],
<del> '_Token' => compact('fields', 'unlocked', 'debug')
<add> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide> $this->assertTrue($this->validatePost());
<ide> }
<ide> public function testValidateIntFieldName()
<ide> $debug = urlencode(json_encode([
<ide> 'some-action',
<ide> [],
<del> []
<add> [],
<ide> ]));
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 1 => 'value,',
<del> '_Token' => compact('fields', 'unlocked', 'debug')
<add> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide> $this->assertTrue($this->validatePost());
<ide> }
<ide> public function testValidatePostNoModel()
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 'anything' => 'some_data',
<del> '_Token' => compact('fields', 'unlocked', 'debug')
<add> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide>
<ide> $result = $this->validatePost();
<ide> public function testValidatePostSimple()
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 'Model' => ['username' => '', 'password' => ''],
<del> '_Token' => compact('fields', 'unlocked', 'debug')
<add> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide>
<ide> $result = $this->validatePost();
<ide> public function testValidatePostSubdirectory()
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 'Model' => ['username' => '', 'password' => ''],
<del> '_Token' => compact('fields', 'unlocked', 'debug')
<add> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide>
<ide> $result = $this->validatePost();
<ide> public function testValidatePostComplex()
<ide> 'Addresses' => [
<ide> '0' => [
<ide> 'id' => '123456', 'title' => '', 'first_name' => '', 'last_name' => '',
<del> 'address' => '', 'city' => '', 'phone' => '', 'primary' => ''
<add> 'address' => '', 'city' => '', 'phone' => '', 'primary' => '',
<ide> ],
<ide> '1' => [
<ide> 'id' => '654321', 'title' => '', 'first_name' => '', 'last_name' => '',
<del> 'address' => '', 'city' => '', 'phone' => '', 'primary' => ''
<del> ]
<add> 'address' => '', 'city' => '', 'phone' => '', 'primary' => '',
<add> ],
<ide> ],
<del> '_Token' => compact('fields', 'unlocked', 'debug')
<add> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide> $result = $this->validatePost();
<ide> $this->assertTrue($result);
<ide> public function testValidatePostHidden()
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 'Model' => [
<ide> 'username' => '', 'password' => '', 'hidden' => '0',
<del> 'other_hidden' => 'some hidden value'
<add> 'other_hidden' => 'some hidden value',
<ide> ],
<ide> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide> public function testValidatePostWithDisabledFields()
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 'Model' => [
<del> 'username' => '', 'password' => '', 'hidden' => '0'
<add> 'username' => '', 'password' => '', 'hidden' => '0',
<ide> ],
<ide> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide> public function testValidatePostDisabledFieldsInData()
<ide> 'Model' => [
<ide> 'username' => 'mark',
<ide> 'password' => 'sekret',
<del> 'hidden' => '0'
<add> 'hidden' => '0',
<ide> ],
<ide> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide> public function testValidatePostFailNoDisabled()
<ide> 'Model' => [
<ide> 'username' => 'mark',
<ide> 'password' => 'sekret',
<del> 'hidden' => '0'
<add> 'hidden' => '0',
<ide> ],
<del> '_Token' => compact('fields')
<add> '_Token' => compact('fields'),
<ide> ]);
<ide>
<ide> $result = $this->validatePost('SecurityException', '\'_Token.unlocked\' was not found in request data.');
<ide> public function testValidatePostFailNoDebug()
<ide> 'Model' => [
<ide> 'username' => 'mark',
<ide> 'password' => 'sekret',
<del> 'hidden' => '0'
<add> 'hidden' => '0',
<ide> ],
<del> '_Token' => compact('fields', 'unlocked')
<add> '_Token' => compact('fields', 'unlocked'),
<ide> ]);
<ide>
<ide> $result = $this->validatePost('SecurityException', '\'_Token.debug\' was not found in request data.');
<ide> public function testValidatePostFailNoDebugMode()
<ide> 'Model' => [
<ide> 'username' => 'mark',
<ide> 'password' => 'sekret',
<del> 'hidden' => '0'
<add> 'hidden' => '0',
<ide> ],
<del> '_Token' => compact('fields', 'unlocked')
<add> '_Token' => compact('fields', 'unlocked'),
<ide> ]);
<ide> Configure::write('debug', false);
<ide> $result = $this->validatePost('SecurityException', 'The request has been black-holed');
<ide> public function testValidatePostFailDisabledFieldTampering()
<ide> $debug = urlencode(json_encode([
<ide> '/articles/index',
<ide> ['Model.hidden', 'Model.password'],
<del> ['Model.username']
<add> ['Model.username'],
<ide> ]));
<ide>
<ide> // Tamper the values.
<ide> public function testValidatePostFailDisabledFieldTampering()
<ide> 'Model' => [
<ide> 'username' => 'mark',
<ide> 'password' => 'sekret',
<del> 'hidden' => '0'
<add> 'hidden' => '0',
<ide> ],
<del> '_Token' => compact('fields', 'unlocked', 'debug')
<add> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide>
<ide> $result = $this->validatePost('SecurityException', 'Missing field \'Model.password\' in POST data, Unexpected unlocked field \'Model.password\' in POST data');
<ide> public function testValidateHasManyModel()
<ide> 'Model' => [
<ide> [
<ide> 'username' => 'username', 'password' => 'password',
<del> 'hidden' => 'value', 'valid' => '0'
<add> 'hidden' => 'value', 'valid' => '0',
<ide> ],
<ide> [
<ide> 'username' => 'username', 'password' => 'password',
<del> 'hidden' => 'value', 'valid' => '0'
<del> ]
<add> 'hidden' => 'value', 'valid' => '0',
<add> ],
<ide> ],
<ide> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide> public function testValidateHasManyRecordsPass()
<ide> 'address' => '50 Bag end way',
<ide> 'city' => 'the shire',
<ide> 'phone' => 'N/A',
<del> 'primary' => '1'
<del> ]
<add> 'primary' => '1',
<add> ],
<ide> ],
<ide> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide> public function testValidateNestedNumericSets()
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 'TaxonomyData' => [
<ide> 1 => [[2]],
<del> 2 => [[3]]
<add> 2 => [[3]],
<ide> ],
<ide> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide> public function testValidateHasManyRecordsFail()
<ide> 'Address.0.id' => '123',
<ide> 'Address.0.primary' => '5',
<ide> 'Address.1.id' => '124',
<del> 'Address.1.primary' => '1'
<add> 'Address.1.primary' => '1',
<ide> ],
<del> []
<add> [],
<ide> ]));
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> public function testValidateHasManyRecordsFail()
<ide> 'address' => '50 Bag end way',
<ide> 'city' => 'the shire',
<ide> 'phone' => 'N/A',
<del> 'primary' => '1'
<del> ]
<add> 'primary' => '1',
<add> ],
<ide> ],
<ide> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide> public function testFormDisabledFields()
<ide> $debug = urlencode(json_encode([
<ide> '/articles/index',
<ide> [],
<del> []
<add> [],
<ide> ]));
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> public function testValidatePostRadio()
<ide> $debug = urlencode(json_encode([
<ide> '/articles/index',
<ide> [],
<del> []
<add> [],
<ide> ]));
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> public function testValidatePostRadio()
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> '_Token' => compact('fields', 'unlocked', 'debug'),
<del> 'Test' => ['test' => '']
<add> 'Test' => ['test' => ''],
<ide> ]);
<ide> $result = $this->validatePost();
<ide> $this->assertTrue($result);
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> '_Token' => compact('fields', 'unlocked', 'debug'),
<del> 'Test' => ['test' => '1']
<add> 'Test' => ['test' => '1'],
<ide> ]);
<ide> $result = $this->validatePost();
<ide> $this->assertTrue($result);
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> '_Token' => compact('fields', 'unlocked', 'debug'),
<del> 'Test' => ['test' => '2']
<add> 'Test' => ['test' => '2'],
<ide> ]);
<ide> $result = $this->validatePost();
<ide> $this->assertTrue($result);
<ide> public function testValidatePostUrlAsHashInput()
<ide> $debug = urlencode(json_encode([
<ide> 'another-url',
<ide> ['Model.username', 'Model.password'],
<del> []
<add> [],
<ide> ]));
<ide>
<ide> $this->Controller->request = $this->Controller->request
<ide> public function testValidatePostDebugFormat()
<ide> '/articles/index',
<ide> ['Model.hidden', 'Model.password'],
<ide> ['Model.username'],
<del> ['not expected']
<add> ['not expected'],
<ide> ]));
<ide>
<ide> $this->Controller->request = $this->Controller->request->withParsedBody([
<ide> 'Model' => [
<ide> 'username' => 'mark',
<ide> 'password' => 'sekret',
<del> 'hidden' => '0'
<add> 'hidden' => '0',
<ide> ],
<del> '_Token' => compact('fields', 'unlocked', 'debug')
<add> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide>
<ide> $result = $this->validatePost('SecurityException', 'Invalid security debug token.');
<ide> public function testValidatePostFailTampering()
<ide> $debug = urlencode(json_encode([
<ide> '/articles/index',
<ide> $fields,
<del> []
<add> [],
<ide> ]));
<ide> $fields = urlencode(Security::hash(serialize($fields) . $unlocked . Security::getSalt()));
<ide> $fields .= urlencode(':Model.hidden|Model.id');
<ide> public function testValidatePostFailTampering()
<ide> 'hidden' => 'tampered',
<ide> 'id' => '1',
<ide> ],
<del> '_Token' => compact('fields', 'unlocked', 'debug')
<add> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide>
<ide> $result = $this->validatePost('SecurityException', 'Tampered field \'Model.hidden\' in POST data (expected value \'value\' but found \'tampered\')');
<ide> public function testValidatePostFailTamperingMutatedIntoArray()
<ide> $debug = urlencode(json_encode([
<ide> '/articles/index',
<ide> $fields,
<del> []
<add> [],
<ide> ]));
<ide> $fields = urlencode(Security::hash(serialize($fields) . $unlocked . Security::getSalt()));
<ide> $fields .= urlencode(':Model.hidden|Model.id');
<ide> public function testValidatePostUnexpectedDebugToken()
<ide> $debug = urlencode(json_encode([
<ide> '/articles/index',
<ide> $fields,
<del> []
<add> [],
<ide> ]));
<ide> $fields = urlencode(Security::hash(serialize($fields) . $unlocked . Security::getSalt()));
<ide> $fields .= urlencode(':Model.hidden|Model.id');
<ide> public function testValidatePostUnexpectedDebugToken()
<ide> 'hidden' => ['some-key' => 'some-value'],
<ide> 'id' => '1',
<ide> ],
<del> '_Token' => compact('fields', 'unlocked', 'debug')
<add> '_Token' => compact('fields', 'unlocked', 'debug'),
<ide> ]);
<ide> Configure::write('debug', false);
<ide> $result = $this->validatePost('SecurityException', 'Unexpected \'_Token.debug\' found in request data');
<ide> public function testAuthRequiredThrowsExceptionControllerNotAllowed()
<ide> $this->Controller->request->params['action'] = 'protected';
<ide> $this->Controller->request->data = ['_Token' => 'not empty'];
<ide> $this->Controller->request->session()->write('_Token', [
<del> 'allowedControllers' => ['Allowed', 'AnotherAllowed']
<add> 'allowedControllers' => ['Allowed', 'AnotherAllowed'],
<ide> ]);
<ide> $this->Security->authRequired($this->Controller);
<ide> });
<ide> public function testAuthRequiredThrowsExceptionActionNotAllowed()
<ide> $this->Controller->request->params['action'] = 'protected';
<ide> $this->Controller->request->data = ['_Token' => 'not empty'];
<ide> $this->Controller->request->session()->write('_Token', [
<del> 'allowedActions' => ['index', 'view']
<add> 'allowedActions' => ['index', 'view'],
<ide> ]);
<ide> $this->Security->authRequired($this->Controller);
<ide> });
<ide><path>tests/TestCase/Controller/ComponentTest.php
<ide> public function testDebugInfo()
<ide>
<ide> $expected = [
<ide> 'components' => [
<del> 'Orange'
<add> 'Orange',
<ide> ],
<ide> 'implementedEvents' => [
<del> 'Controller.startup' => 'startup'
<add> 'Controller.startup' => 'startup',
<ide> ],
<del> '_config' => []
<add> '_config' => [],
<ide> ];
<ide> $result = $Component->__debugInfo();
<ide> $this->assertEquals($expected, $result);
<ide><path>tests/TestCase/Controller/ControllerTest.php
<ide> public function index($testId, $testTwoId)
<ide> {
<ide> $this->request = $this->request->withParsedBody([
<ide> 'testId' => $testId,
<del> 'test2Id' => $testTwoId
<add> 'test2Id' => $testTwoId,
<ide> ]);
<ide> }
<ide>
<ide> public function view($testId, $testTwoId)
<ide> {
<ide> $this->request = $this->request->withParsedBody([
<ide> 'testId' => $testId,
<del> 'test2Id' => $testTwoId
<add> 'test2Id' => $testTwoId,
<ide> ]);
<ide> }
<ide>
<ide> class ControllerTest extends TestCase
<ide> */
<ide> public $fixtures = [
<ide> 'core.Comments',
<del> 'core.Posts'
<add> 'core.Posts',
<ide> ];
<ide>
<ide> /**
<ide> public function testRender()
<ide> $request = new ServerRequest([
<ide> 'url' => 'controller_posts/index',
<ide> 'params' => [
<del> 'action' => 'header'
<del> ]
<add> 'action' => 'header',
<add> ],
<ide> ]);
<ide>
<ide> $Controller = new Controller($request, new Response());
<ide> public function testRenderViewChangesResponse()
<ide> $request = new ServerRequest([
<ide> 'url' => 'controller_posts/index',
<ide> 'params' => [
<del> 'action' => 'header'
<del> ]
<add> 'action' => 'header',
<add> ],
<ide> ]);
<ide>
<ide> $controller = new Controller($request, new Response());
<ide> public function testBeforeRenderCallbackChangingViewClass()
<ide>
<ide> $Controller->set([
<ide> 'test' => 'value',
<del> '_serialize' => ['test']
<add> '_serialize' => ['test'],
<ide> ]);
<ide> $debug = Configure::read('debug');
<ide> Configure::write('debug', false);
<ide> public function testPaginate()
<ide> 'posts' => [
<ide> 'page' => 2,
<ide> 'limit' => 2,
<del> ]
<add> ],
<ide> ]);
<ide>
<ide> $this->assertEquals([], $Controller->paginate);
<ide> public function testInvokeActionMissingAction()
<ide> $this->expectExceptionMessage('Action TestController::missing() could not be found, or is not accessible.');
<ide> $url = new ServerRequest([
<ide> 'url' => 'test/missing',
<del> 'params' => ['controller' => 'Test', 'action' => 'missing']
<add> 'params' => ['controller' => 'Test', 'action' => 'missing'],
<ide> ]);
<ide> $response = $this->getMockBuilder('Cake\Http\Response')->getMock();
<ide>
<ide> public function testInvokeActionPrivate()
<ide> $this->expectExceptionMessage('Action TestController::private_m() could not be found, or is not accessible.');
<ide> $url = new ServerRequest([
<ide> 'url' => 'test/private_m/',
<del> 'params' => ['controller' => 'Test', 'action' => 'private_m']
<add> 'params' => ['controller' => 'Test', 'action' => 'private_m'],
<ide> ]);
<ide> $response = $this->getMockBuilder('Cake\Http\Response')->getMock();
<ide>
<ide> public function testInvokeActionProtected()
<ide> $this->expectExceptionMessage('Action TestController::protected_m() could not be found, or is not accessible.');
<ide> $url = new ServerRequest([
<ide> 'url' => 'test/protected_m/',
<del> 'params' => ['controller' => 'Test', 'action' => 'protected_m']
<add> 'params' => ['controller' => 'Test', 'action' => 'protected_m'],
<ide> ]);
<ide> $response = $this->getMockBuilder('Cake\Http\Response')->getMock();
<ide>
<ide> public function testInvokeActionBaseMethods()
<ide> $this->expectExceptionMessage('Action TestController::redirect() could not be found, or is not accessible.');
<ide> $url = new ServerRequest([
<ide> 'url' => 'test/redirect/',
<del> 'params' => ['controller' => 'Test', 'action' => 'redirect']
<add> 'params' => ['controller' => 'Test', 'action' => 'redirect'],
<ide> ]);
<ide> $response = $this->getMockBuilder('Cake\Http\Response')->getMock();
<ide>
<ide> public function testInvokeActionReturnValue()
<ide> 'params' => [
<ide> 'controller' => 'Test',
<ide> 'action' => 'returner',
<del> 'pass' => []
<del> ]
<add> 'pass' => [],
<add> ],
<ide> ]);
<ide> $response = new Response();
<ide>
<ide> public function testInvokeActionWithPassedParams()
<ide> 'params' => [
<ide> 'controller' => 'Test',
<ide> 'action' => 'index',
<del> 'pass' => ['param1' => '1', 'param2' => '2']
<del> ]
<add> 'pass' => ['param1' => '1', 'param2' => '2'],
<add> ],
<ide> ]);
<ide> $response = $this->getMockBuilder('Cake\Http\Response')->getMock();
<ide>
<ide> public function testViewPathConventions()
<ide> {
<ide> $request = new ServerRequest([
<ide> 'url' => 'admin/posts',
<del> 'params' => ['prefix' => 'admin']
<add> 'params' => ['prefix' => 'admin'],
<ide> ]);
<ide> $response = $this->getMockBuilder('Cake\Http\Response')->getMock();
<ide> $Controller = new \TestApp\Controller\Admin\PostsController($request, $response);
<ide> public function testViewPathConventions()
<ide> $request = new ServerRequest([
<ide> 'url' => 'pages/home',
<ide> 'params' => [
<del> 'prefix' => false
<del> ]
<add> 'prefix' => false,
<add> ],
<ide> ]);
<ide> $Controller = new \TestApp\Controller\PagesController($request, $response);
<ide> $Controller->getEventManager()->on('Controller.beforeRender', function (Event $e) {
<ide> public function testRequest()
<ide> 'plugin' => 'Posts',
<ide> 'pass' => [
<ide> 'foo',
<del> 'bar'
<del> ]
<del> ]
<add> 'bar',
<add> ],
<add> ],
<ide> ]);
<ide> $this->assertSame($controller, $controller->setRequest($request));
<ide> $this->assertSame($request, $controller->getRequest());
<ide><path>tests/TestCase/Core/BasePluginTest.php
<ide> public function testConfigForRoutesAndBootstrap()
<ide> {
<ide> $plugin = new BasePlugin([
<ide> 'bootstrap' => false,
<del> 'routes' => false
<add> 'routes' => false,
<ide> ]);
<ide>
<ide> $this->assertFalse($plugin->isEnabled('routes'));
<ide> public function testConstructorArguments()
<ide> 'routes' => false,
<ide> 'bootstrap' => false,
<ide> 'console' => false,
<del> 'middleware' => false
<add> 'middleware' => false,
<ide> ]);
<ide> $this->assertFalse($plugin->isEnabled('routes'));
<ide> $this->assertFalse($plugin->isEnabled('bootstrap'));
<ide><path>tests/TestCase/Core/Configure/Engine/IniConfigTest.php
<ide> class IniConfigTest extends TestCase
<ide> 'One' => [
<ide> 'two' => 'value',
<ide> 'three' => [
<del> 'four' => 'value four'
<add> 'four' => 'value four',
<ide> ],
<ide> 'is_null' => null,
<ide> 'bool_false' => false,
<ide> 'bool_true' => true,
<ide> ],
<ide> 'Asset' => [
<del> 'timestamp' => 'force'
<add> 'timestamp' => 'force',
<ide> ],
<ide> ];
<ide>
<ide> public function testReadWithoutSection()
<ide>
<ide> $expected = [
<ide> 'some_key' => 'some_value',
<del> 'bool_key' => true
<add> 'bool_key' => true,
<ide> ];
<ide> $this->assertEquals($expected, $config);
<ide> }
<ide><path>tests/TestCase/Core/Configure/Engine/JsonConfigTest.php
<ide> class JsonConfigTest extends TestCase
<ide> 'One' => [
<ide> 'two' => 'value',
<ide> 'three' => [
<del> 'four' => 'value four'
<add> 'four' => 'value four',
<ide> ],
<ide> 'is_null' => null,
<ide> 'bool_false' => false,
<ide> 'bool_true' => true,
<ide> ],
<ide> 'Asset' => [
<del> 'timestamp' => 'force'
<add> 'timestamp' => 'force',
<ide> ],
<ide> ];
<ide>
<ide><path>tests/TestCase/Core/Configure/Engine/PhpConfigTest.php
<ide> class PhpConfigTest extends TestCase
<ide> 'One' => [
<ide> 'two' => 'value',
<ide> 'three' => [
<del> 'four' => 'value four'
<add> 'four' => 'value four',
<ide> ],
<ide> 'is_null' => null,
<ide> 'bool_false' => false,
<ide> 'bool_true' => true,
<ide> ],
<ide> 'Asset' => [
<del> 'timestamp' => 'force'
<add> 'timestamp' => 'force',
<ide> ],
<ide> ];
<ide>
<ide><path>tests/TestCase/Core/ConfigureTest.php
<ide> public function testStoreAndRestore()
<ide> Cache::enable();
<ide> Cache::setConfig('configure', [
<ide> 'className' => 'File',
<del> 'path' => TMP . 'tests'
<add> 'path' => TMP . 'tests',
<ide> ]);
<ide>
<ide> Configure::write('Testing', 'yummy');
<ide> public function testStoreAndRestoreWithData()
<ide> Cache::enable();
<ide> Cache::setConfig('configure', [
<ide> 'className' => 'File',
<del> 'path' => TMP . 'tests'
<add> 'path' => TMP . 'tests',
<ide> ]);
<ide>
<ide> Configure::write('testing', 'value');
<ide><path>tests/TestCase/Core/InstanceConfigTraitTest.php
<ide> class TestInstanceConfig
<ide> 'some' => 'string',
<ide> 'a' => [
<ide> 'nested' => 'value',
<del> 'other' => 'value'
<del> ]
<add> 'other' => 'value',
<add> ],
<ide> ];
<ide> }
<ide>
<ide> class ReadOnlyTestInstanceConfig
<ide> 'some' => 'string',
<ide> 'a' => [
<ide> 'nested' => 'value',
<del> 'other' => 'value'
<del> ]
<add> 'other' => 'value',
<add> ],
<ide> ];
<ide>
<ide> /**
<ide> public function testDefaultsAreSet()
<ide> 'some' => 'string',
<ide> 'a' => [
<ide> 'nested' => 'value',
<del> 'other' => 'value'
<del> ]
<add> 'other' => 'value',
<add> ],
<ide> ],
<ide> $this->object->getConfig(),
<ide> 'runtime config should match the defaults if not overridden'
<ide> public function testSetNested()
<ide> [
<ide> 'some' => 'string',
<ide> 'a' => ['nested' => 'zum', 'other' => 'value'],
<del> 'new' => ['foo' => 'bar']
<add> 'new' => ['foo' => 'bar'],
<ide> ],
<ide> $this->object->getConfig(),
<ide> 'updates should be merged with existing config'
<ide> public function testSetArray()
<ide> 'some' => 'string',
<ide> 'a' => ['nested' => 'value', 'other' => 'value'],
<ide> 'foo' => 'bar',
<del> 'new' => ['foo' => 'bar']
<add> 'new' => ['foo' => 'bar'],
<ide> ],
<ide> $this->object->getConfig(),
<ide> 'updates should be merged with existing config'
<ide> public function testSetArray()
<ide> 'a' => ['nested' => 'value', 'other' => 'value', 'values' => ['to' => 'set']],
<ide> 'foo' => 'bar',
<ide> 'new' => ['foo' => 'bar'],
<del> 'multiple' => 'different'
<add> 'multiple' => 'different',
<ide> ],
<ide> $this->object->getConfig(),
<ide> 'updates should be merged with existing config'
<ide> public function testConfigShallow()
<ide> [
<ide> 'some' => 'string',
<ide> 'a' => ['new_nested' => true],
<del> 'new' => 'bar'
<add> 'new' => 'bar',
<ide> ],
<ide> $this->object->getConfig(),
<ide> 'When merging a scalar property will be overwritten with an array'
<ide> public function testMerge()
<ide> 'a' => [
<ide> 'nested' => 'value',
<ide> 'other' => 'value',
<del> 'nother' => 'value'
<del> ]
<add> 'nother' => 'value',
<add> ],
<ide> ],
<ide> $this->object->getConfig(),
<ide> 'Merging should not delete untouched array values'
<ide> public function testMergeDotKey()
<ide> 'a' => [
<ide> 'nested' => 'value',
<ide> 'other' => 'value',
<del> 'nother' => 'value'
<del> ]
<add> 'nother' => 'value',
<add> ],
<ide> ],
<ide> $this->object->getConfig(),
<ide> 'Should act the same as having passed the equivalent array to the config function'
<ide> public function testMergeDotKey()
<ide> 'nested' => 'value',
<ide> 'other' => 'value',
<ide> 'nother' => 'value',
<del> 'nextra' => 'value'
<del> ]
<add> 'nextra' => 'value',
<add> ],
<ide> ],
<ide> $this->object->getConfig(),
<ide> 'Merging should not delete untouched array values'
<ide> public function testSetDefaultsMerge()
<ide> 'a' => [
<ide> 'nested' => 'value',
<ide> 'other' => 'value',
<del> 'nother' => 'value'
<del> ]
<add> 'nother' => 'value',
<add> ],
<ide> ],
<ide> $this->object->getConfig(),
<ide> 'First access should act like any subsequent access'
<ide> public function testSetDefaultsNoMerge()
<ide> [
<ide> 'some' => 'string',
<ide> 'a' => [
<del> 'nother' => 'value'
<del> ]
<add> 'nother' => 'value',
<add> ],
<ide> ],
<ide> $this->object->getConfig(),
<ide> 'If explicitly no-merge, array values should be overwritten'
<ide> public function testSetMergeNoClobber()
<ide> 'some' => 'string',
<ide> 'a' => [
<ide> 'nested' => [
<del> 'value' => 'it is possible'
<add> 'value' => 'it is possible',
<ide> ],
<del> 'other' => 'value'
<del> ]
<add> 'other' => 'value',
<add> ],
<ide> ],
<ide> $this->object->getConfig(),
<ide> 'When merging a scalar property will be overwritten with an array'
<ide> public function testReadOnlyConfig()
<ide> $this->assertSame(
<ide> [
<ide> 'some' => 'string',
<del> 'a' => ['nested' => 'value', 'other' => 'value']
<add> 'a' => ['nested' => 'value', 'other' => 'value'],
<ide> ],
<ide> $object->getConfig(),
<ide> 'default config should be returned'
<ide> public function testDeleteNested()
<ide> [
<ide> 'some' => 'string',
<ide> 'a' => [
<del> 'other' => 'value'
<del> ]
<add> 'other' => 'value',
<add> ],
<ide> ],
<ide> $this->object->getConfig(),
<ide> 'deleted keys should not be present'
<ide> public function testDeleteNested()
<ide> $this->assertSame(
<ide> [
<ide> 'some' => 'string',
<del> 'a' => []
<add> 'a' => [],
<ide> ],
<ide> $this->object->getConfig(),
<ide> 'deleted keys should not be present'
<ide> public function testDeleteArray()
<ide> );
<ide> $this->assertSame(
<ide> [
<del> 'some' => 'string'
<add> 'some' => 'string',
<ide> ],
<ide> $this->object->getConfig(),
<ide> 'deleted keys should not be present'
<ide><path>tests/TestCase/Core/PluginCollectionTest.php
<ide> public function testIterator()
<ide> {
<ide> $data = [
<ide> new TestPlugin(),
<del> new TestPluginThree()
<add> new TestPluginThree(),
<ide> ];
<ide> $plugins = new PluginCollection($data);
<ide> $out = [];
<ide><path>tests/TestCase/Core/PluginTest.php
<ide> public function testLoadWithAutoloadAndBootstrap()
<ide> 'Company/TestPluginFive',
<ide> [
<ide> 'autoload' => true,
<del> 'bootstrap' => true
<add> 'bootstrap' => true,
<ide> ]
<ide> );
<ide> $this->assertTrue(Configure::read('PluginTest.test_plugin_five.autoload'));
<ide> public function testIgnoreMissingFiles()
<ide> Plugin::loadAll([[
<ide> 'bootstrap' => true,
<ide> 'routes' => true,
<del> 'ignoreMissing' => true
<add> 'ignoreMissing' => true,
<ide> ]]);
<ide> $this->assertTrue(Plugin::routes());
<ide> });
<ide> public function testLoadAll()
<ide> Plugin::loadAll();
<ide> $expected = [
<ide> 'Company', 'ParentPlugin', 'PluginJs', 'TestPlugin',
<del> 'TestPluginFour', 'TestPluginTwo', 'TestTheme'
<add> 'TestPluginFour', 'TestPluginTwo', 'TestTheme',
<ide> ];
<ide> $this->assertEquals($expected, Plugin::loaded());
<ide> });
<ide> public function testLoadAllWithDefaults()
<ide> Plugin::loadAll([$defaults]);
<ide> $expected = [
<ide> 'Company', 'ParentPlugin', 'PluginJs', 'TestPlugin',
<del> 'TestPluginFour', 'TestPluginTwo', 'TestTheme'
<add> 'TestPluginFour', 'TestPluginTwo', 'TestTheme',
<ide> ];
<ide> $this->assertEquals($expected, Plugin::loaded());
<ide> $this->assertEquals('loaded js plugin bootstrap', Configure::read('PluginTest.js_plugin.bootstrap'));
<ide> public function testLoadAllWithDefaultsAndOverride()
<ide> Plugin::loadAll([
<ide> ['bootstrap' => true, 'ignoreMissing' => true],
<ide> 'TestPlugin' => ['routes' => true],
<del> 'TestPluginFour' => ['bootstrap' => true, 'classBase' => '']
<add> 'TestPluginFour' => ['bootstrap' => true, 'classBase' => ''],
<ide> ]);
<ide> Plugin::routes();
<ide>
<ide> $expected = [
<ide> 'Company', 'ParentPlugin', 'PluginJs', 'TestPlugin',
<del> 'TestPluginFour', 'TestPluginTwo', 'TestTheme'
<add> 'TestPluginFour', 'TestPluginTwo', 'TestTheme',
<ide> ];
<ide> $this->assertEquals($expected, Plugin::loaded());
<ide> $this->assertEquals('loaded js plugin bootstrap', Configure::read('PluginTest.js_plugin.bootstrap'));
<ide><path>tests/TestCase/Core/StaticConfigTraitTest.php
<ide> public function testCanUpdateClassMap()
<ide> 'console' => 'Special\EngineLog',
<ide> 'file' => 'Cake\Log\Engine\FileLog',
<ide> 'syslog' => 'Cake\Log\Engine\SyslogLog',
<del> 'my' => 'Special\OtherLog'
<add> 'my' => 'Special\OtherLog',
<ide> ];
<ide> $result = TestLogStaticConfig::dsnClassMap(['my' => 'Special\OtherLog']);
<ide> $this->assertEquals($expected, $result, 'Should be possible to add to the map');
<ide><path>tests/TestCase/Database/Driver/MysqlTest.php
<ide> public function testConnectionConfigCustom()
<ide> 'init' => [
<ide> 'Execute this',
<ide> 'this too',
<del> ]
<add> ],
<ide> ];
<ide> $driver = $this->getMockBuilder('Cake\Database\Driver\Mysql')
<ide> ->setMethods(['_connect', 'getConnection'])
<ide><path>tests/TestCase/Database/Driver/PostgresTest.php
<ide> public function testConnectionConfigDefault()
<ide> $expected['flags'] += [
<ide> PDO::ATTR_PERSISTENT => true,
<ide> PDO::ATTR_EMULATE_PREPARES => false,
<del> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
<add> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
<ide> ];
<ide>
<ide> $connection = $this->getMockBuilder('stdClass')
<ide> public function testConnectionConfigCustom()
<ide> 'encoding' => 'a-language',
<ide> 'timezone' => 'Antarctica',
<ide> 'schema' => 'fooblic',
<del> 'init' => ['Execute this', 'this too']
<add> 'init' => ['Execute this', 'this too'],
<ide> ];
<ide> $driver = $this->getMockBuilder('Cake\Database\Driver\Postgres')
<ide> ->setMethods(['_connect', 'getConnection', 'setConnection'])
<ide> public function testConnectionConfigCustom()
<ide> $expected['flags'] += [
<ide> PDO::ATTR_PERSISTENT => false,
<ide> PDO::ATTR_EMULATE_PREPARES => false,
<del> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
<add> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
<ide> ];
<ide>
<ide> $connection = $this->getMockBuilder('stdClass')
<ide><path>tests/TestCase/Database/Driver/SqliteTest.php
<ide> public function testConnectionConfigDefault()
<ide> $expected['flags'] += [
<ide> PDO::ATTR_PERSISTENT => false,
<ide> PDO::ATTR_EMULATE_PREPARES => false,
<del> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
<add> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
<ide> ];
<ide> $driver->expects($this->once())->method('_connect')
<ide> ->with($dsn, $expected);
<ide> public function testConnectionConfigCustom()
<ide> 'flags' => [1 => true, 2 => false],
<ide> 'encoding' => 'a-language',
<ide> 'init' => ['Execute this', 'this too'],
<del> 'mask' => 0666
<add> 'mask' => 0666,
<ide> ];
<ide> $driver = $this->getMockBuilder('Cake\Database\driver\Sqlite')
<ide> ->setMethods(['_connect', 'getConnection'])
<ide> public function testConnectionConfigCustom()
<ide> $expected['flags'] += [
<ide> PDO::ATTR_PERSISTENT => true,
<ide> PDO::ATTR_EMULATE_PREPARES => false,
<del> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
<add> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
<ide> ];
<ide>
<ide> $connection = $this->getMockBuilder('StdClass')
<ide><path>tests/TestCase/Database/Driver/SqlserverTest.php
<ide> public function testConnectionConfigCustom()
<ide> $expected['flags'] += [
<ide> PDO::ATTR_EMULATE_PREPARES => false,
<ide> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
<del> PDO::SQLSRV_ATTR_ENCODING => 'a-language'
<add> PDO::SQLSRV_ATTR_ENCODING => 'a-language',
<ide> ];
<ide> $expected['attributes'] = [];
<ide> $expected['app'] = null;
<ide> public function testConnectionPersistentFalse()
<ide> $expected['flags'] = [
<ide> PDO::ATTR_EMULATE_PREPARES => false,
<ide> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
<del> PDO::SQLSRV_ATTR_ENCODING => 'a-language'
<add> PDO::SQLSRV_ATTR_ENCODING => 'a-language',
<ide> ];
<ide> $expected['attributes'] = [];
<ide> $expected['settings'] = [];
<ide><path>tests/TestCase/Database/DriverTest.php
<ide> public function schemaValueProvider()
<ide> [true, 'TRUE'],
<ide> [1, '1'],
<ide> ['0', '0'],
<del> ['42', '42']
<add> ['42', '42'],
<ide> ];
<ide> }
<ide> }
<ide><path>tests/TestCase/Database/Expression/QueryExpressionTest.php
<ide> public function testSqlGenerationMultipleClauses()
<ide> ],
<ide> [
<ide> 'Users.username' => 'string',
<del> 'Users.active' => 'boolean'
<add> 'Users.active' => 'boolean',
<ide> ]
<ide> );
<ide>
<ide> public function methodsProvider()
<ide> {
<ide> return [
<ide> ['eq'], ['notEq'], ['gt'], ['lt'], ['gte'], ['lte'], ['like'],
<del> ['notLike'], ['in'], ['notIn']
<add> ['notLike'], ['in'], ['notIn'],
<ide> ];
<ide> }
<ide>
<ide><path>tests/TestCase/Database/QueryTest.php
<ide> class QueryTest extends TestCase
<ide> 'core.Authors',
<ide> 'core.Comments',
<ide> 'core.Profiles',
<del> 'core.MenuLinkTrees'
<add> 'core.MenuLinkTrees',
<ide> ];
<ide>
<ide> public $autoFixtures = false;
<ide> public function testSelectWithJoins()
<ide> $result->closeCursor();
<ide>
<ide> $result = $query->join([
<del> ['table' => 'authors', 'type' => 'INNER', 'conditions' => $query->newExpr()->equalFields('author_id', 'authors.id')]
<add> ['table' => 'authors', 'type' => 'INNER', 'conditions' => $query->newExpr()->equalFields('author_id', 'authors.id')],
<ide> ], [], true)->execute();
<ide> $this->assertCount(3, $result);
<ide> $this->assertEquals(['title' => 'First Article', 'name' => 'mariano'], $result->fetch('assoc'));
<ide> public function testSelectWhereUnary()
<ide> ->from('articles')
<ide> ->where([
<ide> 'title is not' => null,
<del> 'user_id is' => null
<add> 'user_id is' => null,
<ide> ])
<ide> ->sql();
<ide> $this->assertQuotedQuery(
<ide> public function testSelectWhereTypes()
<ide> ->where(
<ide> [
<ide> 'created >' => new \DateTime('2007-03-18 10:40:00'),
<del> 'created <' => new \DateTime('2007-03-18 10:46:00')
<add> 'created <' => new \DateTime('2007-03-18 10:46:00'),
<ide> ],
<ide> ['created' => 'datetime']
<ide> )
<ide> public function testSelectWhereTypes()
<ide> ->where(
<ide> [
<ide> 'id' => '3',
<del> 'created <' => new \DateTime('2013-01-01 12:00')
<add> 'created <' => new \DateTime('2013-01-01 12:00'),
<ide> ],
<ide> ['created' => 'datetime', 'id' => 'integer']
<ide> )
<ide> public function testSelectWhereTypes()
<ide> ->where(
<ide> [
<ide> 'id' => '1',
<del> 'created <' => new \DateTime('2013-01-01 12:00')
<add> 'created <' => new \DateTime('2013-01-01 12:00'),
<ide> ],
<ide> ['created' => 'datetime', 'id' => 'integer']
<ide> )
<ide> public function testTupleWithClosureExpression()
<ide> 'id' => 1,
<ide> function ($exp) {
<ide> return $exp->eq('id', 2);
<del> }
<del> ]
<add> },
<add> ],
<ide> ]);
<ide>
<ide> $result = $query->sql();
<ide> public function testWhereCallables()
<ide> 'title' => ['\Cake\Error\Debugger', 'dump'],
<ide> 'author_id' => function ($exp) {
<ide> return 1;
<del> }
<add> },
<ide> ]);
<ide> $this->assertQuotedQuery(
<ide> 'SELECT <id> FROM <articles> WHERE \(<id> = :c0 AND <title> = :c1 AND <author_id> = :c2\)',
<ide> public function testSelectWhereNot2()
<ide> ->select(['id'])
<ide> ->from('articles')
<ide> ->where([
<del> 'not' => ['or' => ['id' => 1, 'id >' => 2], 'id' => 3]
<add> 'not' => ['or' => ['id' => 1, 'id >' => 2], 'id' => 3],
<ide> ])
<ide> ->execute();
<ide> $this->assertCount(2, $result);
<ide> public function testSelectPageWithOrder()
<ide> $result = $query
<ide> ->select([
<ide> 'id',
<del> 'ids_added' => $query->newExpr()->add('(user_id + article_id)')
<add> 'ids_added' => $query->newExpr()->add('(user_id + article_id)'),
<ide> ])
<ide> ->from('comments')
<ide> ->order(['ids_added' => 'asc'])
<ide> public function testSelectPageWithOrder()
<ide> $this->assertEquals(
<ide> [
<ide> ['id' => '6', 'ids_added' => '4'],
<del> ['id' => '2', 'ids_added' => '5']
<add> ['id' => '2', 'ids_added' => '5'],
<ide> ],
<ide> $result->fetchAll('assoc')
<ide> );
<ide> public function testDeleteStripAliasesFromConditions()
<ide> 'OR' => [
<ide> $query->newExpr()->eq(new IdentifierExpression('c.name'), 'zap'),
<ide> 'd.name' => 'baz',
<del> (new Query($this->connection))->select(['e.name'])->where(['e.name' => 'oof'])
<del> ]
<del> ]
<add> (new Query($this->connection))->select(['e.name'])->where(['e.name' => 'oof']),
<add> ],
<add> ],
<ide> ],
<ide> ]);
<ide>
<ide> public function testUpdateMultipleFieldsArray()
<ide> $query->update('articles')
<ide> ->set([
<ide> 'title' => 'mark',
<del> 'body' => 'some text'
<add> 'body' => 'some text',
<ide> ], ['title' => 'string', 'body' => 'string'])
<ide> ->where(['id' => 1]);
<ide> $result = $query->sql();
<ide> public function testUpdateStripAliasesFromConditions()
<ide> 'OR' => [
<ide> $query->newExpr()->eq(new IdentifierExpression('c.name'), 'zap'),
<ide> 'd.name' => 'baz',
<del> (new Query($this->connection))->select(['e.name'])->where(['e.name' => 'oof'])
<del> ]
<del> ]
<add> (new Query($this->connection))->select(['e.name'])->where(['e.name' => 'oof']),
<add> ],
<add> ],
<ide> ],
<ide> ]);
<ide>
<ide> public function testInsertValuesBeforeInsertFailure()
<ide> $query->select('*')->values([
<ide> 'id' => 1,
<ide> 'title' => 'mark',
<del> 'body' => 'test insert'
<add> 'body' => 'test insert',
<ide> ]);
<ide> }
<ide>
<ide> public function testInsertSimple()
<ide> ->into('articles')
<ide> ->values([
<ide> 'title' => 'mark',
<del> 'body' => 'test insert'
<add> 'body' => 'test insert',
<ide> ]);
<ide> $result = $query->sql();
<ide> $this->assertQuotedQuery(
<ide> public function testInsertSimple()
<ide> 'title' => 'mark',
<ide> 'body' => 'test insert',
<ide> 'published' => 'N',
<del> ]
<add> ],
<ide> ];
<ide> $this->assertTable('articles', 1, $expected, ['id >=' => 4]);
<ide> }
<ide> public function testInsertSparseRow()
<ide> 'title' => 'mark',
<ide> 'body' => null,
<ide> 'published' => 'N',
<del> ]
<add> ],
<ide> ];
<ide> $this->assertTable('articles', 1, $expected, ['id >=' => 4]);
<ide> }
<ide> public function testInsertMultipleRowsSparse()
<ide> $query->insert(['title', 'body'])
<ide> ->into('articles')
<ide> ->values([
<del> 'body' => 'test insert'
<add> 'body' => 'test insert',
<ide> ])
<ide> ->values([
<ide> 'title' => 'jose',
<ide> function ($q) {
<ide>
<ide> $query = new Query($this->connection);
<ide> $result = $query->select([
<del> 'c' => $query->func()->concat(['comment' => 'literal', ' is appended'])
<add> 'c' => $query->func()->concat(['comment' => 'literal', ' is appended']),
<ide> ])
<ide> ->from('comments')
<ide> ->order(['c' => 'ASC'])
<ide> function ($q) {
<ide> 'wd' => $query->func()->weekday('created'),
<ide> 'dow' => $query->func()->dayOfWeek('created'),
<ide> 'addDays' => $query->func()->dateAdd('created', 2, 'day'),
<del> 'substractYears' => $query->func()->dateAdd('created', -2, 'year')
<add> 'substractYears' => $query->func()->dateAdd('created', -2, 'year'),
<ide> ])
<ide> ->from('comments')
<ide> ->where(['created' => '2007-03-18 10:45:23'])
<ide> function ($q) {
<ide> 'wd' => '1', // Sunday
<ide> 'dow' => '1',
<ide> 'addDays' => '2007-03-20',
<del> 'substractYears' => '2005-03-18'
<add> 'substractYears' => '2005-03-18',
<ide> ];
<ide> $this->assertEquals($expected, $result[0]);
<ide> }
<ide> public function testQuotingExpressions()
<ide> $sql = $query->select('*')
<ide> ->where([
<ide> 'something' => 'value',
<del> 'OR' => ['foo' => 'bar', 'baz' => 'cake']
<add> 'OR' => ['foo' => 'bar', 'baz' => 'cake'],
<ide> ])
<ide> ->sql();
<ide> $this->assertQuotedQuery('<something> = :c0 AND', $sql);
<ide> public function testDebugInfo()
<ide> '(help)' => 'This is a Query object, to get the results execute or iterate it.',
<ide> 'sql' => $query->sql(),
<ide> 'params' => [
<del> ':c0' => ['value' => '1', 'type' => 'integer', 'placeholder' => 'c0']
<add> ':c0' => ['value' => '1', 'type' => 'integer', 'placeholder' => 'c0'],
<ide> ],
<ide> 'defaultTypes' => ['id' => 'integer'],
<ide> 'decorators' => 0,
<del> 'executed' => false
<add> 'executed' => false,
<ide> ];
<ide> $result = $query->__debugInfo();
<ide> $this->assertEquals($expected, $result);
<ide> public function testDebugInfo()
<ide> '(help)' => 'This is a Query object, to get the results execute or iterate it.',
<ide> 'sql' => $query->sql(),
<ide> 'params' => [
<del> ':c0' => ['value' => '1', 'type' => 'integer', 'placeholder' => 'c0']
<add> ':c0' => ['value' => '1', 'type' => 'integer', 'placeholder' => 'c0'],
<ide> ],
<ide> 'defaultTypes' => ['id' => 'integer'],
<ide> 'decorators' => 0,
<del> 'executed' => true
<add> 'executed' => true,
<ide> ];
<ide> $result = $query->__debugInfo();
<ide> $this->assertEquals($expected, $result);
<ide> public function testSqlCaseStatement()
<ide> $results = $query
<ide> ->select([
<ide> 'published' => $query->func()->sum($publishedCase),
<del> 'not_published' => $query->func()->sum($notPublishedCase)
<add> 'not_published' => $query->func()->sum($notPublishedCase),
<ide> ])
<ide> ->from(['comments'])
<ide> ->execute()
<ide> public function testSqlCaseStatement()
<ide> 'article_id' => 2,
<ide> 'user_id' => 1,
<ide> 'comment' => 'In limbo',
<del> 'published' => 'L'
<add> 'published' => 'L',
<ide> ])
<ide> ->execute()
<ide> ->closeCursor();
<ide> public function testSqlCaseStatement()
<ide> ->add(['published' => 'Y']),
<ide> $query
<ide> ->newExpr()
<del> ->add(['published' => 'N'])
<add> ->add(['published' => 'N']),
<ide> ];
<ide> $values = [
<ide> 'Published',
<ide> 'Not published',
<del> 'None'
<add> 'None',
<ide> ];
<ide> $results = $query
<ide> ->select([
<ide> 'id',
<ide> 'comment',
<del> 'status' => $query->newExpr()->addCase($conditions, $values)
<add> 'status' => $query->newExpr()->addCase($conditions, $values),
<ide> ])
<ide> ->from(['comments'])
<ide> ->execute()
<ide> public function testSelectTypeConversion()
<ide> ->setTypes([
<ide> 'id' => 'integer',
<ide> 'the_date' => 'datetime',
<del> 'updated' => 'custom_datetime'
<add> 'updated' => 'custom_datetime',
<ide> ]);
<ide>
<ide> $result = $query->execute()->fetchAll('assoc');
<ide> public function testSymmetricJsonType()
<ide> ->values([
<ide> 'comment' => ['a' => 'b', 'c' => true],
<ide> 'article_id' => 1,
<del> 'user_id' => 1
<add> 'user_id' => 1,
<ide> ])
<ide> ->execute();
<ide>
<ide> public function testRemoveJoin()
<ide> ->from('articles')
<ide> ->join(['authors' => [
<ide> 'type' => 'INNER',
<del> 'conditions' => ['articles.author_id = authors.id']
<add> 'conditions' => ['articles.author_id = authors.id'],
<ide> ]]);
<ide> $this->assertArrayHasKey('authors', $query->clause('join'));
<ide>
<ide> public function testJoinReadMode()
<ide> ->from('articles')
<ide> ->join(['authors' => [
<ide> 'type' => 'INNER',
<del> 'conditions' => ['articles.author_id = authors.id']
<add> 'conditions' => ['articles.author_id = authors.id'],
<ide> ]]);
<ide>
<ide> $this->deprecated(function () use ($query) {
<ide> public function testCastResults()
<ide> $query = new Query($this->connection);
<ide> $fields = [
<ide> 'user_id' => 'integer',
<del> 'is_active' => 'boolean'
<add> 'is_active' => 'boolean',
<ide> ];
<ide> $typeMap = new TypeMap($fields + ['a' => 'integer']);
<ide> $results = $query
<ide> public function testFetchAssoc()
<ide> $fields = [
<ide> 'id' => 'integer',
<ide> 'user_id' => 'integer',
<del> 'is_active' => 'boolean'
<add> 'is_active' => 'boolean',
<ide> ];
<ide> $typeMap = new TypeMap($fields);
<ide> $results = $query
<ide> ->select([
<ide> 'id',
<ide> 'user_id',
<del> 'is_active'
<add> 'is_active',
<ide> ])
<ide> ->from('profiles')
<ide> ->setSelectTypeMap($typeMap)
<ide> public function testFetchObjects()
<ide> ->select([
<ide> 'id',
<ide> 'user_id',
<del> 'is_active'
<add> 'is_active',
<ide> ])
<ide> ->from('profiles')
<ide> ->limit(1)
<ide> public function testFetchColumn()
<ide> $fields = [
<ide> 'integer',
<ide> 'integer',
<del> 'boolean'
<add> 'boolean',
<ide> ];
<ide> $typeMap = new TypeMap($fields);
<ide> $query
<ide> ->select([
<ide> 'id',
<ide> 'user_id',
<del> 'is_active'
<add> 'is_active',
<ide> ])
<ide> ->from('profiles')
<ide> ->setSelectTypeMap($typeMap)
<ide> public function testFetchColumnReturnsFalse()
<ide> $fields = [
<ide> 'integer',
<ide> 'integer',
<del> 'boolean'
<add> 'boolean',
<ide> ];
<ide> $typeMap = new TypeMap($fields);
<ide> $query
<ide> ->select([
<ide> 'id',
<ide> 'user_id',
<del> 'is_active'
<add> 'is_active',
<ide> ])
<ide> ->from('profiles')
<ide> ->setSelectTypeMap($typeMap)
<ide><path>tests/TestCase/Database/Schema/CollectionTest.php
<ide> class CollectionTest extends TestCase
<ide> * @var array
<ide> */
<ide> public $fixtures = [
<del> 'core.Users'
<add> 'core.Users',
<ide> ];
<ide>
<ide> /**
<ide><path>tests/TestCase/Database/Schema/MysqlSchemaTest.php
<ide> public static function convertColumnProvider()
<ide> return [
<ide> [
<ide> 'DATETIME',
<del> ['type' => 'datetime', 'length' => null]
<add> ['type' => 'datetime', 'length' => null],
<ide> ],
<ide> [
<ide> 'DATE',
<del> ['type' => 'date', 'length' => null]
<add> ['type' => 'date', 'length' => null],
<ide> ],
<ide> [
<ide> 'TIME',
<del> ['type' => 'time', 'length' => null]
<add> ['type' => 'time', 'length' => null],
<ide> ],
<ide> [
<ide> 'TIMESTAMP',
<del> ['type' => 'timestamp', 'length' => null]
<add> ['type' => 'timestamp', 'length' => null],
<ide> ],
<ide> [
<ide> 'TINYINT(1)',
<del> ['type' => 'boolean', 'length' => null]
<add> ['type' => 'boolean', 'length' => null],
<ide> ],
<ide> [
<ide> 'TINYINT(2)',
<del> ['type' => 'tinyinteger', 'length' => 2, 'unsigned' => false]
<add> ['type' => 'tinyinteger', 'length' => 2, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'TINYINT(3)',
<del> ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => false]
<add> ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'TINYINT(3) UNSIGNED',
<del> ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => true]
<add> ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => true],
<ide> ],
<ide> [
<ide> 'SMALLINT(4)',
<del> ['type' => 'smallinteger', 'length' => 4, 'unsigned' => false]
<add> ['type' => 'smallinteger', 'length' => 4, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'SMALLINT(4) UNSIGNED',
<del> ['type' => 'smallinteger', 'length' => 4, 'unsigned' => true]
<add> ['type' => 'smallinteger', 'length' => 4, 'unsigned' => true],
<ide> ],
<ide> [
<ide> 'INTEGER(11)',
<del> ['type' => 'integer', 'length' => 11, 'unsigned' => false]
<add> ['type' => 'integer', 'length' => 11, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'MEDIUMINT(11)',
<del> ['type' => 'integer', 'length' => 11, 'unsigned' => false]
<add> ['type' => 'integer', 'length' => 11, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'INTEGER(11) UNSIGNED',
<del> ['type' => 'integer', 'length' => 11, 'unsigned' => true]
<add> ['type' => 'integer', 'length' => 11, 'unsigned' => true],
<ide> ],
<ide> [
<ide> 'BIGINT',
<del> ['type' => 'biginteger', 'length' => null, 'unsigned' => false]
<add> ['type' => 'biginteger', 'length' => null, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'BIGINT UNSIGNED',
<del> ['type' => 'biginteger', 'length' => null, 'unsigned' => true]
<add> ['type' => 'biginteger', 'length' => null, 'unsigned' => true],
<ide> ],
<ide> [
<ide> 'VARCHAR(255)',
<del> ['type' => 'string', 'length' => 255, 'collate' => 'utf8_general_ci']
<add> ['type' => 'string', 'length' => 255, 'collate' => 'utf8_general_ci'],
<ide> ],
<ide> [
<ide> 'CHAR(25)',
<del> ['type' => 'string', 'length' => 25, 'fixed' => true, 'collate' => 'utf8_general_ci']
<add> ['type' => 'string', 'length' => 25, 'fixed' => true, 'collate' => 'utf8_general_ci'],
<ide> ],
<ide> [
<ide> 'CHAR(36)',
<del> ['type' => 'uuid', 'length' => null]
<add> ['type' => 'uuid', 'length' => null],
<ide> ],
<ide> [
<ide> 'BINARY(16)',
<del> ['type' => 'binaryuuid', 'length' => null]
<add> ['type' => 'binaryuuid', 'length' => null],
<ide> ],
<ide> [
<ide> 'BINARY(1)',
<del> ['type' => 'binary', 'length' => 1]
<add> ['type' => 'binary', 'length' => 1],
<ide> ],
<ide> [
<ide> 'TEXT',
<del> ['type' => 'text', 'length' => null, 'collate' => 'utf8_general_ci']
<add> ['type' => 'text', 'length' => null, 'collate' => 'utf8_general_ci'],
<ide> ],
<ide> [
<ide> 'TINYTEXT',
<del> ['type' => 'text', 'length' => TableSchema::LENGTH_TINY, 'collate' => 'utf8_general_ci']
<add> ['type' => 'text', 'length' => TableSchema::LENGTH_TINY, 'collate' => 'utf8_general_ci'],
<ide> ],
<ide> [
<ide> 'MEDIUMTEXT',
<del> ['type' => 'text', 'length' => TableSchema::LENGTH_MEDIUM, 'collate' => 'utf8_general_ci']
<add> ['type' => 'text', 'length' => TableSchema::LENGTH_MEDIUM, 'collate' => 'utf8_general_ci'],
<ide> ],
<ide> [
<ide> 'LONGTEXT',
<del> ['type' => 'text', 'length' => TableSchema::LENGTH_LONG, 'collate' => 'utf8_general_ci']
<add> ['type' => 'text', 'length' => TableSchema::LENGTH_LONG, 'collate' => 'utf8_general_ci'],
<ide> ],
<ide> [
<ide> 'TINYBLOB',
<del> ['type' => 'binary', 'length' => TableSchema::LENGTH_TINY]
<add> ['type' => 'binary', 'length' => TableSchema::LENGTH_TINY],
<ide> ],
<ide> [
<ide> 'BLOB',
<del> ['type' => 'binary', 'length' => null]
<add> ['type' => 'binary', 'length' => null],
<ide> ],
<ide> [
<ide> 'MEDIUMBLOB',
<del> ['type' => 'binary', 'length' => TableSchema::LENGTH_MEDIUM]
<add> ['type' => 'binary', 'length' => TableSchema::LENGTH_MEDIUM],
<ide> ],
<ide> [
<ide> 'LONGBLOB',
<del> ['type' => 'binary', 'length' => TableSchema::LENGTH_LONG]
<add> ['type' => 'binary', 'length' => TableSchema::LENGTH_LONG],
<ide> ],
<ide> [
<ide> 'FLOAT',
<del> ['type' => 'float', 'length' => null, 'precision' => null, 'unsigned' => false]
<add> ['type' => 'float', 'length' => null, 'precision' => null, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'DOUBLE',
<del> ['type' => 'float', 'length' => null, 'precision' => null, 'unsigned' => false]
<add> ['type' => 'float', 'length' => null, 'precision' => null, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'DOUBLE UNSIGNED',
<del> ['type' => 'float', 'length' => null, 'precision' => null, 'unsigned' => true]
<add> ['type' => 'float', 'length' => null, 'precision' => null, 'unsigned' => true],
<ide> ],
<ide> [
<ide> 'DECIMAL(11,2) UNSIGNED',
<del> ['type' => 'decimal', 'length' => 11, 'precision' => 2, 'unsigned' => true]
<add> ['type' => 'decimal', 'length' => 11, 'precision' => 2, 'unsigned' => true],
<ide> ],
<ide> [
<ide> 'DECIMAL(11,2)',
<del> ['type' => 'decimal', 'length' => 11, 'precision' => 2, 'unsigned' => false]
<add> ['type' => 'decimal', 'length' => 11, 'precision' => 2, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'FLOAT(11,2)',
<del> ['type' => 'float', 'length' => 11, 'precision' => 2, 'unsigned' => false]
<add> ['type' => 'float', 'length' => 11, 'precision' => 2, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'FLOAT(11,2) UNSIGNED',
<del> ['type' => 'float', 'length' => 11, 'precision' => 2, 'unsigned' => true]
<add> ['type' => 'float', 'length' => 11, 'precision' => 2, 'unsigned' => true],
<ide> ],
<ide> [
<ide> 'DOUBLE(10,4)',
<del> ['type' => 'float', 'length' => 10, 'precision' => 4, 'unsigned' => false]
<add> ['type' => 'float', 'length' => 10, 'precision' => 4, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'DOUBLE(10,4) UNSIGNED',
<del> ['type' => 'float', 'length' => 10, 'precision' => 4, 'unsigned' => true]
<add> ['type' => 'float', 'length' => 10, 'precision' => 4, 'unsigned' => true],
<ide> ],
<ide> [
<ide> 'JSON',
<del> ['type' => 'json', 'length' => null]
<add> ['type' => 'json', 'length' => null],
<ide> ],
<ide> ];
<ide> }
<ide> public function testDescribeTableIndexes()
<ide> 'primary' => [
<ide> 'type' => 'primary',
<ide> 'columns' => ['id'],
<del> 'length' => []
<add> 'length' => [],
<ide> ],
<ide> 'length_idx' => [
<ide> 'type' => 'unique',
<ide> 'columns' => ['title'],
<ide> 'length' => [
<ide> 'title' => 4,
<del> ]
<add> ],
<ide> ],
<ide> 'schema_articles_ibfk_1' => [
<ide> 'type' => 'foreign',
<ide> public function testDescribeTableIndexes()
<ide> 'length' => [],
<ide> 'update' => 'cascade',
<ide> 'delete' => 'restrict',
<del> ]
<add> ],
<ide> ];
<ide> $this->assertEquals($expected['primary'], $result->getConstraint('primary'));
<ide> $this->assertEquals($expected['length_idx'], $result->getConstraint('length_idx'));
<ide> public function testDescribeTableIndexes()
<ide> $expected = [
<ide> 'type' => 'index',
<ide> 'columns' => ['author_id'],
<del> 'length' => []
<add> 'length' => [],
<ide> ];
<ide> $this->assertEquals($expected, $result->getIndex('author_idx'));
<ide> }
<ide> public static function columnSqlProvider()
<ide> [
<ide> 'title',
<ide> ['type' => 'string', 'length' => 25, 'null' => false],
<del> '`title` VARCHAR(25) NOT NULL'
<add> '`title` VARCHAR(25) NOT NULL',
<ide> ],
<ide> [
<ide> 'title',
<ide> public static function columnSqlProvider()
<ide> [
<ide> 'role',
<ide> ['type' => 'string', 'length' => 10, 'null' => false, 'default' => 'admin'],
<del> '`role` VARCHAR(10) NOT NULL DEFAULT \'admin\''
<add> '`role` VARCHAR(10) NOT NULL DEFAULT \'admin\'',
<ide> ],
<ide> [
<ide> 'id',
<ide> ['type' => 'string', 'length' => 32, 'fixed' => true, 'null' => false],
<del> '`id` CHAR(32) NOT NULL'
<add> '`id` CHAR(32) NOT NULL',
<ide> ],
<ide> [
<ide> 'title',
<ide> ['type' => 'string'],
<del> '`title` VARCHAR(255)'
<add> '`title` VARCHAR(255)',
<ide> ],
<ide> [
<ide> 'id',
<ide> ['type' => 'uuid'],
<del> '`id` CHAR(36)'
<add> '`id` CHAR(36)',
<ide> ],
<ide> [
<ide> 'id',
<ide> ['type' => 'binaryuuid'],
<del> '`id` BINARY(16)'
<add> '`id` BINARY(16)',
<ide> ],
<ide> [
<ide> 'title',
<ide> ['type' => 'string', 'length' => 255, 'null' => false, 'collate' => 'utf8_unicode_ci'],
<del> '`title` VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL'
<add> '`title` VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL',
<ide> ],
<ide> // Text
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'null' => false],
<del> '`body` TEXT NOT NULL'
<add> '`body` TEXT NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'length' => TableSchema::LENGTH_TINY, 'null' => false],
<del> '`body` TINYTEXT NOT NULL'
<add> '`body` TINYTEXT NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'length' => TableSchema::LENGTH_MEDIUM, 'null' => false],
<del> '`body` MEDIUMTEXT NOT NULL'
<add> '`body` MEDIUMTEXT NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'length' => TableSchema::LENGTH_LONG, 'null' => false],
<del> '`body` LONGTEXT NOT NULL'
<add> '`body` LONGTEXT NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'null' => false, 'collate' => 'utf8_unicode_ci'],
<del> '`body` TEXT COLLATE utf8_unicode_ci NOT NULL'
<add> '`body` TEXT COLLATE utf8_unicode_ci NOT NULL',
<ide> ],
<ide> // Blob / binary
<ide> [
<ide> 'body',
<ide> ['type' => 'binary', 'null' => false],
<del> '`body` BLOB NOT NULL'
<add> '`body` BLOB NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'binary', 'length' => TableSchema::LENGTH_TINY, 'null' => false],
<del> '`body` TINYBLOB NOT NULL'
<add> '`body` TINYBLOB NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'binary', 'length' => TableSchema::LENGTH_MEDIUM, 'null' => false],
<del> '`body` MEDIUMBLOB NOT NULL'
<add> '`body` MEDIUMBLOB NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'binary', 'length' => TableSchema::LENGTH_LONG, 'null' => false],
<del> '`body` LONGBLOB NOT NULL'
<add> '`body` LONGBLOB NOT NULL',
<ide> ],
<ide> [
<ide> 'bytes',
<ide> ['type' => 'binary', 'length' => 5],
<del> '`bytes` VARBINARY(5)'
<add> '`bytes` VARBINARY(5)',
<ide> ],
<ide> [
<ide> 'bit',
<ide> ['type' => 'binary', 'length' => 1],
<del> '`bit` BINARY(1)'
<add> '`bit` BINARY(1)',
<ide> ],
<ide> // Integers
<ide> [
<ide> 'post_id',
<ide> ['type' => 'tinyinteger', 'length' => 2],
<del> '`post_id` TINYINT(2)'
<add> '`post_id` TINYINT(2)',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'tinyinteger', 'length' => 2, 'unsigned' => true],
<del> '`post_id` TINYINT(2) UNSIGNED'
<add> '`post_id` TINYINT(2) UNSIGNED',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'smallinteger', 'length' => 4],
<del> '`post_id` SMALLINT(4)'
<add> '`post_id` SMALLINT(4)',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'smallinteger', 'length' => 4, 'unsigned' => true],
<del> '`post_id` SMALLINT(4) UNSIGNED'
<add> '`post_id` SMALLINT(4) UNSIGNED',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'integer', 'length' => 11],
<del> '`post_id` INTEGER(11)'
<add> '`post_id` INTEGER(11)',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'integer', 'length' => 11, 'unsigned' => true],
<del> '`post_id` INTEGER(11) UNSIGNED'
<add> '`post_id` INTEGER(11) UNSIGNED',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'biginteger', 'length' => 20],
<del> '`post_id` BIGINT'
<add> '`post_id` BIGINT',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'biginteger', 'length' => 20, 'unsigned' => true],
<del> '`post_id` BIGINT UNSIGNED'
<add> '`post_id` BIGINT UNSIGNED',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'integer', 'length' => 20, 'autoIncrement' => true],
<del> '`post_id` INTEGER(20) AUTO_INCREMENT'
<add> '`post_id` INTEGER(20) AUTO_INCREMENT',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'integer', 'length' => 20, 'null' => false, 'autoIncrement' => false],
<del> '`post_id` INTEGER(20) NOT NULL'
<add> '`post_id` INTEGER(20) NOT NULL',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'biginteger', 'length' => 20, 'autoIncrement' => true],
<del> '`post_id` BIGINT AUTO_INCREMENT'
<add> '`post_id` BIGINT AUTO_INCREMENT',
<ide> ],
<ide> // Decimal
<ide> [
<ide> 'value',
<ide> ['type' => 'decimal'],
<del> '`value` DECIMAL'
<add> '`value` DECIMAL',
<ide> ],
<ide> [
<ide> 'value',
<ide> ['type' => 'decimal', 'length' => 11, 'unsigned' => true],
<del> '`value` DECIMAL(11) UNSIGNED'
<add> '`value` DECIMAL(11) UNSIGNED',
<ide> ],
<ide> [
<ide> 'value',
<ide> ['type' => 'decimal', 'length' => 12, 'precision' => 5],
<del> '`value` DECIMAL(12,5)'
<add> '`value` DECIMAL(12,5)',
<ide> ],
<ide> // Float
<ide> [
<ide> 'value',
<ide> ['type' => 'float', 'unsigned'],
<del> '`value` FLOAT'
<add> '`value` FLOAT',
<ide> ],
<ide> [
<ide> 'value',
<ide> ['type' => 'float', 'unsigned' => true],
<del> '`value` FLOAT UNSIGNED'
<add> '`value` FLOAT UNSIGNED',
<ide> ],
<ide> [
<ide> 'latitude',
<ide> public static function columnSqlProvider()
<ide> [
<ide> 'value',
<ide> ['type' => 'float', 'length' => 11, 'precision' => 3],
<del> '`value` FLOAT(11,3)'
<add> '`value` FLOAT(11,3)',
<ide> ],
<ide> // Boolean
<ide> [
<ide> 'checked',
<ide> ['type' => 'boolean', 'default' => false],
<del> '`checked` BOOLEAN DEFAULT FALSE'
<add> '`checked` BOOLEAN DEFAULT FALSE',
<ide> ],
<ide> [
<ide> 'checked',
<ide> ['type' => 'boolean', 'default' => false, 'null' => false],
<del> '`checked` BOOLEAN NOT NULL DEFAULT FALSE'
<add> '`checked` BOOLEAN NOT NULL DEFAULT FALSE',
<ide> ],
<ide> [
<ide> 'checked',
<ide> ['type' => 'boolean', 'default' => true, 'null' => false],
<del> '`checked` BOOLEAN NOT NULL DEFAULT TRUE'
<add> '`checked` BOOLEAN NOT NULL DEFAULT TRUE',
<ide> ],
<ide> [
<ide> 'checked',
<ide> ['type' => 'boolean', 'default' => false, 'null' => true],
<del> '`checked` BOOLEAN DEFAULT FALSE'
<add> '`checked` BOOLEAN DEFAULT FALSE',
<ide> ],
<ide> // datetimes
<ide> [
<ide> 'created',
<ide> ['type' => 'datetime', 'comment' => 'Created timestamp'],
<del> '`created` DATETIME COMMENT \'Created timestamp\''
<add> '`created` DATETIME COMMENT \'Created timestamp\'',
<ide> ],
<ide> [
<ide> 'created',
<ide> ['type' => 'datetime', 'null' => false, 'default' => 'current_timestamp'],
<del> '`created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP'
<add> '`created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
<ide> ],
<ide> [
<ide> 'open_date',
<ide> ['type' => 'datetime', 'null' => false, 'default' => '2016-12-07 23:04:00'],
<del> '`open_date` DATETIME NOT NULL DEFAULT \'2016-12-07 23:04:00\''
<add> '`open_date` DATETIME NOT NULL DEFAULT \'2016-12-07 23:04:00\'',
<ide> ],
<ide> // Date & Time
<ide> [
<ide> 'start_date',
<ide> ['type' => 'date'],
<del> '`start_date` DATE'
<add> '`start_date` DATE',
<ide> ],
<ide> [
<ide> 'start_time',
<ide> ['type' => 'time'],
<del> '`start_time` TIME'
<add> '`start_time` TIME',
<ide> ],
<ide> // timestamps
<ide> [
<ide> 'created',
<ide> ['type' => 'timestamp', 'null' => true],
<del> '`created` TIMESTAMP NULL'
<add> '`created` TIMESTAMP NULL',
<ide> ],
<ide> [
<ide> 'created',
<ide> ['type' => 'timestamp', 'null' => false, 'default' => 'current_timestamp'],
<del> '`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP'
<add> '`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP',
<ide> ],
<ide> [
<ide> 'created',
<ide> ['type' => 'timestamp', 'null' => false, 'default' => 'current_timestamp()'],
<del> '`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP'
<add> '`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP',
<ide> ],
<ide> [
<ide> 'open_date',
<ide> ['type' => 'timestamp', 'null' => false, 'default' => '2016-12-07 23:04:00'],
<del> '`open_date` TIMESTAMP NOT NULL DEFAULT \'2016-12-07 23:04:00\''
<add> '`open_date` TIMESTAMP NOT NULL DEFAULT \'2016-12-07 23:04:00\'',
<ide> ],
<ide> ];
<ide> }
<ide> public static function constraintSqlProvider()
<ide> [
<ide> 'primary',
<ide> ['type' => 'primary', 'columns' => ['title']],
<del> 'PRIMARY KEY (`title`)'
<add> 'PRIMARY KEY (`title`)',
<ide> ],
<ide> [
<ide> 'unique_idx',
<ide> ['type' => 'unique', 'columns' => ['title', 'author_id']],
<del> 'UNIQUE KEY `unique_idx` (`title`, `author_id`)'
<add> 'UNIQUE KEY `unique_idx` (`title`, `author_id`)',
<ide> ],
<ide> [
<ide> 'length_idx',
<ide> [
<ide> 'type' => 'unique',
<ide> 'columns' => ['author_id', 'title'],
<del> 'length' => ['author_id' => 5, 'title' => 4]
<add> 'length' => ['author_id' => 5, 'title' => 4],
<ide> ],
<del> 'UNIQUE KEY `length_idx` (`author_id`(5), `title`(4))'
<add> 'UNIQUE KEY `length_idx` (`author_id`(5), `title`(4))',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id']],
<ide> 'CONSTRAINT `author_id_idx` FOREIGN KEY (`author_id`) ' .
<del> 'REFERENCES `authors` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT'
<add> 'REFERENCES `authors` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'cascade'],
<ide> 'CONSTRAINT `author_id_idx` FOREIGN KEY (`author_id`) ' .
<del> 'REFERENCES `authors` (`id`) ON UPDATE CASCADE ON DELETE RESTRICT'
<add> 'REFERENCES `authors` (`id`) ON UPDATE CASCADE ON DELETE RESTRICT',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'restrict'],
<ide> 'CONSTRAINT `author_id_idx` FOREIGN KEY (`author_id`) ' .
<del> 'REFERENCES `authors` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT'
<add> 'REFERENCES `authors` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'setNull'],
<ide> 'CONSTRAINT `author_id_idx` FOREIGN KEY (`author_id`) ' .
<del> 'REFERENCES `authors` (`id`) ON UPDATE SET NULL ON DELETE RESTRICT'
<add> 'REFERENCES `authors` (`id`) ON UPDATE SET NULL ON DELETE RESTRICT',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'noAction'],
<ide> 'CONSTRAINT `author_id_idx` FOREIGN KEY (`author_id`) ' .
<del> 'REFERENCES `authors` (`id`) ON UPDATE NO ACTION ON DELETE RESTRICT'
<add> 'REFERENCES `authors` (`id`) ON UPDATE NO ACTION ON DELETE RESTRICT',
<ide> ],
<ide> ];
<ide> }
<ide> public function testConstraintSql($name, $data, $expected)
<ide>
<ide> $table = (new TableSchema('articles'))->addColumn('title', [
<ide> 'type' => 'string',
<del> 'length' => 255
<add> 'length' => 255,
<ide> ])->addColumn('author_id', [
<ide> 'type' => 'integer',
<ide> ])->addConstraint($name, $data);
<ide> public static function indexSqlProvider()
<ide> [
<ide> 'key_key',
<ide> ['type' => 'index', 'columns' => ['author_id']],
<del> 'KEY `key_key` (`author_id`)'
<add> 'KEY `key_key` (`author_id`)',
<ide> ],
<ide> [
<ide> 'full_text',
<ide> ['type' => 'fulltext', 'columns' => ['title']],
<del> 'FULLTEXT KEY `full_text` (`title`)'
<add> 'FULLTEXT KEY `full_text` (`title`)',
<ide> ],
<ide> ];
<ide> }
<ide> public function testIndexSql($name, $data, $expected)
<ide>
<ide> $table = (new TableSchema('articles'))->addColumn('title', [
<ide> 'type' => 'string',
<del> 'length' => 255
<add> 'length' => 255,
<ide> ])->addColumn('author_id', [
<ide> 'type' => 'integer',
<ide> ])->addIndex($name, $data);
<ide> public function testAddConstraintSql()
<ide> $table = (new TableSchema('posts'))
<ide> ->addColumn('author_id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('category_id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('category_name', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addConstraint('author_fk', [
<ide> 'type' => 'foreign',
<ide> 'columns' => ['author_id'],
<ide> 'references' => ['authors', 'id'],
<ide> 'update' => 'cascade',
<del> 'delete' => 'cascade'
<add> 'delete' => 'cascade',
<ide> ])
<ide> ->addConstraint('category_fk', [
<ide> 'type' => 'foreign',
<ide> 'columns' => ['category_id', 'category_name'],
<ide> 'references' => ['categories', ['id', 'name']],
<ide> 'update' => 'cascade',
<del> 'delete' => 'cascade'
<add> 'delete' => 'cascade',
<ide> ]);
<ide>
<ide> $expected = [
<ide> 'ALTER TABLE `posts` ADD CONSTRAINT `author_fk` FOREIGN KEY (`author_id`) REFERENCES `authors` (`id`) ON UPDATE CASCADE ON DELETE CASCADE;',
<del> 'ALTER TABLE `posts` ADD CONSTRAINT `category_fk` FOREIGN KEY (`category_id`, `category_name`) REFERENCES `categories` (`id`, `name`) ON UPDATE CASCADE ON DELETE CASCADE;'
<add> 'ALTER TABLE `posts` ADD CONSTRAINT `category_fk` FOREIGN KEY (`category_id`, `category_name`) REFERENCES `categories` (`id`, `name`) ON UPDATE CASCADE ON DELETE CASCADE;',
<ide> ];
<ide> $result = $table->addConstraintSql($connection);
<ide> $this->assertCount(2, $result);
<ide> public function testDropConstraintSql()
<ide> $table = (new TableSchema('posts'))
<ide> ->addColumn('author_id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('category_id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('category_name', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addConstraint('author_fk', [
<ide> 'type' => 'foreign',
<ide> 'columns' => ['author_id'],
<ide> 'references' => ['authors', 'id'],
<ide> 'update' => 'cascade',
<del> 'delete' => 'cascade'
<add> 'delete' => 'cascade',
<ide> ])
<ide> ->addConstraint('category_fk', [
<ide> 'type' => 'foreign',
<ide> 'columns' => ['category_id', 'category_name'],
<ide> 'references' => ['categories', ['id', 'name']],
<ide> 'update' => 'cascade',
<del> 'delete' => 'cascade'
<add> 'delete' => 'cascade',
<ide> ]);
<ide>
<ide> $expected = [
<ide> 'ALTER TABLE `posts` DROP FOREIGN KEY `author_fk`;',
<del> 'ALTER TABLE `posts` DROP FOREIGN KEY `category_fk`;'
<add> 'ALTER TABLE `posts` DROP FOREIGN KEY `category_fk`;',
<ide> ];
<ide> $result = $table->dropConstraintSql($connection);
<ide> $this->assertCount(2, $result);
<ide> public function testColumnSqlPrimaryKey()
<ide> ])
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['id']
<add> 'columns' => ['id'],
<ide> ]);
<ide> $result = $schema->columnSql($table, 'id');
<ide> $this->assertEquals($result, '`id` INTEGER NOT NULL AUTO_INCREMENT');
<ide>
<ide> $table = new TableSchema('articles');
<ide> $table->addColumn('id', [
<ide> 'type' => 'biginteger',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['id']
<add> 'columns' => ['id'],
<ide> ]);
<ide> $result = $schema->columnSql($table, 'id');
<ide> $this->assertEquals($result, '`id` BIGINT NOT NULL AUTO_INCREMENT');
<ide> public function testCreateSql()
<ide>
<ide> $table = (new TableSchema('posts'))->addColumn('id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('title', [
<ide> 'type' => 'string',
<ide> 'null' => false,
<del> 'comment' => 'The title'
<add> 'comment' => 'The title',
<ide> ])
<ide> ->addColumn('body', [
<ide> 'type' => 'text',
<del> 'comment' => ''
<add> 'comment' => '',
<ide> ])
<ide> ->addColumn('data', [
<del> 'type' => 'json'
<add> 'type' => 'json',
<ide> ])
<ide> ->addColumn('hash', [
<ide> 'type' => 'string',
<ide> public function testCreateSql()
<ide> ->addColumn('created', 'datetime')
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['id']
<add> 'columns' => ['id'],
<ide> ])
<ide> ->setOptions([
<ide> 'engine' => 'InnoDB',
<ide> public function testCreateSqlJson()
<ide>
<ide> $table = (new TableSchema('posts'))->addColumn('id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('data', [
<del> 'type' => 'json'
<add> 'type' => 'json',
<ide> ])
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['id']
<add> 'columns' => ['id'],
<ide> ])
<ide> ->setOptions([
<ide> 'engine' => 'InnoDB',
<ide> public function testCreateTemporary()
<ide> ->will($this->returnValue($driver));
<ide> $table = (new TableSchema('schema_articles'))->addColumn('id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ]);
<ide> $table->setTemporary(true);
<ide> $sql = $table->createSql($connection);
<ide> public function testCreateSqlCompositeIntegerKey()
<ide> $table = (new TableSchema('articles_tags'))
<ide> ->addColumn('article_id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('tag_id', [
<ide> 'type' => 'integer',
<ide> 'null' => false,
<ide> ])
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['article_id', 'tag_id']
<add> 'columns' => ['article_id', 'tag_id'],
<ide> ]);
<ide>
<ide> $expected = <<<SQL
<ide> public function testCreateSqlCompositeIntegerKey()
<ide> ->addColumn('id', [
<ide> 'type' => 'integer',
<ide> 'null' => false,
<del> 'autoIncrement' => true
<add> 'autoIncrement' => true,
<ide> ])
<ide> ->addColumn('account_id', [
<ide> 'type' => 'integer',
<ide> 'null' => false,
<ide> ])
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['id', 'account_id']
<add> 'columns' => ['id', 'account_id'],
<ide> ]);
<ide>
<ide> $expected = <<<SQL
<ide><path>tests/TestCase/Database/Schema/PostgresSchemaTest.php
<ide> public static function convertColumnProvider()
<ide> // Timestamp
<ide> [
<ide> ['type' => 'TIMESTAMP'],
<del> ['type' => 'timestamp', 'length' => null]
<add> ['type' => 'timestamp', 'length' => null],
<ide> ],
<ide> [
<ide> ['type' => 'TIMESTAMP WITHOUT TIME ZONE'],
<del> ['type' => 'timestamp', 'length' => null]
<add> ['type' => 'timestamp', 'length' => null],
<ide> ],
<ide> // Date & time
<ide> [
<ide> ['type' => 'DATE'],
<del> ['type' => 'date', 'length' => null]
<add> ['type' => 'date', 'length' => null],
<ide> ],
<ide> [
<ide> ['type' => 'TIME'],
<del> ['type' => 'time', 'length' => null]
<add> ['type' => 'time', 'length' => null],
<ide> ],
<ide> [
<ide> ['type' => 'TIME WITHOUT TIME ZONE'],
<del> ['type' => 'time', 'length' => null]
<add> ['type' => 'time', 'length' => null],
<ide> ],
<ide> // Integer
<ide> [
<ide> ['type' => 'SMALLINT'],
<del> ['type' => 'smallinteger', 'length' => 5]
<add> ['type' => 'smallinteger', 'length' => 5],
<ide> ],
<ide> [
<ide> ['type' => 'INTEGER'],
<del> ['type' => 'integer', 'length' => 10]
<add> ['type' => 'integer', 'length' => 10],
<ide> ],
<ide> [
<ide> ['type' => 'SERIAL'],
<del> ['type' => 'integer', 'length' => 10]
<add> ['type' => 'integer', 'length' => 10],
<ide> ],
<ide> [
<ide> ['type' => 'BIGINT'],
<del> ['type' => 'biginteger', 'length' => 20]
<add> ['type' => 'biginteger', 'length' => 20],
<ide> ],
<ide> [
<ide> ['type' => 'BIGSERIAL'],
<del> ['type' => 'biginteger', 'length' => 20]
<add> ['type' => 'biginteger', 'length' => 20],
<ide> ],
<ide> // Decimal
<ide> [
<ide> ['type' => 'NUMERIC'],
<del> ['type' => 'decimal', 'length' => null, 'precision' => null]
<add> ['type' => 'decimal', 'length' => null, 'precision' => null],
<ide> ],
<ide> [
<ide> ['type' => 'NUMERIC', 'default' => 'NULL::numeric'],
<del> ['type' => 'decimal', 'length' => null, 'precision' => null, 'default' => null]
<add> ['type' => 'decimal', 'length' => null, 'precision' => null, 'default' => null],
<ide> ],
<ide> [
<ide> ['type' => 'DECIMAL(10,2)', 'column_precision' => 10, 'column_scale' => 2],
<del> ['type' => 'decimal', 'length' => 10, 'precision' => 2]
<add> ['type' => 'decimal', 'length' => 10, 'precision' => 2],
<ide> ],
<ide> // String
<ide> [
<ide> ['type' => 'VARCHAR'],
<del> ['type' => 'string', 'length' => null, 'collate' => 'ja_JP.utf8']
<add> ['type' => 'string', 'length' => null, 'collate' => 'ja_JP.utf8'],
<ide> ],
<ide> [
<ide> ['type' => 'VARCHAR(10)'],
<del> ['type' => 'string', 'length' => 10, 'collate' => 'ja_JP.utf8']
<add> ['type' => 'string', 'length' => 10, 'collate' => 'ja_JP.utf8'],
<ide> ],
<ide> [
<ide> ['type' => 'CHARACTER VARYING'],
<del> ['type' => 'string', 'length' => null, 'collate' => 'ja_JP.utf8']
<add> ['type' => 'string', 'length' => null, 'collate' => 'ja_JP.utf8'],
<ide> ],
<ide> [
<ide> ['type' => 'CHARACTER VARYING(10)'],
<del> ['type' => 'string', 'length' => 10, 'collate' => 'ja_JP.utf8']
<add> ['type' => 'string', 'length' => 10, 'collate' => 'ja_JP.utf8'],
<ide> ],
<ide> [
<ide> ['type' => 'CHARACTER VARYING(255)', 'default' => 'NULL::character varying'],
<del> ['type' => 'string', 'length' => 255, 'default' => null, 'collate' => 'ja_JP.utf8']
<add> ['type' => 'string', 'length' => 255, 'default' => null, 'collate' => 'ja_JP.utf8'],
<ide> ],
<ide> [
<ide> ['type' => 'CHAR(10)'],
<del> ['type' => 'string', 'fixed' => true, 'length' => 10, 'collate' => 'ja_JP.utf8']
<add> ['type' => 'string', 'fixed' => true, 'length' => 10, 'collate' => 'ja_JP.utf8'],
<ide> ],
<ide> [
<ide> ['type' => 'CHAR(36)'],
<del> ['type' => 'string', 'fixed' => true, 'length' => 36, 'collate' => 'ja_JP.utf8']
<add> ['type' => 'string', 'fixed' => true, 'length' => 36, 'collate' => 'ja_JP.utf8'],
<ide> ],
<ide> [
<ide> ['type' => 'CHARACTER(10)'],
<del> ['type' => 'string', 'fixed' => true, 'length' => 10, 'collate' => 'ja_JP.utf8']
<add> ['type' => 'string', 'fixed' => true, 'length' => 10, 'collate' => 'ja_JP.utf8'],
<ide> ],
<ide> [
<ide> ['type' => 'MONEY'],
<del> ['type' => 'string', 'length' => null]
<add> ['type' => 'string', 'length' => null],
<ide> ],
<ide> // UUID
<ide> [
<ide> ['type' => 'UUID'],
<del> ['type' => 'uuid', 'length' => null]
<add> ['type' => 'uuid', 'length' => null],
<ide> ],
<ide> [
<ide> ['type' => 'INET'],
<del> ['type' => 'string', 'length' => 39]
<add> ['type' => 'string', 'length' => 39],
<ide> ],
<ide> // Text
<ide> [
<ide> ['type' => 'TEXT'],
<del> ['type' => 'text', 'length' => null, 'collate' => 'ja_JP.utf8']
<add> ['type' => 'text', 'length' => null, 'collate' => 'ja_JP.utf8'],
<ide> ],
<ide> // Blob
<ide> [
<ide> ['type' => 'BYTEA'],
<del> ['type' => 'binary', 'length' => null]
<add> ['type' => 'binary', 'length' => null],
<ide> ],
<ide> // Float
<ide> [
<ide> ['type' => 'REAL'],
<del> ['type' => 'float', 'length' => null]
<add> ['type' => 'float', 'length' => null],
<ide> ],
<ide> [
<ide> ['type' => 'DOUBLE PRECISION'],
<del> ['type' => 'float', 'length' => null]
<add> ['type' => 'float', 'length' => null],
<ide> ],
<ide> // Json
<ide> [
<ide> ['type' => 'JSON'],
<del> ['type' => 'json', 'length' => null]
<add> ['type' => 'json', 'length' => null],
<ide> ],
<ide> [
<ide> ['type' => 'JSONB'],
<del> ['type' => 'json', 'length' => null]
<add> ['type' => 'json', 'length' => null],
<ide> ],
<ide> ];
<ide> }
<ide> public function testDescribeTableConstraintsWithKeywords()
<ide> 'primary' => [
<ide> 'type' => 'primary',
<ide> 'columns' => ['id'],
<del> 'length' => []
<add> 'length' => [],
<ide> ],
<ide> 'unique_position' => [
<ide> 'type' => 'unique',
<ide> 'columns' => ['position'],
<del> 'length' => []
<del> ]
<add> 'length' => [],
<add> ],
<ide> ];
<ide> $this->assertCount(2, $result->constraints());
<ide> $this->assertEquals($expected['primary'], $result->getConstraint('primary'));
<ide> public function testDescribeTableIndexes()
<ide> 'primary' => [
<ide> 'type' => 'primary',
<ide> 'columns' => ['id'],
<del> 'length' => []
<add> 'length' => [],
<ide> ],
<ide> 'content_idx' => [
<ide> 'type' => 'unique',
<ide> 'columns' => ['title', 'body'],
<del> 'length' => []
<del> ]
<add> 'length' => [],
<add> ],
<ide> ];
<ide> $this->assertCount(3, $result->constraints());
<ide> $expected = [
<ide> 'primary' => [
<ide> 'type' => 'primary',
<ide> 'columns' => ['id'],
<del> 'length' => []
<add> 'length' => [],
<ide> ],
<ide> 'content_idx' => [
<ide> 'type' => 'unique',
<ide> 'columns' => ['title', 'body'],
<del> 'length' => []
<add> 'length' => [],
<ide> ],
<ide> 'author_idx' => [
<ide> 'type' => 'foreign',
<ide> public function testDescribeTableIndexes()
<ide> 'length' => [],
<ide> 'update' => 'cascade',
<ide> 'delete' => 'restrict',
<del> ]
<add> ],
<ide> ];
<ide> $this->assertEquals($expected['primary'], $result->getConstraint('primary'));
<ide> $this->assertEquals($expected['content_idx'], $result->getConstraint('content_idx'));
<ide> public function testDescribeTableIndexes()
<ide> $expected = [
<ide> 'type' => 'index',
<ide> 'columns' => ['author_id'],
<del> 'length' => []
<add> 'length' => [],
<ide> ];
<ide> $this->assertEquals($expected, $result->getIndex('author_idx'));
<ide> }
<ide> public function testDescribeTableIndexesNullsFirst()
<ide> $expected = [
<ide> 'type' => 'index',
<ide> 'columns' => ['group_id', 'grade'],
<del> 'length' => []
<add> 'length' => [],
<ide> ];
<ide> $this->assertEquals($expected, $result->getIndex('schema_index_nulls'));
<ide> $connection->execute('DROP TABLE schema_index');
<ide> public static function columnSqlProvider()
<ide> [
<ide> 'title',
<ide> ['type' => 'string', 'length' => 25, 'null' => false],
<del> '"title" VARCHAR(25) NOT NULL'
<add> '"title" VARCHAR(25) NOT NULL',
<ide> ],
<ide> [
<ide> 'title',
<ide> public static function columnSqlProvider()
<ide> [
<ide> 'id',
<ide> ['type' => 'string', 'length' => 32, 'fixed' => true, 'null' => false],
<del> '"id" CHAR(32) NOT NULL'
<add> '"id" CHAR(32) NOT NULL',
<ide> ],
<ide> [
<ide> 'title',
<ide> ['type' => 'string', 'length' => 36, 'fixed' => true, 'null' => false],
<del> '"title" CHAR(36) NOT NULL'
<add> '"title" CHAR(36) NOT NULL',
<ide> ],
<ide> [
<ide> 'id',
<ide> ['type' => 'uuid', 'length' => 36, 'null' => false],
<del> '"id" UUID NOT NULL'
<add> '"id" UUID NOT NULL',
<ide> ],
<ide> [
<ide> 'id',
<ide> ['type' => 'binaryuuid', 'length' => null, 'null' => false],
<del> '"id" UUID NOT NULL'
<add> '"id" UUID NOT NULL',
<ide> ],
<ide> [
<ide> 'role',
<ide> ['type' => 'string', 'length' => 10, 'null' => false, 'default' => 'admin'],
<del> '"role" VARCHAR(10) NOT NULL DEFAULT \'admin\''
<add> '"role" VARCHAR(10) NOT NULL DEFAULT \'admin\'',
<ide> ],
<ide> [
<ide> 'title',
<ide> ['type' => 'string'],
<del> '"title" VARCHAR'
<add> '"title" VARCHAR',
<ide> ],
<ide> [
<ide> 'title',
<ide> ['type' => 'string', 'length' => 36],
<del> '"title" VARCHAR(36)'
<add> '"title" VARCHAR(36)',
<ide> ],
<ide> [
<ide> 'title',
<ide> ['type' => 'string', 'length' => 255, 'null' => false, 'collate' => 'C'],
<del> '"title" VARCHAR(255) COLLATE "C" NOT NULL'
<add> '"title" VARCHAR(255) COLLATE "C" NOT NULL',
<ide> ],
<ide> // Text
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'null' => false],
<del> '"body" TEXT NOT NULL'
<add> '"body" TEXT NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'length' => TableSchema::LENGTH_TINY, 'null' => false],
<del> sprintf('"body" VARCHAR(%s) NOT NULL', TableSchema::LENGTH_TINY)
<add> sprintf('"body" VARCHAR(%s) NOT NULL', TableSchema::LENGTH_TINY),
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'length' => TableSchema::LENGTH_MEDIUM, 'null' => false],
<del> '"body" TEXT NOT NULL'
<add> '"body" TEXT NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'length' => TableSchema::LENGTH_LONG, 'null' => false],
<del> '"body" TEXT NOT NULL'
<add> '"body" TEXT NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'null' => false, 'collate' => 'C'],
<del> '"body" TEXT COLLATE "C" NOT NULL'
<add> '"body" TEXT COLLATE "C" NOT NULL',
<ide> ],
<ide> // Integers
<ide> [
<ide> 'post_id',
<ide> ['type' => 'tinyinteger', 'length' => 11],
<del> '"post_id" SMALLINT'
<add> '"post_id" SMALLINT',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'smallinteger', 'length' => 11],
<del> '"post_id" SMALLINT'
<add> '"post_id" SMALLINT',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'integer', 'length' => 11],
<del> '"post_id" INTEGER'
<add> '"post_id" INTEGER',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'biginteger', 'length' => 20],
<del> '"post_id" BIGINT'
<add> '"post_id" BIGINT',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'integer', 'autoIncrement' => true, 'length' => 11],
<del> '"post_id" SERIAL'
<add> '"post_id" SERIAL',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'biginteger', 'autoIncrement' => true, 'length' => 20],
<del> '"post_id" BIGSERIAL'
<add> '"post_id" BIGSERIAL',
<ide> ],
<ide> // Decimal
<ide> [
<ide> 'value',
<ide> ['type' => 'decimal'],
<del> '"value" DECIMAL'
<add> '"value" DECIMAL',
<ide> ],
<ide> [
<ide> 'value',
<ide> ['type' => 'decimal', 'length' => 11],
<del> '"value" DECIMAL(11,0)'
<add> '"value" DECIMAL(11,0)',
<ide> ],
<ide> [
<ide> 'value',
<ide> ['type' => 'decimal', 'length' => 12, 'precision' => 5],
<del> '"value" DECIMAL(12,5)'
<add> '"value" DECIMAL(12,5)',
<ide> ],
<ide> // Float
<ide> [
<ide> 'value',
<ide> ['type' => 'float'],
<del> '"value" FLOAT'
<add> '"value" FLOAT',
<ide> ],
<ide> [
<ide> 'value',
<ide> ['type' => 'float', 'length' => 11, 'precision' => 3],
<del> '"value" FLOAT(3)'
<add> '"value" FLOAT(3)',
<ide> ],
<ide> // Binary
<ide> [
<ide> 'img',
<ide> ['type' => 'binary'],
<del> '"img" BYTEA'
<add> '"img" BYTEA',
<ide> ],
<ide> // Boolean
<ide> [
<ide> 'checked',
<ide> ['type' => 'boolean', 'default' => false],
<del> '"checked" BOOLEAN DEFAULT FALSE'
<add> '"checked" BOOLEAN DEFAULT FALSE',
<ide> ],
<ide> [
<ide> 'checked',
<ide> ['type' => 'boolean', 'default' => true, 'null' => false],
<del> '"checked" BOOLEAN NOT NULL DEFAULT TRUE'
<add> '"checked" BOOLEAN NOT NULL DEFAULT TRUE',
<ide> ],
<ide> // Boolean
<ide> [
<ide> 'checked',
<ide> ['type' => 'boolean', 'default' => 0],
<del> '"checked" BOOLEAN DEFAULT FALSE'
<add> '"checked" BOOLEAN DEFAULT FALSE',
<ide> ],
<ide> [
<ide> 'checked',
<ide> ['type' => 'boolean', 'default' => 1, 'null' => false],
<del> '"checked" BOOLEAN NOT NULL DEFAULT TRUE'
<add> '"checked" BOOLEAN NOT NULL DEFAULT TRUE',
<ide> ],
<ide> // Datetime
<ide> [
<ide> 'created',
<ide> ['type' => 'datetime'],
<del> '"created" TIMESTAMP'
<add> '"created" TIMESTAMP',
<ide> ],
<ide> [
<ide> 'open_date',
<ide> ['type' => 'datetime', 'null' => false, 'default' => '2016-12-07 23:04:00'],
<del> '"open_date" TIMESTAMP NOT NULL DEFAULT \'2016-12-07 23:04:00\''
<add> '"open_date" TIMESTAMP NOT NULL DEFAULT \'2016-12-07 23:04:00\'',
<ide> ],
<ide> [
<ide> 'null_date',
<ide> ['type' => 'datetime', 'null' => true],
<del> '"null_date" TIMESTAMP DEFAULT NULL'
<add> '"null_date" TIMESTAMP DEFAULT NULL',
<ide> ],
<ide> [
<ide> 'current_timestamp',
<ide> ['type' => 'datetime', 'null' => false, 'default' => 'CURRENT_TIMESTAMP'],
<del> '"current_timestamp" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP'
<add> '"current_timestamp" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP',
<ide> ],
<ide> // Date & Time
<ide> [
<ide> 'start_date',
<ide> ['type' => 'date'],
<del> '"start_date" DATE'
<add> '"start_date" DATE',
<ide> ],
<ide> [
<ide> 'start_time',
<ide> ['type' => 'time'],
<del> '"start_time" TIME'
<add> '"start_time" TIME',
<ide> ],
<ide> // Timestamp
<ide> [
<ide> 'created',
<ide> ['type' => 'timestamp', 'null' => true],
<del> '"created" TIMESTAMP DEFAULT NULL'
<add> '"created" TIMESTAMP DEFAULT NULL',
<ide> ],
<ide> ];
<ide> }
<ide> public function testColumnSqlPrimaryKey()
<ide> $table = new TableSchema('schema_articles');
<ide> $table->addColumn('id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['id']
<add> 'columns' => ['id'],
<ide> ]);
<ide> $result = $schema->columnSql($table, 'id');
<ide> $this->assertEquals($result, '"id" SERIAL');
<ide> public static function constraintSqlProvider()
<ide> [
<ide> 'primary',
<ide> ['type' => 'primary', 'columns' => ['title']],
<del> 'PRIMARY KEY ("title")'
<add> 'PRIMARY KEY ("title")',
<ide> ],
<ide> [
<ide> 'unique_idx',
<ide> ['type' => 'unique', 'columns' => ['title', 'author_id']],
<del> 'CONSTRAINT "unique_idx" UNIQUE ("title", "author_id")'
<add> 'CONSTRAINT "unique_idx" UNIQUE ("title", "author_id")',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id']],
<ide> 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
<del> 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT DEFERRABLE INITIALLY IMMEDIATE'
<add> 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT DEFERRABLE INITIALLY IMMEDIATE',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'cascade'],
<ide> 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
<del> 'REFERENCES "authors" ("id") ON UPDATE CASCADE ON DELETE RESTRICT DEFERRABLE INITIALLY IMMEDIATE'
<add> 'REFERENCES "authors" ("id") ON UPDATE CASCADE ON DELETE RESTRICT DEFERRABLE INITIALLY IMMEDIATE',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'restrict'],
<ide> 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
<del> 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT DEFERRABLE INITIALLY IMMEDIATE'
<add> 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT DEFERRABLE INITIALLY IMMEDIATE',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'setNull'],
<ide> 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
<del> 'REFERENCES "authors" ("id") ON UPDATE SET NULL ON DELETE RESTRICT DEFERRABLE INITIALLY IMMEDIATE'
<add> 'REFERENCES "authors" ("id") ON UPDATE SET NULL ON DELETE RESTRICT DEFERRABLE INITIALLY IMMEDIATE',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'noAction'],
<ide> 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
<del> 'REFERENCES "authors" ("id") ON UPDATE NO ACTION ON DELETE RESTRICT DEFERRABLE INITIALLY IMMEDIATE'
<add> 'REFERENCES "authors" ("id") ON UPDATE NO ACTION ON DELETE RESTRICT DEFERRABLE INITIALLY IMMEDIATE',
<ide> ],
<ide> ];
<ide> }
<ide> public function testConstraintSql($name, $data, $expected)
<ide>
<ide> $table = (new TableSchema('schema_articles'))->addColumn('title', [
<ide> 'type' => 'string',
<del> 'length' => 255
<add> 'length' => 255,
<ide> ])->addColumn('author_id', [
<ide> 'type' => 'integer',
<ide> ])->addConstraint($name, $data);
<ide> public function testAddConstraintSql()
<ide> $table = (new TableSchema('posts'))
<ide> ->addColumn('author_id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('category_id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('category_name', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addConstraint('author_fk', [
<ide> 'type' => 'foreign',
<ide> 'columns' => ['author_id'],
<ide> 'references' => ['authors', 'id'],
<ide> 'update' => 'cascade',
<del> 'delete' => 'cascade'
<add> 'delete' => 'cascade',
<ide> ])
<ide> ->addConstraint('category_fk', [
<ide> 'type' => 'foreign',
<ide> 'columns' => ['category_id', 'category_name'],
<ide> 'references' => ['categories', ['id', 'name']],
<ide> 'update' => 'cascade',
<del> 'delete' => 'cascade'
<add> 'delete' => 'cascade',
<ide> ]);
<ide>
<ide> $expected = [
<ide> 'ALTER TABLE "posts" ADD CONSTRAINT "author_fk" FOREIGN KEY ("author_id") REFERENCES "authors" ("id") ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY IMMEDIATE;',
<del> 'ALTER TABLE "posts" ADD CONSTRAINT "category_fk" FOREIGN KEY ("category_id", "category_name") REFERENCES "categories" ("id", "name") ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY IMMEDIATE;'
<add> 'ALTER TABLE "posts" ADD CONSTRAINT "category_fk" FOREIGN KEY ("category_id", "category_name") REFERENCES "categories" ("id", "name") ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY IMMEDIATE;',
<ide> ];
<ide> $result = $table->addConstraintSql($connection);
<ide> $this->assertCount(2, $result);
<ide> public function testDropConstraintSql()
<ide> $table = (new TableSchema('posts'))
<ide> ->addColumn('author_id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('category_id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('category_name', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addConstraint('author_fk', [
<ide> 'type' => 'foreign',
<ide> 'columns' => ['author_id'],
<ide> 'references' => ['authors', 'id'],
<ide> 'update' => 'cascade',
<del> 'delete' => 'cascade'
<add> 'delete' => 'cascade',
<ide> ])
<ide> ->addConstraint('category_fk', [
<ide> 'type' => 'foreign',
<ide> 'columns' => ['category_id', 'category_name'],
<ide> 'references' => ['categories', ['id', 'name']],
<ide> 'update' => 'cascade',
<del> 'delete' => 'cascade'
<add> 'delete' => 'cascade',
<ide> ]);
<ide>
<ide> $expected = [
<ide> 'ALTER TABLE "posts" DROP CONSTRAINT "author_fk";',
<del> 'ALTER TABLE "posts" DROP CONSTRAINT "category_fk";'
<add> 'ALTER TABLE "posts" DROP CONSTRAINT "category_fk";',
<ide> ];
<ide> $result = $table->dropConstraintSql($connection);
<ide> $this->assertCount(2, $result);
<ide> public function testCreateSql()
<ide>
<ide> $table = (new TableSchema('schema_articles'))->addColumn('id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('title', [
<ide> 'type' => 'string',
<ide> public function testCreateTemporary()
<ide> ->will($this->returnValue($driver));
<ide> $table = (new TableSchema('schema_articles'))->addColumn('id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ]);
<ide> $table->setTemporary(true);
<ide> $sql = $table->createSql($connection);
<ide> public function testCreateSqlCompositeIntegerKey()
<ide> $table = (new TableSchema('articles_tags'))
<ide> ->addColumn('article_id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('tag_id', [
<ide> 'type' => 'integer',
<ide> 'null' => false,
<ide> ])
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['article_id', 'tag_id']
<add> 'columns' => ['article_id', 'tag_id'],
<ide> ]);
<ide>
<ide> $expected = <<<SQL
<ide> public function testCreateSqlCompositeIntegerKey()
<ide> ->addColumn('id', [
<ide> 'type' => 'integer',
<ide> 'null' => false,
<del> 'autoIncrement' => true
<add> 'autoIncrement' => true,
<ide> ])
<ide> ->addColumn('account_id', [
<ide> 'type' => 'integer',
<ide> 'null' => false,
<ide> ])
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['id', 'account_id']
<add> 'columns' => ['id', 'account_id'],
<ide> ]);
<ide>
<ide> $expected = <<<SQL
<ide> public function testTruncateSql()
<ide> $table->addColumn('id', 'integer')
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['id']
<add> 'columns' => ['id'],
<ide> ]);
<ide> $result = $table->truncateSql($connection);
<ide> $this->assertCount(1, $result);
<ide><path>tests/TestCase/Database/Schema/SqliteSchemaTest.php
<ide> public static function convertColumnProvider()
<ide> return [
<ide> [
<ide> 'DATETIME',
<del> ['type' => 'datetime', 'length' => null]
<add> ['type' => 'datetime', 'length' => null],
<ide> ],
<ide> [
<ide> 'DATE',
<del> ['type' => 'date', 'length' => null]
<add> ['type' => 'date', 'length' => null],
<ide> ],
<ide> [
<ide> 'TIME',
<del> ['type' => 'time', 'length' => null]
<add> ['type' => 'time', 'length' => null],
<ide> ],
<ide> [
<ide> 'BOOLEAN',
<del> ['type' => 'boolean', 'length' => null]
<add> ['type' => 'boolean', 'length' => null],
<ide> ],
<ide> [
<ide> 'BIGINT',
<del> ['type' => 'biginteger', 'length' => null, 'unsigned' => false]
<add> ['type' => 'biginteger', 'length' => null, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'UNSIGNED BIGINT',
<del> ['type' => 'biginteger', 'length' => null, 'unsigned' => true]
<add> ['type' => 'biginteger', 'length' => null, 'unsigned' => true],
<ide> ],
<ide> [
<ide> 'VARCHAR(255)',
<del> ['type' => 'string', 'length' => 255]
<add> ['type' => 'string', 'length' => 255],
<ide> ],
<ide> [
<ide> 'CHAR(25)',
<del> ['type' => 'string', 'fixed' => true, 'length' => 25]
<add> ['type' => 'string', 'fixed' => true, 'length' => 25],
<ide> ],
<ide> [
<ide> 'CHAR(36)',
<del> ['type' => 'uuid', 'length' => null]
<add> ['type' => 'uuid', 'length' => null],
<ide> ],
<ide> [
<ide> 'BINARY(16)',
<del> ['type' => 'binaryuuid', 'length' => null]
<add> ['type' => 'binaryuuid', 'length' => null],
<ide> ],
<ide> [
<ide> 'BINARY(1)',
<del> ['type' => 'binary', 'length' => 1]
<add> ['type' => 'binary', 'length' => 1],
<ide> ],
<ide> [
<ide> 'BLOB',
<del> ['type' => 'binary', 'length' => null]
<add> ['type' => 'binary', 'length' => null],
<ide> ],
<ide> [
<ide> 'INTEGER(11)',
<del> ['type' => 'integer', 'length' => 11, 'unsigned' => false]
<add> ['type' => 'integer', 'length' => 11, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'UNSIGNED INTEGER(11)',
<del> ['type' => 'integer', 'length' => 11, 'unsigned' => true]
<add> ['type' => 'integer', 'length' => 11, 'unsigned' => true],
<ide> ],
<ide> [
<ide> 'TINYINT(3)',
<del> ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => false]
<add> ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'UNSIGNED TINYINT(3)',
<del> ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => true]
<add> ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => true],
<ide> ],
<ide> [
<ide> 'SMALLINT(5)',
<del> ['type' => 'smallinteger', 'length' => 5, 'unsigned' => false]
<add> ['type' => 'smallinteger', 'length' => 5, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'UNSIGNED SMALLINT(5)',
<del> ['type' => 'smallinteger', 'length' => 5, 'unsigned' => true]
<add> ['type' => 'smallinteger', 'length' => 5, 'unsigned' => true],
<ide> ],
<ide> [
<ide> 'MEDIUMINT(10)',
<del> ['type' => 'integer', 'length' => 10, 'unsigned' => false]
<add> ['type' => 'integer', 'length' => 10, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'FLOAT',
<del> ['type' => 'float', 'length' => null, 'precision' => null, 'unsigned' => false]
<add> ['type' => 'float', 'length' => null, 'precision' => null, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'DOUBLE',
<del> ['type' => 'float', 'length' => null, 'precision' => null, 'unsigned' => false]
<add> ['type' => 'float', 'length' => null, 'precision' => null, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'UNSIGNED DOUBLE',
<del> ['type' => 'float', 'length' => null, 'precision' => null, 'unsigned' => true]
<add> ['type' => 'float', 'length' => null, 'precision' => null, 'unsigned' => true],
<ide> ],
<ide> [
<ide> 'REAL',
<del> ['type' => 'float', 'length' => null, 'precision' => null, 'unsigned' => false]
<add> ['type' => 'float', 'length' => null, 'precision' => null, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'DECIMAL(11,2)',
<del> ['type' => 'decimal', 'length' => 11, 'precision' => 2, 'unsigned' => false]
<add> ['type' => 'decimal', 'length' => 11, 'precision' => 2, 'unsigned' => false],
<ide> ],
<ide> [
<ide> 'UNSIGNED DECIMAL(11,2)',
<del> ['type' => 'decimal', 'length' => 11, 'precision' => 2, 'unsigned' => true]
<add> ['type' => 'decimal', 'length' => 11, 'precision' => 2, 'unsigned' => true],
<ide> ],
<ide> ];
<ide> }
<ide> public function testDescribeTableIndexes()
<ide> 'primary' => [
<ide> 'type' => 'primary',
<ide> 'columns' => ['id'],
<del> 'length' => []
<add> 'length' => [],
<ide> ],
<ide> 'sqlite_autoindex_schema_articles_1' => [
<ide> 'type' => 'unique',
<ide> 'columns' => ['title', 'body'],
<del> 'length' => []
<add> 'length' => [],
<ide> ],
<ide> 'author_id_fk' => [
<ide> 'type' => 'foreign',
<ide> public function testDescribeTableIndexes()
<ide> 'length' => [],
<ide> 'update' => 'cascade',
<ide> 'delete' => 'restrict',
<del> ]
<add> ],
<ide> ];
<ide> $this->assertCount(3, $result->constraints());
<ide> $this->assertEquals($expected['primary'], $result->getConstraint('primary'));
<ide> public function testDescribeTableIndexes()
<ide> $expected = [
<ide> 'type' => 'index',
<ide> 'columns' => ['created'],
<del> 'length' => []
<add> 'length' => [],
<ide> ];
<ide> $this->assertEquals($expected, $result->getIndex('created_idx'));
<ide> }
<ide> public static function columnSqlProvider()
<ide> [
<ide> 'title',
<ide> ['type' => 'string', 'length' => 25, 'null' => false],
<del> '"title" VARCHAR(25) NOT NULL'
<add> '"title" VARCHAR(25) NOT NULL',
<ide> ],
<ide> [
<ide> 'title',
<ide> public static function columnSqlProvider()
<ide> [
<ide> 'id',
<ide> ['type' => 'string', 'length' => 32, 'fixed' => true, 'null' => false],
<del> '"id" VARCHAR(32) NOT NULL'
<add> '"id" VARCHAR(32) NOT NULL',
<ide> ],
<ide> [
<ide> 'role',
<ide> ['type' => 'string', 'length' => 10, 'null' => false, 'default' => 'admin'],
<del> '"role" VARCHAR(10) NOT NULL DEFAULT "admin"'
<add> '"role" VARCHAR(10) NOT NULL DEFAULT "admin"',
<ide> ],
<ide> [
<ide> 'title',
<ide> ['type' => 'string'],
<del> '"title" VARCHAR'
<add> '"title" VARCHAR',
<ide> ],
<ide> [
<ide> 'id',
<ide> ['type' => 'uuid'],
<del> '"id" CHAR(36)'
<add> '"id" CHAR(36)',
<ide> ],
<ide> [
<ide> 'id',
<ide> ['type' => 'binaryuuid'],
<del> '"id" BINARY(16)'
<add> '"id" BINARY(16)',
<ide> ],
<ide> // Text
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'null' => false],
<del> '"body" TEXT NOT NULL'
<add> '"body" TEXT NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'length' => TableSchema::LENGTH_TINY, 'null' => false],
<del> '"body" VARCHAR(' . TableSchema::LENGTH_TINY . ') NOT NULL'
<add> '"body" VARCHAR(' . TableSchema::LENGTH_TINY . ') NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'length' => TableSchema::LENGTH_MEDIUM, 'null' => false],
<del> '"body" TEXT NOT NULL'
<add> '"body" TEXT NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'length' => TableSchema::LENGTH_LONG, 'null' => false],
<del> '"body" TEXT NOT NULL'
<add> '"body" TEXT NOT NULL',
<ide> ],
<ide> // Integers
<ide> [
<ide> 'post_id',
<ide> ['type' => 'smallinteger', 'length' => 5, 'unsigned' => false],
<del> '"post_id" SMALLINT(5)'
<add> '"post_id" SMALLINT(5)',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'smallinteger', 'length' => 5, 'unsigned' => true],
<del> '"post_id" UNSIGNED SMALLINT(5)'
<add> '"post_id" UNSIGNED SMALLINT(5)',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => false],
<del> '"post_id" TINYINT(3)'
<add> '"post_id" TINYINT(3)',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => true],
<del> '"post_id" UNSIGNED TINYINT(3)'
<add> '"post_id" UNSIGNED TINYINT(3)',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'integer', 'length' => 11, 'unsigned' => false],
<del> '"post_id" INTEGER(11)'
<add> '"post_id" INTEGER(11)',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'biginteger', 'length' => 20, 'unsigned' => false],
<del> '"post_id" BIGINT'
<add> '"post_id" BIGINT',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'biginteger', 'length' => 20, 'unsigned' => true],
<del> '"post_id" UNSIGNED BIGINT'
<add> '"post_id" UNSIGNED BIGINT',
<ide> ],
<ide> // Decimal
<ide> [
<ide> 'value',
<ide> ['type' => 'decimal', 'unsigned' => false],
<del> '"value" DECIMAL'
<add> '"value" DECIMAL',
<ide> ],
<ide> [
<ide> 'value',
<ide> ['type' => 'decimal', 'length' => 11, 'unsigned' => false],
<del> '"value" DECIMAL(11,0)'
<add> '"value" DECIMAL(11,0)',
<ide> ],
<ide> [
<ide> 'value',
<ide> ['type' => 'decimal', 'length' => 11, 'unsigned' => true],
<del> '"value" UNSIGNED DECIMAL(11,0)'
<add> '"value" UNSIGNED DECIMAL(11,0)',
<ide> ],
<ide> [
<ide> 'value',
<ide> ['type' => 'decimal', 'length' => 12, 'precision' => 5, 'unsigned' => false],
<del> '"value" DECIMAL(12,5)'
<add> '"value" DECIMAL(12,5)',
<ide> ],
<ide> // Float
<ide> [
<ide> 'value',
<ide> ['type' => 'float'],
<del> '"value" FLOAT'
<add> '"value" FLOAT',
<ide> ],
<ide> [
<ide> 'value',
<ide> ['type' => 'float', 'length' => 11, 'precision' => 3, 'unsigned' => false],
<del> '"value" FLOAT(11,3)'
<add> '"value" FLOAT(11,3)',
<ide> ],
<ide> [
<ide> 'value',
<ide> ['type' => 'float', 'length' => 11, 'precision' => 3, 'unsigned' => true],
<del> '"value" UNSIGNED FLOAT(11,3)'
<add> '"value" UNSIGNED FLOAT(11,3)',
<ide> ],
<ide> // Boolean
<ide> [
<ide> 'checked',
<ide> ['type' => 'boolean', 'null' => true, 'default' => false],
<del> '"checked" BOOLEAN DEFAULT FALSE'
<add> '"checked" BOOLEAN DEFAULT FALSE',
<ide> ],
<ide> [
<ide> 'checked',
<ide> ['type' => 'boolean', 'default' => true, 'null' => false],
<del> '"checked" BOOLEAN NOT NULL DEFAULT TRUE'
<add> '"checked" BOOLEAN NOT NULL DEFAULT TRUE',
<ide> ],
<ide> // datetimes
<ide> [
<ide> 'created',
<ide> ['type' => 'datetime'],
<del> '"created" DATETIME'
<add> '"created" DATETIME',
<ide> ],
<ide> [
<ide> 'open_date',
<ide> ['type' => 'datetime', 'null' => false, 'default' => '2016-12-07 23:04:00'],
<del> '"open_date" DATETIME NOT NULL DEFAULT "2016-12-07 23:04:00"'
<add> '"open_date" DATETIME NOT NULL DEFAULT "2016-12-07 23:04:00"',
<ide> ],
<ide> // Date & Time
<ide> [
<ide> 'start_date',
<ide> ['type' => 'date'],
<del> '"start_date" DATE'
<add> '"start_date" DATE',
<ide> ],
<ide> [
<ide> 'start_time',
<ide> ['type' => 'time'],
<del> '"start_time" TIME'
<add> '"start_time" TIME',
<ide> ],
<ide> // timestamps
<ide> [
<ide> 'created',
<ide> ['type' => 'timestamp', 'null' => true],
<del> '"created" TIMESTAMP DEFAULT NULL'
<add> '"created" TIMESTAMP DEFAULT NULL',
<ide> ],
<ide> ];
<ide> }
<ide> public function testColumnSqlPrimaryKey()
<ide> 'type' => 'integer',
<ide> 'null' => false,
<ide> 'length' => 11,
<del> 'unsigned' => true
<add> 'unsigned' => true,
<ide> ])
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['id']
<add> 'columns' => ['id'],
<ide> ]);
<ide> $result = $schema->columnSql($table, 'id');
<ide> $this->assertEquals($result, '"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT');
<ide> public function testColumnSqlPrimaryKeyBigInt()
<ide> $table = new TableSchema('articles');
<ide> $table->addColumn('id', [
<ide> 'type' => 'biginteger',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['id']
<add> 'columns' => ['id'],
<ide> ]);
<ide> $result = $schema->columnSql($table, 'id');
<ide> $this->assertEquals($result, '"id" BIGINT NOT NULL');
<ide> public static function constraintSqlProvider()
<ide> [
<ide> 'primary',
<ide> ['type' => 'primary', 'columns' => ['title']],
<del> 'CONSTRAINT "primary" PRIMARY KEY ("title")'
<add> 'CONSTRAINT "primary" PRIMARY KEY ("title")',
<ide> ],
<ide> [
<ide> 'unique_idx',
<ide> ['type' => 'unique', 'columns' => ['title', 'author_id']],
<del> 'CONSTRAINT "unique_idx" UNIQUE ("title", "author_id")'
<add> 'CONSTRAINT "unique_idx" UNIQUE ("title", "author_id")',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id']],
<ide> 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
<del> 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT'
<add> 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'cascade'],
<ide> 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
<del> 'REFERENCES "authors" ("id") ON UPDATE CASCADE ON DELETE RESTRICT'
<add> 'REFERENCES "authors" ("id") ON UPDATE CASCADE ON DELETE RESTRICT',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'restrict'],
<ide> 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
<del> 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT'
<add> 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'setNull'],
<ide> 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
<del> 'REFERENCES "authors" ("id") ON UPDATE SET NULL ON DELETE RESTRICT'
<add> 'REFERENCES "authors" ("id") ON UPDATE SET NULL ON DELETE RESTRICT',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'noAction'],
<ide> 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
<del> 'REFERENCES "authors" ("id") ON UPDATE NO ACTION ON DELETE RESTRICT'
<add> 'REFERENCES "authors" ("id") ON UPDATE NO ACTION ON DELETE RESTRICT',
<ide> ],
<ide> ];
<ide> }
<ide> public function testConstraintSql($name, $data, $expected)
<ide>
<ide> $table = (new TableSchema('articles'))->addColumn('title', [
<ide> 'type' => 'string',
<del> 'length' => 255
<add> 'length' => 255,
<ide> ])->addColumn('author_id', [
<ide> 'type' => 'integer',
<ide> ])->addConstraint($name, $data);
<ide> public static function indexSqlProvider()
<ide> [
<ide> 'author_idx',
<ide> ['type' => 'index', 'columns' => ['title', 'author_id']],
<del> 'CREATE INDEX "author_idx" ON "articles" ("title", "author_id")'
<add> 'CREATE INDEX "author_idx" ON "articles" ("title", "author_id")',
<ide> ],
<ide> ];
<ide> }
<ide> public function testIndexSql($name, $data, $expected)
<ide>
<ide> $table = (new TableSchema('articles'))->addColumn('title', [
<ide> 'type' => 'string',
<del> 'length' => 255
<add> 'length' => 255,
<ide> ])->addColumn('author_id', [
<ide> 'type' => 'integer',
<ide> ])->addIndex($name, $data);
<ide> public function testCreateSql()
<ide>
<ide> $table = (new TableSchema('articles'))->addColumn('id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('title', [
<ide> 'type' => 'string',
<ide> public function testCreateSql()
<ide> ->addColumn('created', 'datetime')
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['id']
<add> 'columns' => ['id'],
<ide> ])
<ide> ->addIndex('title_idx', [
<ide> 'type' => 'index',
<del> 'columns' => ['title']
<add> 'columns' => ['title'],
<ide> ]);
<ide>
<ide> $expected = <<<SQL
<ide> public function testCreateTemporary()
<ide> ->will($this->returnValue($driver));
<ide> $table = (new TableSchema('schema_articles'))->addColumn('id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ]);
<ide> $table->setTemporary(true);
<ide> $sql = $table->createSql($connection);
<ide> public function testCreateSqlCompositeIntegerKey()
<ide> $table = (new TableSchema('articles_tags'))
<ide> ->addColumn('article_id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('tag_id', [
<ide> 'type' => 'integer',
<ide> 'null' => false,
<ide> ])
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['article_id', 'tag_id']
<add> 'columns' => ['article_id', 'tag_id'],
<ide> ]);
<ide>
<ide> $expected = <<<SQL
<ide> public function testCreateSqlCompositeIntegerKey()
<ide> ->addColumn('id', [
<ide> 'type' => 'integer',
<ide> 'null' => false,
<del> 'autoIncrement' => true
<add> 'autoIncrement' => true,
<ide> ])
<ide> ->addColumn('account_id', [
<ide> 'type' => 'integer',
<ide> 'null' => false,
<ide> ])
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['id', 'account_id']
<add> 'columns' => ['id', 'account_id'],
<ide> ]);
<ide>
<ide> $expected = <<<SQL
<ide><path>tests/TestCase/Database/Schema/SqlserverSchemaTest.php
<ide> public static function convertColumnProvider()
<ide> null,
<ide> null,
<ide> null,
<del> ['type' => 'timestamp', 'length' => null]
<add> ['type' => 'timestamp', 'length' => null],
<ide> ],
<ide> [
<ide> 'DATE',
<ide> null,
<ide> null,
<ide> null,
<del> ['type' => 'date', 'length' => null]
<add> ['type' => 'date', 'length' => null],
<ide> ],
<ide> [
<ide> 'TIME',
<ide> null,
<ide> null,
<ide> null,
<del> ['type' => 'time', 'length' => null]
<add> ['type' => 'time', 'length' => null],
<ide> ],
<ide> [
<ide> 'TINYINT',
<ide> null,
<ide> 2,
<ide> null,
<del> ['type' => 'tinyinteger', 'length' => 2]
<add> ['type' => 'tinyinteger', 'length' => 2],
<ide> ],
<ide> [
<ide> 'TINYINT',
<ide> null,
<ide> null,
<ide> null,
<del> ['type' => 'tinyinteger', 'length' => 3]
<add> ['type' => 'tinyinteger', 'length' => 3],
<ide> ],
<ide> [
<ide> 'SMALLINT',
<ide> null,
<ide> 3,
<ide> null,
<del> ['type' => 'smallinteger', 'length' => 3]
<add> ['type' => 'smallinteger', 'length' => 3],
<ide> ],
<ide> [
<ide> 'SMALLINT',
<ide> null,
<ide> null,
<ide> null,
<del> ['type' => 'smallinteger', 'length' => 5]
<add> ['type' => 'smallinteger', 'length' => 5],
<ide> ],
<ide> [
<ide> 'INTEGER',
<ide> null,
<ide> null,
<ide> null,
<del> ['type' => 'integer', 'length' => 10]
<add> ['type' => 'integer', 'length' => 10],
<ide> ],
<ide> [
<ide> 'INTEGER',
<ide> null,
<ide> 8,
<ide> null,
<del> ['type' => 'integer', 'length' => 8]
<add> ['type' => 'integer', 'length' => 8],
<ide> ],
<ide> [
<ide> 'BIGINT',
<ide> null,
<ide> null,
<ide> null,
<del> ['type' => 'biginteger', 'length' => 20]
<add> ['type' => 'biginteger', 'length' => 20],
<ide> ],
<ide> [
<ide> 'NUMERIC',
<ide> null,
<ide> 15,
<ide> 5,
<del> ['type' => 'decimal', 'length' => 15, 'precision' => 5]
<add> ['type' => 'decimal', 'length' => 15, 'precision' => 5],
<ide> ],
<ide> [
<ide> 'DECIMAL',
<ide> null,
<ide> 11,
<ide> 3,
<del> ['type' => 'decimal', 'length' => 11, 'precision' => 3]
<add> ['type' => 'decimal', 'length' => 11, 'precision' => 3],
<ide> ],
<ide> [
<ide> 'MONEY',
<ide> null,
<ide> null,
<ide> null,
<del> ['type' => 'decimal', 'length' => null, 'precision' => null]
<add> ['type' => 'decimal', 'length' => null, 'precision' => null],
<ide> ],
<ide> [
<ide> 'VARCHAR',
<ide> null,
<ide> null,
<ide> null,
<del> ['type' => 'string', 'length' => 255, 'collate' => 'Japanese_Unicode_CI_AI']
<add> ['type' => 'string', 'length' => 255, 'collate' => 'Japanese_Unicode_CI_AI'],
<ide> ],
<ide> [
<ide> 'VARCHAR',
<ide> 10,
<ide> null,
<ide> null,
<del> ['type' => 'string', 'length' => 10, 'collate' => 'Japanese_Unicode_CI_AI']
<add> ['type' => 'string', 'length' => 10, 'collate' => 'Japanese_Unicode_CI_AI'],
<ide> ],
<ide> [
<ide> 'NVARCHAR',
<ide> 50,
<ide> null,
<ide> null,
<ide> // Sqlserver returns double lengths for unicode columns
<del> ['type' => 'string', 'length' => 25, 'collate' => 'Japanese_Unicode_CI_AI']
<add> ['type' => 'string', 'length' => 25, 'collate' => 'Japanese_Unicode_CI_AI'],
<ide> ],
<ide> [
<ide> 'CHAR',
<ide> 10,
<ide> null,
<ide> null,
<del> ['type' => 'string', 'fixed' => true, 'length' => 10, 'collate' => 'Japanese_Unicode_CI_AI']
<add> ['type' => 'string', 'fixed' => true, 'length' => 10, 'collate' => 'Japanese_Unicode_CI_AI'],
<ide> ],
<ide> [
<ide> 'NCHAR',
<ide> 10,
<ide> null,
<ide> null,
<ide> // SQLServer returns double length for unicode columns.
<del> ['type' => 'string', 'fixed' => true, 'length' => 5, 'collate' => 'Japanese_Unicode_CI_AI']
<add> ['type' => 'string', 'fixed' => true, 'length' => 5, 'collate' => 'Japanese_Unicode_CI_AI'],
<ide> ],
<ide> [
<ide> 'UNIQUEIDENTIFIER',
<ide> null,
<ide> null,
<ide> null,
<del> ['type' => 'uuid']
<add> ['type' => 'uuid'],
<ide> ],
<ide> [
<ide> 'TEXT',
<ide> null,
<ide> null,
<ide> null,
<del> ['type' => 'text', 'length' => null, 'collate' => 'Japanese_Unicode_CI_AI']
<add> ['type' => 'text', 'length' => null, 'collate' => 'Japanese_Unicode_CI_AI'],
<ide> ],
<ide> [
<ide> 'REAL',
<ide> null,
<ide> null,
<ide> null,
<del> ['type' => 'float', 'length' => null]
<add> ['type' => 'float', 'length' => null],
<ide> ],
<ide> [
<ide> 'VARCHAR',
<ide> -1,
<ide> null,
<ide> null,
<del> ['type' => 'text', 'length' => null, 'collate' => 'Japanese_Unicode_CI_AI']
<add> ['type' => 'text', 'length' => null, 'collate' => 'Japanese_Unicode_CI_AI'],
<ide> ],
<ide> [
<ide> 'IMAGE',
<ide> 10,
<ide> null,
<ide> null,
<del> ['type' => 'binary', 'length' => 10]
<add> ['type' => 'binary', 'length' => 10],
<ide> ],
<ide> [
<ide> 'BINARY',
<ide> 20,
<ide> null,
<ide> null,
<del> ['type' => 'binary', 'length' => 20]
<add> ['type' => 'binary', 'length' => 20],
<ide> ],
<ide> [
<ide> 'VARBINARY',
<ide> 30,
<ide> null,
<ide> null,
<del> ['type' => 'binary', 'length' => 30]
<add> ['type' => 'binary', 'length' => 30],
<ide> ],
<ide> [
<ide> 'VARBINARY',
<ide> -1,
<ide> null,
<ide> null,
<del> ['type' => 'binary', 'length' => TableSchema::LENGTH_LONG]
<add> ['type' => 'binary', 'length' => TableSchema::LENGTH_LONG],
<ide> ],
<ide> ];
<ide> }
<ide> public function testDescribeTableIndexes()
<ide> 'primary' => [
<ide> 'type' => 'primary',
<ide> 'columns' => ['id'],
<del> 'length' => []
<add> 'length' => [],
<ide> ],
<ide> 'content_idx' => [
<ide> 'type' => 'unique',
<ide> 'columns' => ['title', 'body'],
<del> 'length' => []
<add> 'length' => [],
<ide> ],
<ide> 'author_idx' => [
<ide> 'type' => 'foreign',
<ide> public function testDescribeTableIndexes()
<ide> 'length' => [],
<ide> 'update' => 'cascade',
<ide> 'delete' => 'cascade',
<del> ]
<add> ],
<ide> ];
<ide> $this->assertEquals($expected['primary'], $result->getConstraint('primary'));
<ide> $this->assertEquals($expected['content_idx'], $result->getConstraint('content_idx'));
<ide> public function testDescribeTableIndexes()
<ide> $expected = [
<ide> 'type' => 'index',
<ide> 'columns' => ['author_id'],
<del> 'length' => []
<add> 'length' => [],
<ide> ];
<ide> $this->assertEquals($expected, $result->getIndex('author_idx'));
<ide> }
<ide> public static function columnSqlProvider()
<ide> [
<ide> 'title',
<ide> ['type' => 'string', 'length' => 25, 'null' => false],
<del> '[title] NVARCHAR(25) NOT NULL'
<add> '[title] NVARCHAR(25) NOT NULL',
<ide> ],
<ide> [
<ide> 'title',
<ide> ['type' => 'string', 'length' => 25, 'null' => true, 'default' => 'ignored'],
<del> "[title] NVARCHAR(25) DEFAULT 'ignored'"
<add> "[title] NVARCHAR(25) DEFAULT 'ignored'",
<ide> ],
<ide> [
<ide> 'id',
<ide> ['type' => 'string', 'length' => 32, 'fixed' => true, 'null' => false],
<del> '[id] NCHAR(32) NOT NULL'
<add> '[id] NCHAR(32) NOT NULL',
<ide> ],
<ide> [
<ide> 'id',
<ide> ['type' => 'uuid', 'null' => false],
<del> '[id] UNIQUEIDENTIFIER NOT NULL'
<add> '[id] UNIQUEIDENTIFIER NOT NULL',
<ide> ],
<ide> [
<ide> 'id',
<ide> ['type' => 'binaryuuid', 'null' => false],
<del> '[id] UNIQUEIDENTIFIER NOT NULL'
<add> '[id] UNIQUEIDENTIFIER NOT NULL',
<ide> ],
<ide> [
<ide> 'role',
<ide> ['type' => 'string', 'length' => 10, 'null' => false, 'default' => 'admin'],
<del> "[role] NVARCHAR(10) NOT NULL DEFAULT 'admin'"
<add> "[role] NVARCHAR(10) NOT NULL DEFAULT 'admin'",
<ide> ],
<ide> [
<ide> 'title',
<ide> ['type' => 'string'],
<del> '[title] NVARCHAR(255)'
<add> '[title] NVARCHAR(255)',
<ide> ],
<ide> [
<ide> 'title',
<ide> ['type' => 'string', 'length' => 25, 'null' => false, 'collate' => 'Japanese_Unicode_CI_AI'],
<del> '[title] NVARCHAR(25) COLLATE Japanese_Unicode_CI_AI NOT NULL'
<add> '[title] NVARCHAR(25) COLLATE Japanese_Unicode_CI_AI NOT NULL',
<ide> ],
<ide> // Text
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'null' => false],
<del> '[body] NVARCHAR(MAX) NOT NULL'
<add> '[body] NVARCHAR(MAX) NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'length' => TableSchema::LENGTH_TINY, 'null' => false],
<del> sprintf('[body] NVARCHAR(%s) NOT NULL', TableSchema::LENGTH_TINY)
<add> sprintf('[body] NVARCHAR(%s) NOT NULL', TableSchema::LENGTH_TINY),
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'length' => TableSchema::LENGTH_MEDIUM, 'null' => false],
<del> '[body] NVARCHAR(MAX) NOT NULL'
<add> '[body] NVARCHAR(MAX) NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'length' => TableSchema::LENGTH_LONG, 'null' => false],
<del> '[body] NVARCHAR(MAX) NOT NULL'
<add> '[body] NVARCHAR(MAX) NOT NULL',
<ide> ],
<ide> [
<ide> 'body',
<ide> ['type' => 'text', 'null' => false, 'collate' => 'Japanese_Unicode_CI_AI'],
<del> '[body] NVARCHAR(MAX) COLLATE Japanese_Unicode_CI_AI NOT NULL'
<add> '[body] NVARCHAR(MAX) COLLATE Japanese_Unicode_CI_AI NOT NULL',
<ide> ],
<ide> // Integers
<ide> [
<ide> 'post_id',
<ide> ['type' => 'smallinteger', 'length' => 11],
<del> '[post_id] SMALLINT'
<add> '[post_id] SMALLINT',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'tinyinteger', 'length' => 11],
<del> '[post_id] TINYINT'
<add> '[post_id] TINYINT',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'integer', 'length' => 11],
<del> '[post_id] INTEGER'
<add> '[post_id] INTEGER',
<ide> ],
<ide> [
<ide> 'post_id',
<ide> ['type' => 'biginteger', 'length' => 20],
<del> '[post_id] BIGINT'
<add> '[post_id] BIGINT',
<ide> ],
<ide> // Decimal
<ide> [
<ide> 'value',
<ide> ['type' => 'decimal'],
<del> '[value] DECIMAL'
<add> '[value] DECIMAL',
<ide> ],
<ide> [
<ide> 'value',
<ide> ['type' => 'decimal', 'length' => 11],
<del> '[value] DECIMAL(11,0)'
<add> '[value] DECIMAL(11,0)',
<ide> ],
<ide> [
<ide> 'value',
<ide> ['type' => 'decimal', 'length' => 12, 'precision' => 5],
<del> '[value] DECIMAL(12,5)'
<add> '[value] DECIMAL(12,5)',
<ide> ],
<ide> // Float
<ide> [
<ide> 'value',
<ide> ['type' => 'float'],
<del> '[value] FLOAT'
<add> '[value] FLOAT',
<ide> ],
<ide> [
<ide> 'value',
<ide> ['type' => 'float', 'length' => 11, 'precision' => 3],
<del> '[value] FLOAT(3)'
<add> '[value] FLOAT(3)',
<ide> ],
<ide> // Binary
<ide> [
<ide> 'img',
<ide> ['type' => 'binary', 'length' => null],
<del> '[img] VARBINARY(MAX)'
<add> '[img] VARBINARY(MAX)',
<ide> ],
<ide> [
<ide> 'img',
<ide> ['type' => 'binary', 'length' => TableSchema::LENGTH_TINY],
<del> sprintf('[img] VARBINARY(%s)', TableSchema::LENGTH_TINY)
<add> sprintf('[img] VARBINARY(%s)', TableSchema::LENGTH_TINY),
<ide> ],
<ide> [
<ide> 'img',
<ide> ['type' => 'binary', 'length' => TableSchema::LENGTH_MEDIUM],
<del> '[img] VARBINARY(MAX)'
<add> '[img] VARBINARY(MAX)',
<ide> ],
<ide> [
<ide> 'img',
<ide> ['type' => 'binary', 'length' => TableSchema::LENGTH_LONG],
<del> '[img] VARBINARY(MAX)'
<add> '[img] VARBINARY(MAX)',
<ide> ],
<ide> [
<ide> 'bytes',
<ide> ['type' => 'binary', 'length' => 5],
<del> '[bytes] VARBINARY(5)'
<add> '[bytes] VARBINARY(5)',
<ide> ],
<ide> [
<ide> 'bytes',
<ide> ['type' => 'binary', 'length' => 1],
<del> '[bytes] BINARY(1)'
<add> '[bytes] BINARY(1)',
<ide> ],
<ide> // Boolean
<ide> [
<ide> 'checked',
<ide> ['type' => 'boolean', 'default' => false],
<del> '[checked] BIT DEFAULT 0'
<add> '[checked] BIT DEFAULT 0',
<ide> ],
<ide> [
<ide> 'checked',
<ide> ['type' => 'boolean', 'default' => true, 'null' => false],
<del> '[checked] BIT NOT NULL DEFAULT 1'
<add> '[checked] BIT NOT NULL DEFAULT 1',
<ide> ],
<ide> // Datetime
<ide> [
<ide> 'created',
<ide> ['type' => 'datetime'],
<del> '[created] DATETIME'
<add> '[created] DATETIME',
<ide> ],
<ide> [
<ide> 'open_date',
<ide> ['type' => 'datetime', 'null' => false, 'default' => '2016-12-07 23:04:00'],
<del> '[open_date] DATETIME NOT NULL DEFAULT \'2016-12-07 23:04:00\''
<add> '[open_date] DATETIME NOT NULL DEFAULT \'2016-12-07 23:04:00\'',
<ide> ],
<ide> [
<ide> 'open_date',
<ide> ['type' => 'datetime', 'null' => false, 'default' => 'current_timestamp'],
<del> '[open_date] DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP'
<add> '[open_date] DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
<ide> ],
<ide> [
<ide> 'null_date',
<ide> ['type' => 'datetime', 'null' => true, 'default' => 'current_timestamp'],
<del> '[null_date] DATETIME DEFAULT CURRENT_TIMESTAMP'
<add> '[null_date] DATETIME DEFAULT CURRENT_TIMESTAMP',
<ide> ],
<ide> [
<ide> 'null_date',
<ide> ['type' => 'datetime', 'null' => true],
<del> '[null_date] DATETIME DEFAULT NULL'
<add> '[null_date] DATETIME DEFAULT NULL',
<ide> ],
<ide> // Date & Time
<ide> [
<ide> 'start_date',
<ide> ['type' => 'date'],
<del> '[start_date] DATE'
<add> '[start_date] DATE',
<ide> ],
<ide> [
<ide> 'start_time',
<ide> ['type' => 'time'],
<del> '[start_time] TIME'
<add> '[start_time] TIME',
<ide> ],
<ide> // Timestamp
<ide> [
<ide> 'created',
<ide> ['type' => 'timestamp', 'null' => true],
<del> '[created] DATETIME DEFAULT NULL'
<add> '[created] DATETIME DEFAULT NULL',
<ide> ],
<ide> ];
<ide> }
<ide> public static function constraintSqlProvider()
<ide> [
<ide> 'primary',
<ide> ['type' => 'primary', 'columns' => ['title']],
<del> 'PRIMARY KEY ([title])'
<add> 'PRIMARY KEY ([title])',
<ide> ],
<ide> [
<ide> 'unique_idx',
<ide> ['type' => 'unique', 'columns' => ['title', 'author_id']],
<del> 'CONSTRAINT [unique_idx] UNIQUE ([title], [author_id])'
<add> 'CONSTRAINT [unique_idx] UNIQUE ([title], [author_id])',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id']],
<ide> 'CONSTRAINT [author_id_idx] FOREIGN KEY ([author_id]) ' .
<del> 'REFERENCES [authors] ([id]) ON UPDATE SET NULL ON DELETE SET NULL'
<add> 'REFERENCES [authors] ([id]) ON UPDATE SET NULL ON DELETE SET NULL',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'cascade'],
<ide> 'CONSTRAINT [author_id_idx] FOREIGN KEY ([author_id]) ' .
<del> 'REFERENCES [authors] ([id]) ON UPDATE CASCADE ON DELETE SET NULL'
<add> 'REFERENCES [authors] ([id]) ON UPDATE CASCADE ON DELETE SET NULL',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'setDefault'],
<ide> 'CONSTRAINT [author_id_idx] FOREIGN KEY ([author_id]) ' .
<del> 'REFERENCES [authors] ([id]) ON UPDATE SET DEFAULT ON DELETE SET NULL'
<add> 'REFERENCES [authors] ([id]) ON UPDATE SET DEFAULT ON DELETE SET NULL',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'setNull'],
<ide> 'CONSTRAINT [author_id_idx] FOREIGN KEY ([author_id]) ' .
<del> 'REFERENCES [authors] ([id]) ON UPDATE SET NULL ON DELETE SET NULL'
<add> 'REFERENCES [authors] ([id]) ON UPDATE SET NULL ON DELETE SET NULL',
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'noAction'],
<ide> 'CONSTRAINT [author_id_idx] FOREIGN KEY ([author_id]) ' .
<del> 'REFERENCES [authors] ([id]) ON UPDATE NO ACTION ON DELETE SET NULL'
<add> 'REFERENCES [authors] ([id]) ON UPDATE NO ACTION ON DELETE SET NULL',
<ide> ],
<ide> ];
<ide> }
<ide> public function testConstraintSql($name, $data, $expected)
<ide>
<ide> $table = (new TableSchema('schema_articles'))->addColumn('title', [
<ide> 'type' => 'string',
<del> 'length' => 255
<add> 'length' => 255,
<ide> ])->addColumn('author_id', [
<ide> 'type' => 'integer',
<ide> ])->addConstraint($name, $data);
<ide> public function testAddConstraintSql()
<ide> $table = (new TableSchema('posts'))
<ide> ->addColumn('author_id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('category_id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('category_name', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addConstraint('author_fk', [
<ide> 'type' => 'foreign',
<ide> 'columns' => ['author_id'],
<ide> 'references' => ['authors', 'id'],
<ide> 'update' => 'cascade',
<del> 'delete' => 'cascade'
<add> 'delete' => 'cascade',
<ide> ])
<ide> ->addConstraint('category_fk', [
<ide> 'type' => 'foreign',
<ide> 'columns' => ['category_id', 'category_name'],
<ide> 'references' => ['categories', ['id', 'name']],
<ide> 'update' => 'cascade',
<del> 'delete' => 'cascade'
<add> 'delete' => 'cascade',
<ide> ]);
<ide>
<ide> $expected = [
<ide> 'ALTER TABLE [posts] ADD CONSTRAINT [author_fk] FOREIGN KEY ([author_id]) REFERENCES [authors] ([id]) ON UPDATE CASCADE ON DELETE CASCADE;',
<del> 'ALTER TABLE [posts] ADD CONSTRAINT [category_fk] FOREIGN KEY ([category_id], [category_name]) REFERENCES [categories] ([id], [name]) ON UPDATE CASCADE ON DELETE CASCADE;'
<add> 'ALTER TABLE [posts] ADD CONSTRAINT [category_fk] FOREIGN KEY ([category_id], [category_name]) REFERENCES [categories] ([id], [name]) ON UPDATE CASCADE ON DELETE CASCADE;',
<ide> ];
<ide> $result = $table->addConstraintSql($connection);
<ide> $this->assertCount(2, $result);
<ide> public function testDropConstraintSql()
<ide> $table = (new TableSchema('posts'))
<ide> ->addColumn('author_id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('category_id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('category_name', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addConstraint('author_fk', [
<ide> 'type' => 'foreign',
<ide> 'columns' => ['author_id'],
<ide> 'references' => ['authors', 'id'],
<ide> 'update' => 'cascade',
<del> 'delete' => 'cascade'
<add> 'delete' => 'cascade',
<ide> ])
<ide> ->addConstraint('category_fk', [
<ide> 'type' => 'foreign',
<ide> 'columns' => ['category_id', 'category_name'],
<ide> 'references' => ['categories', ['id', 'name']],
<ide> 'update' => 'cascade',
<del> 'delete' => 'cascade'
<add> 'delete' => 'cascade',
<ide> ]);
<ide>
<ide> $expected = [
<ide> 'ALTER TABLE [posts] DROP CONSTRAINT [author_fk];',
<del> 'ALTER TABLE [posts] DROP CONSTRAINT [category_fk];'
<add> 'ALTER TABLE [posts] DROP CONSTRAINT [category_fk];',
<ide> ];
<ide> $result = $table->dropConstraintSql($connection);
<ide> $this->assertCount(2, $result);
<ide> public function testCreateSql()
<ide>
<ide> $table = (new TableSchema('schema_articles'))->addColumn('id', [
<ide> 'type' => 'integer',
<del> 'null' => false
<add> 'null' => false,
<ide> ])
<ide> ->addColumn('title', [
<ide> 'type' => 'string',
<ide> public function testTruncateSql()
<ide> $table->addColumn('id', 'integer')
<ide> ->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['id']
<add> 'columns' => ['id'],
<ide> ]);
<ide> $result = $table->truncateSql($connection);
<ide> $this->assertCount(2, $result);
<ide><path>tests/TestCase/Database/Schema/TableSchemaTest.php
<ide> class TableTest extends TestCase
<ide> 'core.Tags',
<ide> 'core.ArticlesTags',
<ide> 'core.Orders',
<del> 'core.Products'
<add> 'core.Products',
<ide> ];
<ide>
<ide> protected $_map;
<ide> public function testConstructWithColumns()
<ide> ],
<ide> 'title' => [
<ide> 'type' => 'string',
<del> 'length' => 255
<del> ]
<add> 'length' => 255,
<add> ],
<ide> ];
<ide> $table = new TableSchema('articles', $columns);
<ide> $this->assertEquals(['id', 'title'], $table->columns());
<ide> public function testAddColumn()
<ide> $result = $table->addColumn('title', [
<ide> 'type' => 'string',
<ide> 'length' => 25,
<del> 'null' => false
<add> 'null' => false,
<ide> ]);
<ide> $this->assertSame($table, $result);
<ide> $this->assertEquals(['title'], $table->columns());
<ide> public function testAddColumn()
<ide> public function testHasColumn()
<ide> {
<ide> $schema = new TableSchema('articles', [
<del> 'title' => 'string'
<add> 'title' => 'string',
<ide> ]);
<ide>
<ide> $this->assertTrue($schema->hasColumn('title'));
<ide> public function testRemoveColumn()
<ide> $result = $table->addColumn('title', [
<ide> 'type' => 'string',
<ide> 'length' => 25,
<del> 'null' => false
<add> 'null' => false,
<ide> ])->removeColumn('title')
<ide> ->removeColumn('unknown');
<ide>
<ide> public function testIsNullable()
<ide> $table->addColumn('title', [
<ide> 'type' => 'string',
<ide> 'length' => 25,
<del> 'null' => false
<add> 'null' => false,
<ide> ])->addColumn('tagline', [
<ide> 'type' => 'string',
<ide> 'length' => 25,
<del> 'null' => true
<add> 'null' => true,
<ide> ]);
<ide> $this->assertFalse($table->isNullable('title'));
<ide> $this->assertTrue($table->isNullable('tagline'));
<ide> public function testColumnType()
<ide> $table->addColumn('title', [
<ide> 'type' => 'string',
<ide> 'length' => 25,
<del> 'null' => false
<add> 'null' => false,
<ide> ]);
<ide> $this->assertEquals('string', $table->getColumnType('title'));
<ide> $this->assertNull($table->getColumnType('not there'));
<ide> public function testSetColumnType()
<ide> $table->addColumn('title', [
<ide> 'type' => 'string',
<ide> 'length' => 25,
<del> 'null' => false
<add> 'null' => false,
<ide> ]);
<ide> $this->assertEquals('string', $table->getColumnType('title'));
<ide> $table->setColumnType('title', 'json');
<ide> public function testBaseColumnType()
<ide> 'type' => 'json',
<ide> 'baseType' => 'text',
<ide> 'length' => 25,
<del> 'null' => false
<add> 'null' => false,
<ide> ]);
<ide> $this->assertEquals('json', $table->getColumnType('title'));
<ide> $this->assertEquals('text', $table->baseColumnType('title'));
<ide> public function testBaseColumnTypeInherited()
<ide> $table = new TableSchema('articles');
<ide> $table->addColumn('thing', [
<ide> 'type' => 'foo',
<del> 'null' => false
<add> 'null' => false,
<ide> ]);
<ide> $this->assertEquals('foo', $table->getColumnType('thing'));
<ide> $this->assertEquals('integer', $table->baseColumnType('thing'));
<ide> public function testAddColumnFiltersAttributes()
<ide> {
<ide> $table = new TableSchema('articles');
<ide> $table->addColumn('title', [
<del> 'type' => 'string'
<add> 'type' => 'string',
<ide> ]);
<ide> $result = $table->getColumn('title');
<ide> $expected = [
<ide> public function testAddColumnFiltersAttributes()
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $table->addColumn('author_id', [
<del> 'type' => 'integer'
<add> 'type' => 'integer',
<ide> ]);
<ide> $result = $table->getColumn('author_id');
<ide> $expected = [
<ide> public function testAddColumnFiltersAttributes()
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $table->addColumn('amount', [
<del> 'type' => 'decimal'
<add> 'type' => 'decimal',
<ide> ]);
<ide> $result = $table->getColumn('amount');
<ide> $expected = [
<ide> public function testDefaultValues()
<ide> $table = new TableSchema('articles');
<ide> $table->addColumn('id', [
<ide> 'type' => 'integer',
<del> 'default' => 0
<add> 'default' => 0,
<ide> ])->addColumn('title', [
<ide> 'type' => 'string',
<del> 'default' => 'A title'
<add> 'default' => 'A title',
<ide> ])->addColumn('name', [
<ide> 'type' => 'string',
<ide> 'null' => false,
<ide> public function testDefaultValues()
<ide> $expected = [
<ide> 'id' => 0,
<ide> 'title' => 'A title',
<del> 'body' => null
<add> 'body' => null,
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testAddConstraint()
<ide> {
<ide> $table = new TableSchema('articles');
<ide> $table->addColumn('id', [
<del> 'type' => 'integer'
<add> 'type' => 'integer',
<ide> ]);
<ide> $result = $table->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['id']
<add> 'columns' => ['id'],
<ide> ]);
<ide> $this->assertSame($result, $table);
<ide> $this->assertEquals(['primary'], $table->constraints());
<ide> public function testAddConstraintOverwriteUniqueIndex()
<ide> ])->addColumn('id', [
<ide> 'type' => 'integer',
<ide> 'autoIncrement' => true,
<del> 'limit' => 11
<add> 'limit' => 11,
<ide> ])->addColumn('user_id', [
<ide> 'type' => 'integer',
<ide> 'default' => null,
<ide> 'limit' => 11,
<ide> 'null' => false,
<ide> ])->addConstraint('users_idx', [
<ide> 'type' => 'unique',
<del> 'columns' => ['project_id', 'user_id']
<add> 'columns' => ['project_id', 'user_id'],
<ide> ])->addConstraint('users_idx', [
<ide> 'type' => 'foreign',
<ide> 'references' => ['users', 'project_id', 'id'],
<del> 'columns' => ['project_id', 'user_id']
<add> 'columns' => ['project_id', 'user_id'],
<ide> ]);
<ide> $this->assertEquals(['users_idx'], $table->constraints());
<ide> }
<ide> public function testAddIndex()
<ide> {
<ide> $table = new TableSchema('articles');
<ide> $table->addColumn('title', [
<del> 'type' => 'string'
<add> 'type' => 'string',
<ide> ]);
<ide> $result = $table->addIndex('faster', [
<ide> 'type' => 'index',
<del> 'columns' => ['title']
<add> 'columns' => ['title'],
<ide> ]);
<ide> $this->assertSame($result, $table);
<ide> $this->assertEquals(['faster'], $table->indexes());
<ide> public function testAddIndexTypes()
<ide>
<ide> $table->addIndex('author_idx', [
<ide> 'columns' => ['author_id'],
<del> 'type' => 'index'
<add> 'type' => 'index',
<ide> ])->addIndex('texty', [
<ide> 'type' => 'fulltext',
<del> 'columns' => ['title']
<add> 'columns' => ['title'],
<ide> ]);
<ide>
<ide> $this->assertEquals(
<ide> public function testPrimaryKey()
<ide> ->addColumn('author_id', 'integer')
<ide> ->addConstraint('author_idx', [
<ide> 'columns' => ['author_id'],
<del> 'type' => 'unique'
<add> 'type' => 'unique',
<ide> ])->addConstraint('primary', [
<ide> 'type' => 'primary',
<del> 'columns' => ['id']
<add> 'columns' => ['id'],
<ide> ]);
<ide> $this->assertEquals(['id'], $table->primaryKey());
<ide>
<ide> public function testOptions()
<ide> {
<ide> $table = new TableSchema('articles');
<ide> $options = [
<del> 'engine' => 'InnoDB'
<add> 'engine' => 'InnoDB',
<ide> ];
<ide> $return = $table->setOptions($options);
<ide> $this->assertInstanceOf('Cake\Database\Schema\TableSchema', $return);
<ide> public function testOptionsDeprecated()
<ide> {
<ide> $table = new TableSchema('articles');
<ide> $options = [
<del> 'engine' => 'InnoDB'
<add> 'engine' => 'InnoDB',
<ide> ];
<ide> $this->deprecated(function () use ($table, $options) {
<ide> $return = $table->options($options);
<ide> public function testConstraintForeignKey()
<ide> 'references' => ['tags', 'id'],
<ide> 'update' => 'cascade',
<ide> 'delete' => 'cascade',
<del> 'length' => []
<add> 'length' => [],
<ide> ];
<ide>
<ide> $this->assertEquals($expected, $compositeConstraint);
<ide> public function testConstraintForeignKeyTwoColumns()
<ide> 'type' => 'foreign',
<ide> 'columns' => [
<ide> 'product_category',
<del> 'product_id'
<add> 'product_id',
<ide> ],
<ide> 'references' => [
<ide> 'products',
<del> ['category', 'id']
<add> ['category', 'id'],
<ide> ],
<ide> 'update' => 'cascade',
<ide> 'delete' => 'cascade',
<del> 'length' => []
<add> 'length' => [],
<ide> ];
<ide> $this->assertEquals($expected, $compositeConstraint);
<ide>
<ide><path>tests/TestCase/Database/Type/DateTimeTypeTest.php
<ide> public function marshalProvider()
<ide> // valid array types
<ide> [
<ide> ['year' => '', 'month' => '', 'day' => '', 'hour' => '', 'minute' => '', 'second' => ''],
<del> null
<add> null,
<ide> ],
<ide> [
<ide> ['year' => 2014, 'month' => 2, 'day' => 14, 'hour' => 13, 'minute' => 14, 'second' => 15],
<del> new Time('2014-02-14 13:14:15')
<add> new Time('2014-02-14 13:14:15'),
<ide> ],
<ide> [
<ide> [
<ide> 'year' => 2014, 'month' => 2, 'day' => 14,
<ide> 'hour' => 1, 'minute' => 14, 'second' => 15,
<del> 'meridian' => 'am'
<add> 'meridian' => 'am',
<ide> ],
<del> new Time('2014-02-14 01:14:15')
<add> new Time('2014-02-14 01:14:15'),
<ide> ],
<ide> [
<ide> [
<ide> 'year' => 2014, 'month' => 2, 'day' => 14,
<ide> 'hour' => 12, 'minute' => 04, 'second' => 15,
<del> 'meridian' => 'pm'
<add> 'meridian' => 'pm',
<ide> ],
<del> new Time('2014-02-14 12:04:15')
<add> new Time('2014-02-14 12:04:15'),
<ide> ],
<ide> [
<ide> [
<ide> 'year' => 2014, 'month' => 2, 'day' => 14,
<ide> 'hour' => 1, 'minute' => 14, 'second' => 15,
<del> 'meridian' => 'pm'
<add> 'meridian' => 'pm',
<ide> ],
<del> new Time('2014-02-14 13:14:15')
<add> new Time('2014-02-14 13:14:15'),
<ide> ],
<ide> [
<ide> [
<ide> 'year' => 2014, 'month' => 2, 'day' => 14,
<ide> ],
<del> new Time('2014-02-14 00:00:00')
<add> new Time('2014-02-14 00:00:00'),
<ide> ],
<ide> [
<ide> [
<del> 'year' => 2014, 'month' => 2, 'day' => 14, 'hour' => 12, 'minute' => 30, 'timezone' => 'Europe/Paris'
<add> 'year' => 2014, 'month' => 2, 'day' => 14, 'hour' => 12, 'minute' => 30, 'timezone' => 'Europe/Paris',
<ide> ],
<del> new Time('2014-02-14 11:30:00', 'UTC')
<add> new Time('2014-02-14 11:30:00', 'UTC'),
<ide> ],
<ide>
<ide> // Invalid array types
<ide> [
<ide> ['year' => 'farts', 'month' => 'derp'],
<del> new Time(date('Y-m-d 00:00:00'))
<add> new Time(date('Y-m-d 00:00:00')),
<ide> ],
<ide> [
<ide> ['year' => 'farts', 'month' => 'derp', 'day' => 'farts'],
<del> new Time(date('Y-m-d 00:00:00'))
<add> new Time(date('Y-m-d 00:00:00')),
<ide> ],
<ide> [
<ide> [
<ide> 'year' => '2014', 'month' => '02', 'day' => '14',
<del> 'hour' => 'farts', 'minute' => 'farts'
<add> 'hour' => 'farts', 'minute' => 'farts',
<ide> ],
<del> new Time('2014-02-14 00:00:00')
<add> new Time('2014-02-14 00:00:00'),
<ide> ],
<ide> [
<ide> Time::now(),
<del> Time::now()
<del> ]
<add> Time::now(),
<add> ],
<ide> ];
<ide> }
<ide>
<ide><path>tests/TestCase/Database/Type/DateTypeTest.php
<ide> public function marshalProvider()
<ide> ],
<ide> [
<ide> ['year' => 2014, 'month' => 2, 'day' => 14, 'hour' => 13, 'minute' => 14, 'second' => 15],
<del> new Date('2014-02-14')
<add> new Date('2014-02-14'),
<ide> ],
<ide> [
<ide> [
<ide> 'year' => 2014, 'month' => 2, 'day' => 14,
<ide> 'hour' => 1, 'minute' => 14, 'second' => 15,
<del> 'meridian' => 'am'
<add> 'meridian' => 'am',
<ide> ],
<del> new Date('2014-02-14')
<add> new Date('2014-02-14'),
<ide> ],
<ide> [
<ide> [
<ide> 'year' => 2014, 'month' => 2, 'day' => 14,
<ide> 'hour' => 1, 'minute' => 14, 'second' => 15,
<del> 'meridian' => 'pm'
<add> 'meridian' => 'pm',
<ide> ],
<del> new Date('2014-02-14')
<add> new Date('2014-02-14'),
<ide> ],
<ide> [
<ide> [
<ide> 'year' => 2014, 'month' => 2, 'day' => 14,
<ide> ],
<del> new Date('2014-02-14')
<add> new Date('2014-02-14'),
<ide> ],
<ide>
<ide> // Invalid array types
<ide> [
<ide> ['year' => 'farts', 'month' => 'derp'],
<del> new Date(date('Y-m-d'))
<add> new Date(date('Y-m-d')),
<ide> ],
<ide> [
<ide> ['year' => 'farts', 'month' => 'derp', 'day' => 'farts'],
<del> new Date(date('Y-m-d'))
<add> new Date(date('Y-m-d')),
<ide> ],
<ide> [
<ide> [
<ide> 'year' => '2014', 'month' => '02', 'day' => '14',
<del> 'hour' => 'farts', 'minute' => 'farts'
<add> 'hour' => 'farts', 'minute' => 'farts',
<ide> ],
<del> new Date('2014-02-14')
<add> new Date('2014-02-14'),
<ide> ],
<ide> ];
<ide> }
<ide><path>tests/TestCase/Database/Type/IntegerTypeTest.php
<ide> public function testManyToPHP()
<ide> 'b' => '2.3',
<ide> 'c' => '15',
<ide> 'd' => '0.0',
<del> 'e' => 10
<add> 'e' => 10,
<ide> ];
<ide> $expected = [
<ide> 'a' => null,
<ide> 'b' => 2,
<ide> 'c' => 15,
<ide> 'd' => 0,
<del> 'e' => 10
<add> 'e' => 10,
<ide> ];
<ide> $this->assertEquals(
<ide> $expected,
<ide> public function testInvalidManyToPHP()
<ide> 'c' => '15',
<ide> 'd' => '0.0',
<ide> 'e' => 10,
<del> 'f' => '6a88accf-a34e-4dd9-ade0-8d255ccaecbe'
<add> 'f' => '6a88accf-a34e-4dd9-ade0-8d255ccaecbe',
<ide> ];
<ide> $expected = [
<ide> 'a' => null,
<ide> 'b' => 2,
<ide> 'c' => 15,
<ide> 'd' => 0,
<ide> 'e' => 10,
<del> 'f' => '6a88accf-a34e-4dd9-ade0-8d255ccaecbe'
<add> 'f' => '6a88accf-a34e-4dd9-ade0-8d255ccaecbe',
<ide> ];
<ide> $this->assertEquals(
<ide> $expected,
<ide><path>tests/TestCase/Database/Type/TimeTypeTest.php
<ide> public function marshalProvider()
<ide> ],
<ide> [
<ide> ['year' => 2014, 'month' => 2, 'day' => 14, 'hour' => 13, 'minute' => 14, 'second' => 15],
<del> new Time('2014-02-14 13:14:15')
<add> new Time('2014-02-14 13:14:15'),
<ide> ],
<ide> [
<ide> [
<ide> 'year' => 2014, 'month' => 2, 'day' => 14,
<ide> 'hour' => 1, 'minute' => 14, 'second' => 15,
<del> 'meridian' => 'am'
<add> 'meridian' => 'am',
<ide> ],
<del> new Time('2014-02-14 01:14:15')
<add> new Time('2014-02-14 01:14:15'),
<ide> ],
<ide> [
<ide> [
<ide> 'year' => 2014, 'month' => 2, 'day' => 14,
<ide> 'hour' => 1, 'minute' => 14, 'second' => 15,
<del> 'meridian' => 'pm'
<add> 'meridian' => 'pm',
<ide> ],
<del> new Time('2014-02-14 13:14:15')
<add> new Time('2014-02-14 13:14:15'),
<ide> ],
<ide> [
<ide> [
<ide> 'hour' => 1, 'minute' => 14, 'second' => 15,
<ide> ],
<del> new Time('01:14:15')
<add> new Time('01:14:15'),
<ide> ],
<ide>
<ide> // Invalid array types
<ide> [
<ide> ['hour' => 'nope', 'minute' => 14, 'second' => 15],
<del> new Time(date('Y-m-d 00:14:15'))
<add> new Time(date('Y-m-d 00:14:15')),
<ide> ],
<ide> [
<ide> [
<ide> 'year' => '2014', 'month' => '02', 'day' => '14',
<del> 'hour' => 'nope', 'minute' => 'nope'
<add> 'hour' => 'nope', 'minute' => 'nope',
<ide> ],
<del> new Time('2014-02-14 00:00:00')
<add> new Time('2014-02-14 00:00:00'),
<ide> ],
<ide> ];
<ide> }
<ide><path>tests/TestCase/Database/ValueBinderTest.php
<ide> public function testBind()
<ide> ':c0' => [
<ide> 'value' => 'value0',
<ide> 'type' => 'string',
<del> 'placeholder' => 'c0'
<add> 'placeholder' => 'c0',
<ide> ],
<ide> ':c1' => [
<ide> 'value' => 1,
<ide> 'type' => 'int',
<del> 'placeholder' => 'c1'
<add> 'placeholder' => 'c1',
<ide> ],
<ide> ':c2' => [
<ide> 'value' => 'value2',
<ide> 'type' => 'string',
<del> 'placeholder' => 'c2'
<del> ]
<add> 'placeholder' => 'c2',
<add> ],
<ide> ];
<ide>
<ide> $bindings = $valueBinder->bindings();
<ide> public function testGenerateManyNamed()
<ide> $valueBinder = new ValueBinder();
<ide> $values = [
<ide> 'value0',
<del> 'value1'
<add> 'value1',
<ide> ];
<ide>
<ide> $expected = [
<ide> ':c0',
<del> ':c1'
<add> ':c1',
<ide> ];
<ide> $placeholders = $valueBinder->generateManyNamed($values);
<ide> $this->assertEquals($expected, $placeholders);
<ide><path>tests/TestCase/DatabaseSuite.php
<ide> public function run(TestResult $result = null)
<ide> },
<ide> 'No identifier quoting' => function () {
<ide> ConnectionManager::get('test')->getDriver()->enableAutoQuoting(false);
<del> }
<add> },
<ide> ];
<ide>
<ide> foreach ($permutations as $permutation) {
<ide><path>tests/TestCase/Datasource/ConnectionManagerTest.php
<ide> public function testConfigInvalidOptions()
<ide> {
<ide> $this->expectException(\Cake\Datasource\Exception\MissingDatasourceException::class);
<ide> ConnectionManager::setConfig('test_variant', [
<del> 'className' => 'Herp\Derp'
<add> 'className' => 'Herp\Derp',
<ide> ]);
<ide> ConnectionManager::get('test_variant');
<ide> }
<ide> public function testConfigured()
<ide> {
<ide> ConnectionManager::setConfig('test_variant', [
<ide> 'className' => __NAMESPACE__ . '\FakeConnection',
<del> 'database' => ':memory:'
<add> 'database' => ':memory:',
<ide> ]);
<ide> $results = ConnectionManager::configured();
<ide> $this->assertContains('test_variant', $results);
<ide> public function testDrop()
<ide> {
<ide> ConnectionManager::setConfig('test_variant', [
<ide> 'className' => __NAMESPACE__ . '\FakeConnection',
<del> 'database' => ':memory:'
<add> 'database' => ':memory:',
<ide> ]);
<ide> $result = ConnectionManager::configured();
<ide> $this->assertContains('test_variant', $result);
<ide> public function testAlias()
<ide> {
<ide> ConnectionManager::setConfig('test_variant', [
<ide> 'className' => __NAMESPACE__ . '\FakeConnection',
<del> 'database' => ':memory:'
<add> 'database' => ':memory:',
<ide> ]);
<ide> ConnectionManager::alias('test_variant', 'other_name');
<ide> $result = ConnectionManager::get('test_variant');
<ide> public function dsnProvider()
<ide> 'database' => 'database',
<ide> 'port' => 3306,
<ide> 'scheme' => 'mysql',
<del> ]
<add> ],
<ide> ],
<ide> 'subdomain host' => [
<ide> 'mysql://my.host-name.com:3306/database',
<ide> public function dsnProvider()
<ide> 'database' => 'database',
<ide> 'port' => 3306,
<ide> 'scheme' => 'mysql',
<del> ]
<add> ],
<ide> ],
<ide> 'user & pass' => [
<ide> 'mysql://root:secret@localhost:3306/database?log=1',
<ide> public function dsnProvider()
<ide> 'password' => 'secret',
<ide> 'port' => 3306,
<ide> 'database' => 'database',
<del> 'log' => '1'
<del> ]
<add> 'log' => '1',
<add> ],
<ide> ],
<ide> 'no password' => [
<ide> 'mysql://user@localhost:3306/database',
<ide> public function dsnProvider()
<ide> 'port' => 3306,
<ide> 'scheme' => 'mysql',
<ide> 'username' => 'user',
<del> ]
<add> ],
<ide> ],
<ide> 'empty password' => [
<ide> 'mysql://user:@localhost:3306/database',
<ide> public function dsnProvider()
<ide> 'scheme' => 'mysql',
<ide> 'username' => 'user',
<ide> 'password' => '',
<del> ]
<add> ],
<ide> ],
<ide> 'sqlite memory' => [
<ide> 'sqlite:///:memory:',
<ide> public function dsnProvider()
<ide> 'driver' => 'Cake\Database\Driver\Sqlite',
<ide> 'database' => ':memory:',
<ide> 'scheme' => 'sqlite',
<del> ]
<add> ],
<ide> ],
<ide> 'sqlite path' => [
<ide> 'sqlite:////absolute/path',
<ide> public function dsnProvider()
<ide> 'driver' => 'Cake\Database\Driver\Sqlite',
<ide> 'database' => '/absolute/path',
<ide> 'scheme' => 'sqlite',
<del> ]
<add> ],
<ide> ],
<ide> 'sqlite database query' => [
<ide> 'sqlite:///?database=:memory:',
<ide> public function dsnProvider()
<ide> 'driver' => 'Cake\Database\Driver\Sqlite',
<ide> 'database' => ':memory:',
<ide> 'scheme' => 'sqlite',
<del> ]
<add> ],
<ide> ],
<ide> 'sqlserver' => [
<ide> 'sqlserver://sa:Password12!@.\SQL2012SP1/cakephp?MultipleActiveResultSets=false',
<ide> public function dsnProvider()
<ide> 'database' => 'cakephp',
<ide> 'scheme' => 'sqlserver',
<ide> 'username' => 'sa',
<del> ]
<add> ],
<ide> ],
<ide> 'sqllocaldb' => [
<ide> 'sqlserver://username:password@(localdb)\.\DeptSharedLocalDB/database',
<ide> public function dsnProvider()
<ide> 'database' => 'database',
<ide> 'scheme' => 'sqlserver',
<ide> 'username' => 'username',
<del> ]
<add> ],
<ide> ],
<ide> 'classname query arg' => [
<ide> 'mysql://localhost/database?className=Custom\Driver',
<ide> public function dsnProvider()
<ide> 'driver' => 'Custom\Driver',
<ide> 'host' => 'localhost',
<ide> 'scheme' => 'mysql',
<del> ]
<add> ],
<ide> ],
<ide> 'classname and port' => [
<ide> 'mysql://localhost:3306/database?className=Custom\Driver',
<ide> public function dsnProvider()
<ide> 'host' => 'localhost',
<ide> 'scheme' => 'mysql',
<ide> 'port' => 3306,
<del> ]
<add> ],
<ide> ],
<ide> 'custom connection class' => [
<ide> 'Cake\Database\Connection://localhost:3306/database?driver=Cake\Database\Driver\Mysql',
<ide> public function dsnProvider()
<ide> 'host' => 'localhost',
<ide> 'scheme' => 'Cake\Database\Connection',
<ide> 'port' => 3306,
<del> ]
<add> ],
<ide> ],
<ide> 'complex password' => [
<ide> 'mysql://user:/?#][{}$%20@!@localhost:3306/database?log=1"eIdentifiers=1',
<ide> public function dsnProvider()
<ide> 'username' => 'user',
<ide> 'log' => 1,
<ide> 'quoteIdentifiers' => 1,
<del> ]
<del> ]
<add> ],
<add> ],
<ide> ];
<ide> }
<ide>
<ide> public function testSetConfigName()
<ide> //Set with explicit name
<ide> ConnectionManager::setConfig('test_variant', [
<ide> 'className' => __NAMESPACE__ . '\FakeConnection',
<del> 'database' => ':memory:'
<add> 'database' => ':memory:',
<ide> ]);
<ide> $result = ConnectionManager::get('test_variant');
<ide> $this->assertSame('test_variant', $result->configName());
<ide> public function testSetConfigName()
<ide> ConnectionManager::setConfig([
<ide> 'test_variant' => [
<ide> 'className' => __NAMESPACE__ . '\FakeConnection',
<del> 'database' => ':memory:'
<del> ]
<add> 'database' => ':memory:',
<add> ],
<ide> ]);
<ide> $result = ConnectionManager::get('test_variant');
<ide> $this->assertSame('test_variant', $result->configName());
<ide><path>tests/TestCase/Datasource/PaginatorTest.php
<ide> class PaginatorTest extends TestCase
<ide> */
<ide> public $fixtures = [
<ide> 'core.Posts', 'core.Articles', 'core.ArticlesTags',
<del> 'core.Authors', 'core.AuthorsTags', 'core.Tags'
<add> 'core.Authors', 'core.AuthorsTags', 'core.Tags',
<ide> ];
<ide>
<ide> /**
<ide> public function testPaginateExtraParams()
<ide> 'contain' => ['PaginatorAuthor'],
<ide> 'maxLimit' => 10,
<ide> 'group' => 'PaginatorPosts.published',
<del> 'order' => ['PaginatorPosts.id' => 'ASC']
<add> 'order' => ['PaginatorPosts.id' => 'ASC'],
<ide> ],
<ide> ];
<ide> $table = $this->_getMockPosts(['query']);
<ide> public function testPaginateCustomFinderOptions()
<ide> $this->loadFixtures('Posts');
<ide> $settings = [
<ide> 'PaginatorPosts' => [
<del> 'finder' => ['author' => ['author_id' => 1]]
<del> ]
<add> 'finder' => ['author' => ['author_id' => 1]],
<add> ],
<ide> ];
<ide> $table = $this->getTableLocator()->get('PaginatorPosts');
<ide>
<ide> $expected = $table
<ide> ->find('author', [
<ide> 'conditions' => [
<del> 'PaginatorPosts.author_id' => 1
<del> ]
<add> 'PaginatorPosts.author_id' => 1,
<add> ],
<ide> ])
<ide> ->count();
<ide> $result = $this->Paginator->paginate($table, [], $settings)->count();
<ide> public function testPaginateCustomFinder()
<ide> 'finder' => 'popular',
<ide> 'fields' => ['id', 'title'],
<ide> 'maxLimit' => 10,
<del> ]
<add> ],
<ide> ];
<ide>
<ide> $table = $this->_getMockPosts(['findPopular']);
<ide> public function testMergeOptionsCustomScope()
<ide> 'scope' => [
<ide> 'page' => 2,
<ide> 'limit' => 5,
<del> ]
<add> ],
<ide> ];
<ide>
<ide> $settings = [
<ide> public function testMergeOptionsCustomFindKey()
<ide> {
<ide> $params = [
<ide> 'page' => 10,
<del> 'limit' => 10
<add> 'limit' => 10,
<ide> ];
<ide> $settings = [
<ide> 'page' => 1,
<ide> 'limit' => 20,
<ide> 'maxLimit' => 100,
<del> 'finder' => 'myCustomFind'
<add> 'finder' => 'myCustomFind',
<ide> ];
<ide> $defaults = $this->Paginator->getDefaults('Post', $settings);
<ide> $result = $this->Paginator->mergeOptions($params, $defaults);
<ide> public function testMergeOptionsQueryString()
<ide> {
<ide> $params = [
<ide> 'page' => 99,
<del> 'limit' => 75
<add> 'limit' => 75,
<ide> ];
<ide> $settings = [
<ide> 'page' => 1,
<ide> public function testMergeOptionsDefaultWhiteList()
<ide> 'fields' => ['bad.stuff'],
<ide> 'recursive' => 1000,
<ide> 'conditions' => ['bad.stuff'],
<del> 'contain' => ['bad']
<add> 'contain' => ['bad'],
<ide> ];
<ide> $settings = [
<ide> 'page' => 1,
<ide> public function testMergeOptionsExtraWhitelist()
<ide> 'fields' => ['bad.stuff'],
<ide> 'recursive' => 1000,
<ide> 'conditions' => ['bad.stuff'],
<del> 'contain' => ['bad']
<add> 'contain' => ['bad'],
<ide> ];
<ide> $settings = [
<ide> 'page' => 1,
<ide> public function testMergeOptionsExtraWhitelist()
<ide> $defaults = $this->Paginator->getDefaults('Post', $settings);
<ide> $result = $this->Paginator->mergeOptions($params, $defaults);
<ide> $expected = [
<del> 'page' => 10, 'limit' => 10, 'maxLimit' => 100, 'fields' => ['bad.stuff'], 'whitelist' => ['limit', 'sort', 'page', 'direction', 'fields']
<add> 'page' => 10, 'limit' => 10, 'maxLimit' => 100, 'fields' => ['bad.stuff'], 'whitelist' => ['limit', 'sort', 'page', 'direction', 'fields'],
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testMergeOptionsMaxLimit()
<ide> 'limit' => 100,
<ide> 'maxLimit' => 100,
<ide> 'paramType' => 'named',
<del> 'whitelist' => ['limit', 'sort', 'page', 'direction']
<add> 'whitelist' => ['limit', 'sort', 'page', 'direction'],
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> public function testMergeOptionsMaxLimit()
<ide> 'limit' => 10,
<ide> 'maxLimit' => 10,
<ide> 'paramType' => 'named',
<del> 'whitelist' => ['limit', 'sort', 'page', 'direction']
<add> 'whitelist' => ['limit', 'sort', 'page', 'direction'],
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testGetDefaultMaxLimit()
<ide> 'limit' => 2,
<ide> 'maxLimit' => 10,
<ide> 'order' => [
<del> 'Users.username' => 'asc'
<add> 'Users.username' => 'asc',
<ide> ],
<ide> ];
<ide> $defaults = $this->Paginator->getDefaults('Post', $settings);
<ide> public function testGetDefaultMaxLimit()
<ide> 'limit' => 2,
<ide> 'maxLimit' => 10,
<ide> 'order' => [
<del> 'Users.username' => 'asc'
<add> 'Users.username' => 'asc',
<ide> ],
<del> 'whitelist' => ['limit', 'sort', 'page', 'direction']
<add> 'whitelist' => ['limit', 'sort', 'page', 'direction'],
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> public function testGetDefaultMaxLimit()
<ide> 'limit' => 100,
<ide> 'maxLimit' => 10,
<ide> 'order' => [
<del> 'Users.username' => 'asc'
<add> 'Users.username' => 'asc',
<ide> ],
<ide> ];
<ide> $defaults = $this->Paginator->getDefaults('Post', $settings);
<ide> public function testGetDefaultMaxLimit()
<ide> 'limit' => 10,
<ide> 'maxLimit' => 10,
<ide> 'order' => [
<del> 'Users.username' => 'asc'
<add> 'Users.username' => 'asc',
<ide> ],
<del> 'whitelist' => ['limit', 'sort', 'page', 'direction']
<add> 'whitelist' => ['limit', 'sort', 'page', 'direction'],
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide> public function testValidateSortInvalid()
<ide> $params = [
<ide> 'page' => 1,
<ide> 'sort' => 'id',
<del> 'direction' => 'herp'
<add> 'direction' => 'herp',
<ide> ];
<ide> $this->Paginator->paginate($table, $params);
<ide> $pagingParams = $this->Paginator->getPagingParams();
<ide> public function testValidateSortAndDirectionAliased()
<ide> $queryParams = [
<ide> 'page' => 1,
<ide> 'sort' => 'title',
<del> 'direction' => 'asc'
<add> 'direction' => 'asc',
<ide> ];
<ide>
<ide> $this->Paginator->paginate($table, $queryParams, $options);
<ide> public function testValidateSortRetainsOriginalSortValue()
<ide> $params = [
<ide> 'page' => 1,
<ide> 'sort' => 'id',
<del> 'direction' => 'herp'
<add> 'direction' => 'herp',
<ide> ];
<ide> $options = [
<del> 'sortWhitelist' => ['id']
<add> 'sortWhitelist' => ['id'],
<ide> ];
<ide> $this->Paginator->paginate($table, $params, $options);
<ide> $pagingParams = $this->Paginator->getPagingParams();
<ide> public function testOutOfRangePageNumberGetsClamped()
<ide> $this->assertSame(
<ide> [
<ide> 'requestedPage' => 3000,
<del> 'pagingParams' => $this->Paginator->getPagingParams()
<add> 'pagingParams' => $this->Paginator->getPagingParams(),
<ide> ],
<ide> $exception->getAttributes()
<ide> );
<ide> public function testValidateSortWhitelistFailure()
<ide> $options = [
<ide> 'sort' => 'body',
<ide> 'direction' => 'asc',
<del> 'sortWhitelist' => ['title', 'id']
<add> 'sortWhitelist' => ['title', 'id'],
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide>
<ide> public function testValidateSortWhitelistTrusted()
<ide> $options = [
<ide> 'sort' => 'body',
<ide> 'direction' => 'asc',
<del> 'sortWhitelist' => ['body']
<add> 'sortWhitelist' => ['body'],
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide>
<ide> public function testValidateSortWhitelistEmpty()
<ide> $options = [
<ide> 'order' => [
<ide> 'body' => 'asc',
<del> 'foo.bar' => 'asc'
<add> 'foo.bar' => 'asc',
<ide> ],
<ide> 'sort' => 'body',
<ide> 'direction' => 'asc',
<del> 'sortWhitelist' => []
<add> 'sortWhitelist' => [],
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide>
<ide> public function testValidateSortWhitelistNotInSchema()
<ide> $options = [
<ide> 'sort' => 'score',
<ide> 'direction' => 'asc',
<del> 'sortWhitelist' => ['score']
<add> 'sortWhitelist' => ['score'],
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide>
<ide> public function testValidateSortWhitelistMultiple()
<ide> $options = [
<ide> 'order' => [
<ide> 'body' => 'asc',
<del> 'foo.bar' => 'asc'
<add> 'foo.bar' => 'asc',
<ide> ],
<del> 'sortWhitelist' => ['body', 'foo.bar']
<add> 'sortWhitelist' => ['body', 'foo.bar'],
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide>
<ide> $expected = [
<ide> 'model.body' => 'asc',
<del> 'foo.bar' => 'asc'
<add> 'foo.bar' => 'asc',
<ide> ];
<ide> $this->assertEquals($expected, $result['order']);
<ide> }
<ide> protected function getMockRepository()
<ide> $model = $this->getMockBuilder('Cake\Datasource\RepositoryInterface')
<ide> ->setMethods([
<ide> 'getAlias', 'hasField', 'alias', 'find', 'get', 'query', 'updateAll', 'deleteAll',
<del> 'exists', 'save', 'delete', 'newEntity', 'newEntities', 'patchEntity', 'patchEntities'
<add> 'exists', 'save', 'delete', 'newEntity', 'newEntities', 'patchEntity', 'patchEntities',
<ide> ])
<ide> ->getMock();
<ide>
<ide> public function testValidateSortMultiple()
<ide> $options = [
<ide> 'order' => [
<ide> 'author_id' => 'asc',
<del> 'title' => 'asc'
<del> ]
<add> 'title' => 'asc',
<add> ],
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide> $expected = [
<ide> 'model.author_id' => 'asc',
<del> 'model.title' => 'asc'
<add> 'model.title' => 'asc',
<ide> ];
<ide>
<ide> $this->assertEquals($expected, $result['order']);
<ide> public function testValidateSortMultipleWithQuery()
<ide> 'direction' => 'desc',
<ide> 'order' => [
<ide> 'author_id' => 'asc',
<del> 'title' => 'asc'
<del> ]
<add> 'title' => 'asc',
<add> ],
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide>
<ide> $expected = [
<ide> 'model.created' => 'desc',
<ide> 'model.author_id' => 'asc',
<del> 'model.title' => 'asc'
<add> 'model.title' => 'asc',
<ide> ];
<ide> $this->assertEquals($expected, $result['order']);
<ide>
<ide> public function testValidateSortMultipleWithQuery()
<ide> 'direction' => 'desc',
<ide> 'order' => [
<ide> 'author_id' => 'asc',
<del> 'title' => 'asc'
<del> ]
<add> 'title' => 'asc',
<add> ],
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide>
<ide> public function testValidateSortMultipleWithQueryAndAliasedDefault()
<ide> 'sort' => 'created',
<ide> 'direction' => 'desc',
<ide> 'order' => [
<del> 'model.created' => 'asc'
<del> ]
<add> 'model.created' => 'asc',
<add> ],
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide>
<ide> public function testValidateSortWithString()
<ide> $model = $this->mockAliasHasFieldModel();
<ide>
<ide> $options = [
<del> 'order' => 'model.author_id DESC'
<add> 'order' => 'model.author_id DESC',
<ide> ];
<ide> $result = $this->Paginator->validateSort($model, $options);
<ide> $expected = 'model.author_id DESC';
<ide> public function testPaginateMaxLimit()
<ide> 'maxLimit' => 100,
<ide> ];
<ide> $params = [
<del> 'limit' => '1000'
<add> 'limit' => '1000',
<ide> ];
<ide> $this->Paginator->paginate($table, $params, $settings);
<ide> $pagingParams = $this->Paginator->getPagingParams();
<ide> $this->assertEquals(100, $pagingParams['PaginatorPosts']['limit']);
<ide> $this->assertEquals(100, $pagingParams['PaginatorPosts']['perPage']);
<ide>
<ide> $params = [
<del> 'limit' => '10'
<add> 'limit' => '10',
<ide> ];
<ide> $this->Paginator->paginate($table, $params, $settings);
<ide> $pagingParams = $this->Paginator->getPagingParams();
<ide> public function testPaginateCustomFindFieldsArray()
<ide> $settings = [
<ide> 'finder' => 'list',
<ide> 'conditions' => ['PaginatorPosts.published' => 'Y'],
<del> 'limit' => 2
<add> 'limit' => 2,
<ide> ];
<ide> $results = $this->Paginator->paginate($table, [], $settings);
<ide>
<ide> public function testPaginateCustomFindCount()
<ide> {
<ide> $settings = [
<ide> 'finder' => 'published',
<del> 'limit' => 2
<add> 'limit' => 2,
<ide> ];
<ide> $table = $this->_getMockPosts(['query']);
<ide> $query = $this->_getMockFindQuery();
<ide> public function testPaginateQuery()
<ide> 'contain' => ['PaginatorAuthor'],
<ide> 'maxLimit' => 10,
<ide> 'group' => 'PaginatorPosts.published',
<del> 'order' => ['PaginatorPosts.id' => 'ASC']
<del> ]
<add> 'order' => ['PaginatorPosts.id' => 'ASC'],
<add> ],
<ide> ];
<ide> $table = $this->_getMockPosts(['find']);
<ide> $query = $this->_getMockFindQuery($table);
<ide> public function testPaginateQueryWithLimit()
<ide> 'maxLimit' => 10,
<ide> 'limit' => 5,
<ide> 'group' => 'PaginatorPosts.published',
<del> 'order' => ['PaginatorPosts.id' => 'ASC']
<del> ]
<add> 'order' => ['PaginatorPosts.id' => 'ASC'],
<add> ],
<ide> ];
<ide> $table = $this->_getMockPosts(['find']);
<ide> $query = $this->_getMockFindQuery($table);
<ide> protected function _getMockPosts($methods = [])
<ide> 'title' => ['type' => 'string', 'null' => false],
<ide> 'body' => 'text',
<ide> 'published' => ['type' => 'string', 'length' => 1, 'default' => 'N'],
<del> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
<del> ]
<add> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
<add> ],
<ide> ]])
<ide> ->getMock();
<ide> }
<ide><path>tests/TestCase/Datasource/RulesCheckerTest.php
<ide> class RulesCheckerTest extends TestCase
<ide> public function testAddingRuleDeleteMode()
<ide> {
<ide> $entity = new Entity([
<del> 'name' => 'larry'
<add> 'name' => 'larry',
<ide> ]);
<ide>
<ide> $rules = new RulesChecker();
<ide> function () {
<ide> public function testAddingRuleUpdateMode()
<ide> {
<ide> $entity = new Entity([
<del> 'name' => 'larry'
<add> 'name' => 'larry',
<ide> ]);
<ide>
<ide> $rules = new RulesChecker();
<ide> function () {
<ide> public function testAddingRuleCreateMode()
<ide> {
<ide> $entity = new Entity([
<del> 'name' => 'larry'
<add> 'name' => 'larry',
<ide> ]);
<ide>
<ide> $rules = new RulesChecker();
<ide> function () {
<ide> public function testAddingRuleWithName()
<ide> {
<ide> $entity = new Entity([
<del> 'name' => 'larry'
<add> 'name' => 'larry',
<ide> ]);
<ide>
<ide> $rules = new RulesChecker();
<ide> function () {
<ide> public function testAddWithErrorMessage()
<ide> {
<ide> $entity = new Entity([
<del> 'name' => 'larry'
<add> 'name' => 'larry',
<ide> ]);
<ide>
<ide> $rules = new RulesChecker();
<ide> function () {
<ide> public function testAddWithMessageOption()
<ide> {
<ide> $entity = new Entity([
<del> 'name' => 'larry'
<add> 'name' => 'larry',
<ide> ]);
<ide>
<ide> $rules = new RulesChecker();
<ide> function () {
<ide> public function testAddWithoutFields()
<ide> {
<ide> $entity = new Entity([
<del> 'name' => 'larry'
<add> 'name' => 'larry',
<ide> ]);
<ide>
<ide> $rules = new RulesChecker();
<ide><path>tests/TestCase/Error/DebuggerTest.php
<ide> public function testOutputErrorLineHighlight()
<ide> 'file' => __FILE__,
<ide> 'line' => __LINE__,
<ide> 'description' => 'Error description',
<del> 'start' => 1
<add> 'start' => 1,
<ide> ];
<ide> $debugger->outputError($data);
<ide> $result = ob_get_clean();
<ide> public function testAddFormat()
<ide> {
<ide> Debugger::addFormat('js', [
<ide> 'traceLine' => '{:reference} - <a href="txmt://open?url=file://{:file}' .
<del> '&line={:line}">{:path}</a>, line {:line}'
<add> '&line={:line}">{:path}</a>, line {:line}',
<ide> ]);
<ide> Debugger::setOutputFormat('js');
<ide>
<ide> public function testAddFormat()
<ide> '<file', 'preg:/[^<]+/', '/file',
<ide> '<line', '' . ((int)__LINE__ - 9), '/line',
<ide> 'preg:/Undefined variable:\s+foo/',
<del> '/error'
<add> '/error',
<ide> ];
<ide> $this->assertHtml($expected, $result, true);
<ide> }
<ide> public function testExportVar()
<ide>
<ide> $data = [
<ide> 1 => 'Index one',
<del> 5 => 'Index five'
<add> 5 => 'Index five',
<ide> ];
<ide> $result = Debugger::exportVar($data);
<ide> $expected = <<<TEXT
<ide> public function testExportVar()
<ide>
<ide> $data = [
<ide> 'key' => [
<del> 'value'
<del> ]
<add> 'value',
<add> ],
<ide> ];
<ide> $result = Debugger::exportVar($data, 1);
<ide> $expected = <<<TEXT
<ide> public function testExportVarZero()
<ide> 'null' => null,
<ide> 'false' => false,
<ide> 'szero' => '0',
<del> 'zero' => 0
<add> 'zero' => 0,
<ide> ];
<ide> $result = Debugger::exportVar($data);
<ide> $expected = <<<TEXT
<ide> public function testLogDepth()
<ide> ));
<ide>
<ide> $val = [
<del> 'test' => ['key' => 'val']
<add> 'test' => ['key' => 'val'],
<ide> ];
<ide> Debugger::log($val, 'debug', 0);
<ide> }
<ide> public function testDump()
<ide> [
<ide> 'name' => 'joeseph',
<ide> 'coat' => 'technicolor',
<del> 'hair_color' => 'brown'
<add> 'hair_color' => 'brown',
<ide> ],
<ide> [
<ide> 'name' => 'Shaft',
<ide> 'coat' => 'black',
<del> 'hair' => 'black'
<del> ]
<add> 'hair' => 'black',
<add> ],
<ide> ]];
<ide> ob_start();
<ide> Debugger::dump($var);
<ide> public function testTraceExclude()
<ide> $this->assertRegExp('/^Cake\\\Test\\\TestCase\\\Error\\\DebuggerTest::testTraceExclude/', $result);
<ide>
<ide> $result = Debugger::trace([
<del> 'exclude' => ['Cake\Test\TestCase\Error\DebuggerTest::testTraceExclude']
<add> 'exclude' => ['Cake\Test\TestCase\Error\DebuggerTest::testTraceExclude'],
<ide> ]);
<ide> $this->assertNotRegExp('/^Cake\\\Test\\\TestCase\\\Error\\\DebuggerTest::testTraceExclude/', $result);
<ide> }
<ide><path>tests/TestCase/Error/ErrorHandlerTest.php
<ide> public function setUp()
<ide> $request = new ServerRequest([
<ide> 'base' => '',
<ide> 'environment' => [
<del> 'HTTP_REFERER' => '/referer'
<del> ]
<add> 'HTTP_REFERER' => '/referer',
<add> ],
<ide> ]);
<ide>
<ide> Router::setRequestInfo($request);
<ide> public function setUp()
<ide>
<ide> Log::reset();
<ide> Log::setConfig('error_test', [
<del> 'engine' => $this->_logger
<add> 'engine' => $this->_logger,
<ide> ]);
<ide> }
<ide>
<ide><path>tests/TestCase/Error/ExceptionRendererTest.php
<ide> public function testError400AsJson()
<ide> 'url' => '/posts/view/1000?sort=title&direction=desc',
<ide> 'code' => 404,
<ide> 'file' => __FILE__,
<del> 'line' => $exceptionLine
<add> 'line' => $exceptionLine,
<ide> ];
<ide> $this->assertEquals($expected, json_decode($result, true));
<ide> $this->assertEquals(404, $response->getStatusCode());
<ide> public static function exceptionProvider()
<ide> ]),
<ide> [
<ide> '/Missing Method in PostsController/',
<del> '/<em>PostsController::index\(\)<\/em>/'
<add> '/<em>PostsController::index\(\)<\/em>/',
<ide> ],
<del> 404
<add> 404,
<ide> ],
<ide> [
<ide> new MissingActionException([
<ide> public static function exceptionProvider()
<ide> ]),
<ide> [
<ide> '/Missing Method in PostsController/',
<del> '/<em>PostsController::index\(\)<\/em>/'
<add> '/<em>PostsController::index\(\)<\/em>/',
<ide> ],
<del> 404
<add> 404,
<ide> ],
<ide> [
<ide> new MissingTemplateException(['file' => '/posts/about.ctp']),
<ide> [
<del> "/posts\/about.ctp/"
<add> "/posts\/about.ctp/",
<ide> ],
<del> 500
<add> 500,
<ide> ],
<ide> [
<ide> new MissingLayoutException(['file' => 'layouts/my_layout.ctp']),
<ide> [
<ide> '/Missing Layout/',
<del> "/layouts\/my_layout.ctp/"
<add> "/layouts\/my_layout.ctp/",
<ide> ],
<del> 500
<add> 500,
<ide> ],
<ide> [
<ide> new MissingHelperException(['class' => 'MyCustomHelper']),
<ide> [
<ide> '/Missing Helper/',
<ide> '/<em>MyCustomHelper<\/em> could not be found./',
<ide> '/Create the class <em>MyCustomHelper<\/em> below in file:/',
<del> '/(\/|\\\)MyCustomHelper.php/'
<add> '/(\/|\\\)MyCustomHelper.php/',
<ide> ],
<del> 500
<add> 500,
<ide> ],
<ide> [
<ide> new MissingBehaviorException(['class' => 'MyCustomBehavior']),
<ide> [
<ide> '/Missing Behavior/',
<ide> '/Create the class <em>MyCustomBehavior<\/em> below in file:/',
<del> '/(\/|\\\)MyCustomBehavior.php/'
<add> '/(\/|\\\)MyCustomBehavior.php/',
<ide> ],
<del> 500
<add> 500,
<ide> ],
<ide> [
<ide> new MissingComponentException(['class' => 'SideboxComponent']),
<ide> [
<ide> '/Missing Component/',
<ide> '/Create the class <em>SideboxComponent<\/em> below in file:/',
<del> '/(\/|\\\)SideboxComponent.php/'
<add> '/(\/|\\\)SideboxComponent.php/',
<ide> ],
<del> 500
<add> 500,
<ide> ],
<ide> [
<ide> new MissingDatasourceConfigException(['name' => 'MyDatasourceConfig']),
<ide> [
<ide> '/Missing Datasource Configuration/',
<del> '/<em>MyDatasourceConfig<\/em> was not found/'
<add> '/<em>MyDatasourceConfig<\/em> was not found/',
<ide> ],
<del> 500
<add> 500,
<ide> ],
<ide> [
<ide> new MissingDatasourceException(['class' => 'MyDatasource', 'plugin' => 'MyPlugin']),
<ide> [
<ide> '/Missing Datasource/',
<del> '/<em>MyPlugin.MyDatasource<\/em> could not be found./'
<add> '/<em>MyPlugin.MyDatasource<\/em> could not be found./',
<ide> ],
<del> 500
<add> 500,
<ide> ],
<ide> [
<ide> new MissingMailerActionException([
<ide> public static function exceptionProvider()
<ide> ]),
<ide> [
<ide> '/Missing Method in UserMailer/',
<del> '/<em>UserMailer::welcome\(\)<\/em>/'
<add> '/<em>UserMailer::welcome\(\)<\/em>/',
<ide> ],
<del> 404
<add> 404,
<ide> ],
<ide> [
<ide> new Exception('boom'),
<ide> [
<del> '/Internal Error/'
<add> '/Internal Error/',
<ide> ],
<del> 500
<add> 500,
<ide> ],
<ide> [
<ide> new RuntimeException('another boom'),
<ide> [
<del> '/Internal Error/'
<add> '/Internal Error/',
<ide> ],
<del> 500
<add> 500,
<ide> ],
<ide> [
<ide> new CakeException('base class'),
<ide> ['/Internal Error/'],
<del> 500
<add> 500,
<ide> ],
<ide> [
<ide> new HttpException('Network Authentication Required', 511),
<ide> ['/Network Authentication Required/'],
<del> 511
<add> 511,
<ide> ],
<ide> ];
<ide> }
<ide> public function testRenderInheritRoutingParams()
<ide> 'plugin' => null,
<ide> 'pass' => [],
<ide> '_ext' => 'json',
<del> ]
<add> ],
<ide> ]);
<ide> // Simulate a request having routing applied and stored in router
<ide> Router::pushRequest($routerRequest);
<ide><path>tests/TestCase/Error/Middleware/ErrorHandlerMiddlewareTest.php
<ide> public function setUp()
<ide>
<ide> Log::reset();
<ide> Log::setConfig('error_test', [
<del> 'engine' => $this->logger
<add> 'engine' => $this->logger,
<ide> ]);
<ide> }
<ide>
<ide> public function testHandleExceptionLogAndTrace()
<ide>
<ide> $request = ServerRequestFactory::fromGlobals([
<ide> 'REQUEST_URI' => '/target/url',
<del> 'HTTP_REFERER' => '/other/path'
<add> 'HTTP_REFERER' => '/other/path',
<ide> ]);
<ide> $response = new Response();
<ide> $middleware = new ErrorHandlerMiddleware(null, ['log' => true, 'trace' => true]);
<ide> public function testHandleExceptionLogAndTraceWithPrevious()
<ide>
<ide> $request = ServerRequestFactory::fromGlobals([
<ide> 'REQUEST_URI' => '/target/url',
<del> 'HTTP_REFERER' => '/other/path'
<add> 'HTTP_REFERER' => '/other/path',
<ide> ]);
<ide> $response = new Response();
<ide> $middleware = new ErrorHandlerMiddleware(null, ['log' => true, 'trace' => true]);
<ide> public function testHandleExceptionSkipLog()
<ide> $response = new Response();
<ide> $middleware = new ErrorHandlerMiddleware(null, [
<ide> 'log' => true,
<del> 'skipLog' => ['Cake\Http\Exception\NotFoundException']
<add> 'skipLog' => ['Cake\Http\Exception\NotFoundException'],
<ide> ]);
<ide> $next = function ($req, $res) {
<ide> throw new \Cake\Http\Exception\NotFoundException('Kaboom!');
<ide><path>tests/TestCase/Event/Decorator/ConditionDecoratorTest.php
<ide> public function testCanTriggerIf()
<ide> $decorator = new ConditionDecorator($callable, [
<ide> 'if' => function (Event $event) {
<ide> return $event->getData('canTrigger');
<del> }
<add> },
<ide> ]);
<ide>
<ide> $event = new Event('decorator.test', $this);
<ide> public function testCascadingEvents()
<ide> $listener1 = new ConditionDecorator($callable, [
<ide> 'if' => function (Event $event) {
<ide> return false;
<del> }
<add> },
<ide> ]);
<ide>
<ide> $listener2 = function (Event $event) {
<ide> public function testCascadingEvents()
<ide> EventManager::instance()->on('decorator.test2', $listener2);
<ide>
<ide> $event = new Event('decorator.test2', $this, [
<del> 'counter' => 1
<add> 'counter' => 1,
<ide> ]);
<ide>
<ide> EventManager::instance()->dispatch($event);
<ide> public function testCallableRuntimeException()
<ide> };
<ide>
<ide> $decorator = new ConditionDecorator($callable, [
<del> 'if' => 'not a callable'
<add> 'if' => 'not a callable',
<ide> ]);
<ide>
<ide> $event = new Event('decorator.test', $this, []);
<ide><path>tests/TestCase/Event/Decorator/SubjectFilterDecoratorTest.php
<ide> public function testCanTrigger()
<ide> };
<ide>
<ide> $decorator = new SubjectFilterDecorator($callable, [
<del> 'allowedSubject' => self::class
<add> 'allowedSubject' => self::class,
<ide> ]);
<ide>
<ide> $this->assertTrue($decorator->canTrigger($event));
<ide> $this->assertEquals('success', $decorator($event));
<ide>
<ide> $decorator = new SubjectFilterDecorator($callable, [
<del> 'allowedSubject' => '\Some\Other\Class'
<add> 'allowedSubject' => '\Some\Other\Class',
<ide> ]);
<ide>
<ide> $this->assertFalse($decorator->canTrigger($event));
<ide><path>tests/TestCase/Event/EventManagerTest.php
<ide> public function implementedEvents()
<ide> 'another.event' => ['callable' => 'secondListenerFunction'],
<ide> 'multiple.handlers' => [
<ide> ['callable' => 'listenerFunction'],
<del> ['callable' => 'thirdListenerFunction']
<del> ]
<add> ['callable' => 'thirdListenerFunction'],
<add> ],
<ide> ];
<ide> }
<ide>
<ide> public function testAttachListeners()
<ide> $manager = new EventManager();
<ide> $manager->attach('fakeFunction', 'fake.event');
<ide> $expected = [
<del> ['callable' => 'fakeFunction']
<add> ['callable' => 'fakeFunction'],
<ide> ];
<ide> $this->assertEquals($expected, $manager->listeners('fake.event'));
<ide>
<ide> public function testAttachListeners()
<ide> [
<ide> ['callable' => 'inQ1'],
<ide> ['callable' => 'inQ5'],
<del> ['callable' => 'otherInQ5']
<add> ['callable' => 'otherInQ5'],
<ide> ],
<ide> $expected
<ide> );
<ide> public function testAttachMultipleEventKeys()
<ide> $manager->attach('fakeFunction2', 'another.event');
<ide> $manager->attach('fakeFunction3', 'another.event', ['priority' => 1]);
<ide> $expected = [
<del> ['callable' => 'fakeFunction']
<add> ['callable' => 'fakeFunction'],
<ide> ];
<ide> $this->assertEquals($expected, $manager->listeners('fake.event'));
<ide>
<ide> $expected = [
<ide> ['callable' => 'fakeFunction3'],
<del> ['callable' => 'fakeFunction2']
<add> ['callable' => 'fakeFunction2'],
<ide> ];
<ide> $this->assertEquals($expected, $manager->listeners('another.event'));
<ide> });
<ide> public function testOn()
<ide> $manager = new EventManager();
<ide> $manager->on('my.event', 'myfunc');
<ide> $expected = [
<del> ['callable' => 'myfunc']
<add> ['callable' => 'myfunc'],
<ide> ];
<ide> $this->assertSame($expected, $manager->listeners('my.event'));
<ide>
<ide> public function testOff()
<ide>
<ide> $manager->off('another.event', ['AClass', 'anotherMethod']);
<ide> $expected = [
<del> ['callable' => 'fakeFunction']
<add> ['callable' => 'fakeFunction'],
<ide> ];
<ide> $this->assertEquals($expected, $manager->listeners('another.event'));
<ide>
<ide> public function testOffFromAll()
<ide>
<ide> $manager->off(['AClass', 'aMethod']);
<ide> $expected = [
<del> ['callable' => 'fakeFunction']
<add> ['callable' => 'fakeFunction'],
<ide> ];
<ide> $this->assertEquals($expected, $manager->listeners('another.event'));
<ide> $this->assertEquals([], $manager->listeners('fake.event'));
<ide> public function testRemoveAllListeners()
<ide> $manager->off('fake.event');
<ide>
<ide> $expected = [
<del> ['callable' => 'fakeFunction']
<add> ['callable' => 'fakeFunction'],
<ide> ];
<ide> $this->assertEquals($expected, $manager->listeners('another.event'));
<ide> $this->assertEquals([], $manager->listeners('fake.event'));
<ide> public function testDetach()
<ide>
<ide> $manager->detach(['AClass', 'anotherMethod'], 'another.event');
<ide> $expected = [
<del> ['callable' => 'fakeFunction']
<add> ['callable' => 'fakeFunction'],
<ide> ];
<ide> $this->assertEquals($expected, $manager->listeners('another.event'));
<ide>
<ide> public function testDetachFromAll()
<ide>
<ide> $manager->detach(['AClass', 'aMethod']);
<ide> $expected = [
<del> ['callable' => 'fakeFunction']
<add> ['callable' => 'fakeFunction'],
<ide> ];
<ide> $this->assertEquals($expected, $manager->listeners('another.event'));
<ide> $this->assertEquals([], $manager->listeners('fake.event'));
<ide> public function testDetachSubscriber()
<ide> ->getMock();
<ide> $manager->on($listener);
<ide> $expected = [
<del> ['callable' => [$listener, 'secondListenerFunction']]
<add> ['callable' => [$listener, 'secondListenerFunction']],
<ide> ];
<ide> $this->assertEquals($expected, $manager->listeners('another.event'));
<ide> $expected = [
<del> ['callable' => [$listener, 'listenerFunction']]
<add> ['callable' => [$listener, 'listenerFunction']],
<ide> ];
<ide> $this->assertEquals($expected, $manager->listeners('fake.event'));
<ide> $manager->off($listener);
<ide> public function testDispatchPrioritizedWithGlobal()
<ide> ->with('fake.event')
<ide> ->will($this->returnValue(
<ide> [11 => [
<del> ['callable' => [$listener, 'secondListenerFunction']]
<add> ['callable' => [$listener, 'secondListenerFunction']],
<ide> ]]
<ide> ));
<ide>
<ide> public function testDispatchGlobalBeforeLocal()
<ide> ->with('fake.event')
<ide> ->will($this->returnValue(
<ide> [10 => [
<del> ['callable' => [$listener, 'listenerFunction']]
<add> ['callable' => [$listener, 'listenerFunction']],
<ide> ]]
<ide> ));
<ide>
<ide> public function testDebugInfo()
<ide> '_trackEvents' => true,
<ide> '_generalManager' => '(object) EventManager',
<ide> '_dispatchedEvents' => [
<del> 'Foo with subject Cake\Test\TestCase\Event\EventManagerTest'
<add> 'Foo with subject Cake\Test\TestCase\Event\EventManagerTest',
<ide> ],
<ide> ],
<ide> $eventManager->__debugInfo()
<ide><path>tests/TestCase/Filesystem/FileTest.php
<ide> public function testBasic()
<ide> 'basename' => basename($file),
<ide> 'filename' => 'LICENSE',
<ide> 'filesize' => filesize($file),
<del> 'mime' => 'text/plain'
<add> 'mime' => 'text/plain',
<ide> ];
<ide> if (!function_exists('finfo_open') &&
<ide> (!function_exists('mime_content_type') ||
<ide><path>tests/TestCase/Filesystem/FolderTest.php
<ide> public function inPathInvalidPathArgumentDataProvider()
<ide> return [
<ide> [''],
<ide> ['relative/path/'],
<del> ['unknown://stream-wrapper']
<add> ['unknown://stream-wrapper'],
<ide> ];
<ide> }
<ide>
<ide> public function testFolderReadWithHiddenFiles()
<ide> $expected = [
<ide> [
<ide> '.svn',
<del> 'some_folder'
<add> 'some_folder',
<ide> ],
<ide> [
<ide> '.hidden.txt',
<del> 'not_hidden.txt'
<add> 'not_hidden.txt',
<ide> ],
<ide> ];
<ide> $result = $Folder->read(true);
<ide> public function testFolderSubdirectories()
<ide> $expected = [
<ide> $path . DS . 'Exception',
<ide> $path . DS . 'Http',
<del> $path . DS . 'Session'
<add> $path . DS . 'Session',
<ide> ];
<ide> $result = $folder->subdirectories();
<ide> $this->assertSame([], array_diff($expected, $result));
<ide> public function testFolderSubdirectories()
<ide> $expected = [
<ide> 'Exception',
<ide> 'Http',
<del> 'Session'
<add> 'Session',
<ide> ];
<ide> $result = $folder->subdirectories(null, false);
<ide> $this->assertSame([], array_diff($expected, $result));
<ide> public function testFolderTree()
<ide> ],
<ide> [
<ide> CORE_PATH . 'config' . DS . 'config.php',
<del> ]
<add> ],
<ide> ];
<ide>
<ide> $result = $Folder->tree(CORE_PATH . 'config', false);
<ide> public function testFindRecursive()
<ide> $Folder = new Folder(CORE_PATH . 'config');
<ide> $result = $Folder->findRecursive('(config|paths)\.php');
<ide> $expected = [
<del> CORE_PATH . 'config' . DS . 'config.php'
<add> CORE_PATH . 'config' . DS . 'config.php',
<ide> ];
<ide> $this->assertSame([], array_diff($expected, $result));
<ide>
<ide> $result = $Folder->findRecursive('(config|bootstrap)\.php', true);
<ide> $expected = [
<ide> CORE_PATH . 'config' . DS . 'bootstrap.php',
<del> CORE_PATH . 'config' . DS . 'config.php'
<add> CORE_PATH . 'config' . DS . 'config.php',
<ide> ];
<ide> $this->assertSame($expected, $result);
<ide>
<ide> public function testFindRecursive()
<ide> $result = $Folder->findRecursive('(paths|my)\.php');
<ide> $expected = [
<ide> $path . 'testme' . DS . 'my.php',
<del> $path . 'testme' . DS . 'paths.php'
<add> $path . 'testme' . DS . 'paths.php',
<ide> ];
<ide> $this->assertSame(sort($expected), sort($result));
<ide>
<ide> $result = $Folder->findRecursive('(paths|my)\.php', true);
<ide> $expected = [
<ide> $path . 'testme' . DS . 'my.php',
<del> $path . 'testme' . DS . 'paths.php'
<add> $path . 'testme' . DS . 'paths.php',
<ide> ];
<ide> $this->assertSame($expected, $result);
<ide> }
<ide> public function testDelete()
<ide> $path . DS . 'level_1_1' . DS . 'level_2_1 removed',
<ide> $path . DS . 'level_1_1' . DS . 'level_2_2 removed',
<ide> $path . DS . 'level_1_1 removed',
<del> $path . ' removed'
<add> $path . ' removed',
<ide> ];
<ide> sort($expected);
<ide> sort($messages);
<ide><path>tests/TestCase/Form/FormTest.php
<ide> public function testValidate()
<ide>
<ide> $data = [
<ide> 'email' => 'rong',
<del> 'body' => 'too short'
<add> 'body' => 'too short',
<ide> ];
<ide> $this->assertFalse($form->validate($data));
<ide> $this->assertCount(2, $form->getErrors());
<ide>
<ide> $data = [
<ide> 'email' => '[email protected]',
<del> 'body' => 'Some content goes here'
<add> 'body' => 'Some content goes here',
<ide> ];
<ide> $this->assertTrue($form->validate($data));
<ide> $this->assertCount(0, $form->getErrors());
<ide> public function testErrors()
<ide> $form->getValidator()
<ide> ->add('email', 'format', [
<ide> 'message' => 'Must be a valid email',
<del> 'rule' => 'email'
<add> 'rule' => 'email',
<ide> ])
<ide> ->add('body', 'length', [
<ide> 'message' => 'Must be so long',
<ide> public function testErrors()
<ide>
<ide> $data = [
<ide> 'email' => 'rong',
<del> 'body' => 'too short'
<add> 'body' => 'too short',
<ide> ];
<ide> $form->validate($data);
<ide> $errors = $form->errors();
<ide> public function testGetErrors()
<ide> $form->getValidator()
<ide> ->add('email', 'format', [
<ide> 'message' => 'Must be a valid email',
<del> 'rule' => 'email'
<add> 'rule' => 'email',
<ide> ])
<ide> ->add('body', 'length', [
<ide> 'message' => 'Must be so long',
<ide> public function testGetErrors()
<ide>
<ide> $data = [
<ide> 'email' => 'rong',
<del> 'body' => 'too short'
<add> 'body' => 'too short',
<ide> ];
<ide> $form->validate($data);
<ide> $errors = $form->getErrors();
<ide> public function testSetErrors()
<ide> {
<ide> $form = new Form();
<ide> $expected = [
<del> 'field_name' => ['rule_name' => 'message']
<add> 'field_name' => ['rule_name' => 'message'],
<ide> ];
<ide>
<ide> $form->setErrors($expected);
<ide> public function testExecuteInvalid()
<ide> $form->getValidator()
<ide> ->add('email', 'format', ['rule' => 'email']);
<ide> $data = [
<del> 'email' => 'rong'
<add> 'email' => 'rong',
<ide> ];
<ide> $form->expects($this->never())
<ide> ->method('_execute');
<ide> public function testExecuteValid()
<ide> $form->getValidator()
<ide> ->add('email', 'format', ['rule' => 'email']);
<ide> $data = [
<del> 'email' => '[email protected]'
<add> 'email' => '[email protected]',
<ide> ];
<ide> $form->expects($this->once())
<ide> ->method('_execute')
<ide><path>tests/TestCase/Form/SchemaTest.php
<ide> public function testAddingMultipleFields()
<ide> $schema = new Schema();
<ide> $schema->addFields([
<ide> 'email' => 'string',
<del> 'body' => ['type' => 'string', 'length' => 1000]
<add> 'body' => ['type' => 'string', 'length' => 1000],
<ide> ]);
<ide> $this->assertEquals(['email', 'body'], $schema->fields());
<ide> $this->assertEquals('string', $schema->field('email')['type']);
<ide> public function testFieldType()
<ide> $schema->addField('name', 'string')
<ide> ->addField('numbery', [
<ide> 'type' => 'decimal',
<del> 'required' => true
<add> 'required' => true,
<ide> ]);
<ide> $this->assertEquals('string', $schema->fieldType('name'));
<ide> $this->assertEquals('decimal', $schema->fieldType('numbery'));
<ide> public function testDebugInfo()
<ide> $schema->addField('name', 'string')
<ide> ->addField('numbery', [
<ide> 'type' => 'decimal',
<del> 'required' => true
<add> 'required' => true,
<ide> ]);
<ide> $result = $schema->__debugInfo();
<ide> $expected = [
<ide><path>tests/TestCase/Http/ActionDispatcherTest.php
<ide> public function testDispatchAfterDispatchEventModifyResponse()
<ide> 'action' => 'index',
<ide> 'pass' => [],
<ide> ],
<del> 'session' => new Session()
<add> 'session' => new Session(),
<ide> ]);
<ide> $res = new Response();
<ide> $this->dispatcher->getEventManager()->on('Dispatcher.afterDispatch', function (Event $event) {
<ide> public function testDispatchAutoRender()
<ide> 'controller' => 'Posts',
<ide> 'action' => 'index',
<ide> 'pass' => [],
<del> ]
<add> ],
<ide> ]);
<ide> $response = new Response();
<ide> $result = $this->dispatcher->dispatch($request, $response);
<ide> public function testDispatchAutoRenderFalse()
<ide> 'controller' => 'Cakes',
<ide> 'action' => 'noRender',
<ide> 'pass' => [],
<del> ]
<add> ],
<ide> ]);
<ide> $response = new Response();
<ide> $result = $this->dispatcher->dispatch($request, $response);
<ide> public function testMissingController()
<ide> 'params' => [
<ide> 'controller' => 'SomeController',
<ide> 'action' => 'home',
<del> ]
<add> ],
<ide> ]);
<ide> $response = $this->getMockBuilder('Cake\Http\Response')->getMock();
<ide> $this->dispatcher->dispatch($request, $response);
<ide> public function testMissingControllerInterface()
<ide> 'params' => [
<ide> 'controller' => 'Interface',
<ide> 'action' => 'index',
<del> ]
<add> ],
<ide> ]);
<ide> $response = $this->getMockBuilder('Cake\Http\Response')->getMock();
<ide> $this->dispatcher->dispatch($request, $response);
<ide> public function testMissingControllerAbstract()
<ide> 'params' => [
<ide> 'controller' => 'Abstract',
<ide> 'action' => 'index',
<del> ]
<add> ],
<ide> ]);
<ide> $response = $this->getMockBuilder('Cake\Http\Response')->getMock();
<ide> $this->dispatcher->dispatch($request, $response);
<ide> public function testMissingControllerLowercase()
<ide> 'controller' => 'somepages',
<ide> 'action' => 'display',
<ide> 'pass' => ['home'],
<del> ]
<add> ],
<ide> ]);
<ide> $response = $this->getMockBuilder('Cake\Http\Response')->getMock();
<ide> $this->dispatcher->dispatch($request, $response);
<ide> public function testStartupProcessAbort()
<ide> 'action' => 'index',
<ide> 'stop' => 'startup',
<ide> 'pass' => [],
<del> ]
<add> ],
<ide> ]);
<ide> $response = new Response();
<ide> $result = $this->dispatcher->dispatch($request, $response);
<ide> public function testShutdownProcessResponse()
<ide> 'action' => 'index',
<ide> 'stop' => 'shutdown',
<ide> 'pass' => [],
<del> ]
<add> ],
<ide> ]);
<ide> $response = new Response();
<ide> $result = $this->dispatcher->dispatch($request, $response);
<ide><path>tests/TestCase/Http/BaseApplicationTest.php
<ide> public function testInvoke()
<ide> 'controller' => 'Cakes',
<ide> 'action' => 'index',
<ide> 'plugin' => null,
<del> 'pass' => []
<add> 'pass' => [],
<ide> ]);
<ide>
<ide> $app = $this->getMockForAbstractClass(BaseApplication::class, [$this->path]);
<ide> public function testPluginRoutes()
<ide> 'plugin' => 'TestPlugin',
<ide> 'controller' => 'TestPlugin',
<ide> 'action' => 'index',
<del> '_method' => 'GET'
<add> '_method' => 'GET',
<ide> ];
<ide> $this->assertNotEmpty($collection->match($url, []));
<ide> }
<ide><path>tests/TestCase/Http/Client/Adapter/CurlTest.php
<ide> public function testSendLive()
<ide> {
<ide> $request = new Request('http://localhost', 'GET', [
<ide> 'User-Agent' => 'CakePHP TestSuite',
<del> 'Cookie' => 'testing=value'
<add> 'Cookie' => 'testing=value',
<ide> ]);
<ide> try {
<ide> $responses = $this->curl->send($request, []);
<ide> public function testSendLiveResponseCheck()
<ide> public function testBuildOptionsGet()
<ide> {
<ide> $options = [
<del> 'timeout' => 5
<add> 'timeout' => 5,
<ide> ];
<ide> $request = new Request(
<ide> 'http://localhost/things',
<ide> public function testBuildOptionsProxy()
<ide> 'proxy' => '127.0.0.1:8080',
<ide> 'username' => 'frodo',
<ide> 'password' => 'one_ring',
<del> ]
<add> ],
<ide> ];
<ide> $request = new Request('http://localhost/things', 'GET');
<ide> $result = $this->curl->buildOptions($request, $options);
<ide> public function testBuildOptionsCurlOptions()
<ide> {
<ide> $options = [
<ide> 'curl' => [
<del> CURLOPT_USERAGENT => 'Super-secret'
<del> ]
<add> CURLOPT_USERAGENT => 'Super-secret',
<add> ],
<ide> ];
<ide> $request = new Request('http://localhost/things', 'GET');
<ide> $request = $request->withProtocolVersion('1.0');
<ide> public function testBuildOptionsCurlOptions()
<ide> ],
<ide> CURLOPT_HTTPGET => true,
<ide> CURLOPT_CAINFO => $this->caFile,
<del> CURLOPT_USERAGENT => 'Super-secret'
<add> CURLOPT_USERAGENT => 'Super-secret',
<ide> ];
<ide> $this->assertSame($expected, $result);
<ide> }
<ide><path>tests/TestCase/Http/Client/Adapter/StreamTest.php
<ide> public function testSend()
<ide> $stream = new Stream();
<ide> $request = new Request('http://localhost', 'GET', [
<ide> 'User-Agent' => 'CakePHP TestSuite',
<del> 'Cookie' => 'testing=value'
<add> 'Cookie' => 'testing=value',
<ide> ]);
<ide>
<ide> try {
<ide> public function testBuildingContextHeader()
<ide> [
<ide> 'User-Agent' => 'CakePHP TestSuite',
<ide> 'Content-Type' => 'application/json',
<del> 'Cookie' => 'a=b; c=do%20it'
<add> 'Cookie' => 'a=b; c=do%20it',
<ide> ]
<ide> );
<ide>
<ide> public function testSendContextContentString()
<ide> );
<ide>
<ide> $options = [
<del> 'redirect' => 20
<add> 'redirect' => 20,
<ide> ];
<ide> $this->stream->send($request, $options);
<ide> $result = $this->stream->contextOptions();
<ide> public function testSendContextContentArray()
<ide> 'http://localhost',
<ide> 'GET',
<ide> [
<del> 'Content-Type' => 'application/json'
<add> 'Content-Type' => 'application/json',
<ide> ],
<ide> ['a' => 'my value']
<ide> );
<ide> public function testSendContextSsl()
<ide> 'ssl_verify_depth' => 9000,
<ide> 'ssl_allow_self_signed' => false,
<ide> 'proxy' => [
<del> 'proxy' => '127.0.0.1:8080'
<del> ]
<add> 'proxy' => '127.0.0.1:8080',
<add> ],
<ide> ];
<ide>
<ide> $this->stream->send($request, $options);
<ide> public function testSendContextSslNoVerifyPeerName()
<ide> 'ssl_verify_depth' => 9000,
<ide> 'ssl_allow_self_signed' => false,
<ide> 'proxy' => [
<del> 'proxy' => '127.0.0.1:8080'
<del> ]
<add> 'proxy' => '127.0.0.1:8080',
<add> ],
<ide> ];
<ide>
<ide> $this->stream->send($request, $options);
<ide><path>tests/TestCase/Http/Client/Auth/DigestTest.php
<ide> protected function getClientMock()
<ide> public function testRealmAndNonceFromExtraRequest()
<ide> {
<ide> $headers = [
<del> 'WWW-Authenticate: Digest realm="The batcave",nonce="4cded326c6c51"'
<add> 'WWW-Authenticate: Digest realm="The batcave",nonce="4cded326c6c51"',
<ide> ];
<ide>
<ide> $response = new Response($headers, '');
<ide> public function testRealmAndNonceFromExtraRequest()
<ide> public function testQop()
<ide> {
<ide> $headers = [
<del> 'WWW-Authenticate: Digest realm="The batcave",nonce="4cded326c6c51",qop="auth"'
<add> 'WWW-Authenticate: Digest realm="The batcave",nonce="4cded326c6c51",qop="auth"',
<ide> ];
<ide>
<ide> $response = new Response($headers, '');
<ide> public function testQop()
<ide> public function testOpaque()
<ide> {
<ide> $headers = [
<del> 'WWW-Authenticate: Digest realm="The batcave",nonce="4cded326c6c51",opaque="d8ea7aa61a1693024c4cc3a516f49b3c"'
<add> 'WWW-Authenticate: Digest realm="The batcave",nonce="4cded326c6c51",opaque="d8ea7aa61a1693024c4cc3a516f49b3c"',
<ide> ];
<ide>
<ide> $response = new Response($headers, '');
<ide><path>tests/TestCase/Http/Client/Auth/OauthTest.php
<ide> public function testBaseStringWithPostDataNestedArrays()
<ide> 'search' => [
<ide> 'filters' => [
<ide> 'field' => 'date',
<del> 'value' => 'one two'
<del> ]
<del> ]
<add> 'value' => 'one two',
<add> ],
<add> ],
<ide> ]
<ide> );
<ide>
<ide> public function testBaseStringWithPostData()
<ide> [
<ide> 'address' => 'post',
<ide> 'zed' => 'last',
<del> 'tags' => ['oauth', 'cake']
<add> 'tags' => ['oauth', 'cake'],
<ide> ]
<ide> );
<ide>
<ide> public function testHmacSigning()
<ide> 'tokenSecret' => 'pfkkdhi9sl3r4s00',
<ide> 'token' => 'nnch734d00sl2jdk',
<ide> 'nonce' => 'kllo9940pd9333jh',
<del> 'timestamp' => '1191242096'
<add> 'timestamp' => '1191242096',
<ide> ];
<ide> $auth = new Oauth();
<ide> $request = $auth->authentication($request, $options);
<ide> public function testRsaSigningString()
<ide> 'consumerKey' => 'dpf43f3p2l4k3l03',
<ide> 'nonce' => '13917289812797014437',
<ide> 'timestamp' => '1196666512',
<del> 'privateKey' => $privateKey
<add> 'privateKey' => $privateKey,
<ide> ];
<ide> $auth = new Oauth();
<ide> $request = $auth->authentication($request, $options);
<ide> public function testRsaSigningFile()
<ide> 'consumerKey' => 'dpf43f3p2l4k3l03',
<ide> 'nonce' => '13917289812797014437',
<ide> 'timestamp' => '1196666512',
<del> 'privateKey' => $privateKey
<add> 'privateKey' => $privateKey,
<ide> ];
<ide> $auth = new Oauth();
<ide> $request = $auth->authentication($request, $options);
<ide><path>tests/TestCase/Http/Client/FormDataTest.php
<ide> public function testAddMany()
<ide> 'key' => 'value',
<ide> 'empty' => '',
<ide> 'int' => '1',
<del> 'float' => '2.3'
<add> 'float' => '2.3',
<ide> ];
<ide> $data->addMany($array);
<ide> $this->assertCount(4, $data);
<ide> public function testAddArray()
<ide> $data->add('Article', [
<ide> 'title' => 'first post',
<ide> 'published' => 'Y',
<del> 'tags' => ['blog', 'cakephp']
<add> 'tags' => ['blog', 'cakephp'],
<ide> ]);
<ide> $result = (string)$data;
<ide> $expected = 'Article%5Btitle%5D=first+post&Article%5Bpublished%5D=Y&' .
<ide><path>tests/TestCase/Http/Client/RequestTest.php
<ide> public function testBodyArray()
<ide> $data = [
<ide> 'a' => 'b',
<ide> 'c' => 'd',
<del> 'e' => ['f', 'g']
<add> 'e' => ['f', 'g'],
<ide> ];
<ide> $request->body($data);
<ide> $this->assertEquals('application/x-www-form-urlencoded', $request->getHeaderLine('content-type'));
<ide> public function testHeader()
<ide>
<ide> $result = $request->header([
<ide> 'Connection' => 'close',
<del> 'user-agent' => 'CakePHP'
<add> 'user-agent' => 'CakePHP',
<ide> ]);
<ide> $this->assertSame($result, $request, 'Should return self');
<ide>
<ide><path>tests/TestCase/Http/Client/ResponseTest.php
<ide> public function testBody()
<ide> {
<ide> $this->deprecated(function () {
<ide> $data = [
<del> 'property' => 'value'
<add> 'property' => 'value',
<ide> ];
<ide> $encoded = json_encode($data);
<ide>
<ide> public function getStringBody()
<ide> public function testBodyJson()
<ide> {
<ide> $data = [
<del> 'property' => 'value'
<add> 'property' => 'value',
<ide> ];
<ide> $encoded = json_encode($data);
<ide> $response = new Response([], $encoded);
<ide> public function testBodyJson()
<ide> public function testBodyJsonPsr7()
<ide> {
<ide> $data = [
<del> 'property' => 'value'
<add> 'property' => 'value',
<ide> ];
<ide> $encoded = json_encode($data);
<ide> $response = new Response([], '');
<ide> public function testIsOk()
<ide> {
<ide> $headers = [
<ide> 'HTTP/1.1 200 OK',
<del> 'Content-Type: text/html'
<add> 'Content-Type: text/html',
<ide> ];
<ide> $response = new Response($headers, 'ok');
<ide> $this->assertTrue($response->isOk());
<ide>
<ide> $headers = [
<ide> 'HTTP/1.1 201 Created',
<del> 'Content-Type: text/html'
<add> 'Content-Type: text/html',
<ide> ];
<ide> $response = new Response($headers, 'ok');
<ide> $this->assertTrue($response->isOk());
<ide>
<ide> $headers = [
<ide> 'HTTP/1.1 202 Accepted',
<del> 'Content-Type: text/html'
<add> 'Content-Type: text/html',
<ide> ];
<ide> $response = new Response($headers, 'ok');
<ide> $this->assertTrue($response->isOk());
<ide>
<ide> $headers = [
<ide> 'HTTP/1.1 203 Non-Authoritative Information',
<del> 'Content-Type: text/html'
<add> 'Content-Type: text/html',
<ide> ];
<ide> $response = new Response($headers, 'ok');
<ide> $this->assertTrue($response->isOk());
<ide>
<ide> $headers = [
<ide> 'HTTP/1.1 204 No Content',
<del> 'Content-Type: text/html'
<add> 'Content-Type: text/html',
<ide> ];
<ide> $response = new Response($headers, 'ok');
<ide> $this->assertTrue($response->isOk());
<ide>
<ide> $headers = [
<ide> 'HTTP/1.1 301 Moved Permanently',
<del> 'Content-Type: text/html'
<add> 'Content-Type: text/html',
<ide> ];
<ide> $response = new Response($headers, '');
<ide> $this->assertFalse($response->isOk());
<ide>
<ide> $headers = [
<ide> 'HTTP/1.0 404 Not Found',
<del> 'Content-Type: text/html'
<add> 'Content-Type: text/html',
<ide> ];
<ide> $response = new Response($headers, '');
<ide> $this->assertFalse($response->isOk());
<ide> public function testIsRedirect()
<ide> {
<ide> $headers = [
<ide> 'HTTP/1.1 200 OK',
<del> 'Content-Type: text/html'
<add> 'Content-Type: text/html',
<ide> ];
<ide> $response = new Response($headers, 'ok');
<ide> $this->assertFalse($response->isRedirect());
<ide>
<ide> $headers = [
<ide> 'HTTP/1.1 301 Moved Permanently',
<ide> 'Location: /',
<del> 'Content-Type: text/html'
<add> 'Content-Type: text/html',
<ide> ];
<ide> $response = new Response($headers, '');
<ide> $this->assertTrue($response->isRedirect());
<ide>
<ide> $headers = [
<ide> 'HTTP/1.0 404 Not Found',
<del> 'Content-Type: text/html'
<add> 'Content-Type: text/html',
<ide> ];
<ide> $response = new Response($headers, '');
<ide> $this->assertFalse($response->isRedirect());
<ide> public function testGetStatusCode()
<ide> {
<ide> $headers = [
<ide> 'HTTP/1.0 404 Not Found',
<del> 'Content-Type: text/html'
<add> 'Content-Type: text/html',
<ide> ];
<ide> $response = new Response($headers, '');
<ide> $this->assertSame(404, $response->getStatusCode());
<ide> public function testStatusCode()
<ide> $this->deprecated(function () {
<ide> $headers = [
<ide> 'HTTP/1.0 404 Not Found',
<del> 'Content-Type: text/html'
<add> 'Content-Type: text/html',
<ide> ];
<ide> $response = new Response($headers, '');
<ide> $this->assertSame(404, $response->statusCode());
<ide> public function testGetEncoding()
<ide>
<ide> $headers = [
<ide> 'HTTP/1.0 200 Ok',
<del> 'Content-Type: text/html'
<add> 'Content-Type: text/html',
<ide> ];
<ide> $response = new Response($headers, '');
<ide> $this->assertNull($response->getEncoding());
<ide>
<ide> $headers = [
<ide> 'HTTP/1.0 200 Ok',
<del> 'Content-Type: text/html; charset="UTF-8"'
<add> 'Content-Type: text/html; charset="UTF-8"',
<ide> ];
<ide> $response = new Response($headers, '');
<ide> $this->assertEquals('UTF-8', $response->getEncoding());
<ide>
<ide> $headers = [
<ide> 'HTTP/1.0 200 Ok',
<del> "Content-Type: text/html; charset='ISO-8859-1'"
<add> "Content-Type: text/html; charset='ISO-8859-1'",
<ide> ];
<ide> $response = new Response($headers, '');
<ide> $this->assertEquals('ISO-8859-1', $response->getEncoding());
<ide> public function testEncoding()
<ide>
<ide> $headers = [
<ide> 'HTTP/1.0 200 Ok',
<del> 'Content-Type: text/html'
<add> 'Content-Type: text/html',
<ide> ];
<ide> $response = new Response($headers, '');
<ide> $this->assertNull($response->encoding());
<ide>
<ide> $headers = [
<ide> 'HTTP/1.0 200 Ok',
<del> 'Content-Type: text/html; charset="UTF-8"'
<add> 'Content-Type: text/html; charset="UTF-8"',
<ide> ];
<ide> $response = new Response($headers, '');
<ide> $this->assertEquals('UTF-8', $response->encoding());
<ide>
<ide> $headers = [
<ide> 'HTTP/1.0 200 Ok',
<del> "Content-Type: text/html; charset='ISO-8859-1'"
<add> "Content-Type: text/html; charset='ISO-8859-1'",
<ide> ];
<ide> $response = new Response($headers, '');
<ide> $this->assertEquals('ISO-8859-1', $response->encoding());
<ide> public function testAutoDecodeGzipBody()
<ide> 'HTTP/1.0 200 OK',
<ide> 'Content-Encoding: gzip',
<ide> 'Content-Length: 32',
<del> 'Content-Type: text/html; charset=UTF-8'
<add> 'Content-Type: text/html; charset=UTF-8',
<ide> ];
<ide> $body = base64_decode('H4sIAAAAAAAAA/NIzcnJVyjPL8pJUQQAlRmFGwwAAAA=');
<ide> $response = new Response($headers, $body);
<ide><path>tests/TestCase/Http/ClientTest.php
<ide> public function testConstructConfig()
<ide> }
<ide>
<ide> $result = $http->setConfig([
<del> 'auth' => ['username' => 'mark', 'password' => 'secret']
<add> 'auth' => ['username' => 'mark', 'password' => 'secret'],
<ide> ]);
<ide> $this->assertSame($result, $http);
<ide>
<ide> $result = $http->getConfig();
<ide> $expected = [
<ide> 'scheme' => 'http',
<ide> 'host' => 'example.org',
<del> 'auth' => ['username' => 'mark', 'password' => 'secret']
<add> 'auth' => ['username' => 'mark', 'password' => 'secret'],
<ide> ];
<ide> foreach ($expected as $key => $val) {
<ide> $this->assertEquals($val, $result[$key]);
<ide> public static function urlProvider()
<ide> 'http://example.com/test.html',
<ide> [],
<ide> null,
<del> 'Null options'
<add> 'Null options',
<ide> ],
<ide> [
<ide> 'http://example.com/test.html',
<ide> 'http://example.com/test.html',
<ide> [],
<ide> [],
<del> 'Simple string'
<add> 'Simple string',
<ide> ],
<ide> [
<ide> 'http://example.com/test.html',
<ide> public static function urlProvider()
<ide> '/test.html',
<ide> [],
<ide> ['host' => 'example.com', 'port' => '80'],
<del> 'standard port, does not display'
<add> 'standard port, does not display',
<ide> ],
<ide> [
<ide> 'https://example.com/test.html',
<ide> '/test.html',
<ide> [],
<ide> ['host' => 'example.com', 'scheme' => 'https', 'port' => '443'],
<del> 'standard port, does not display'
<add> 'standard port, does not display',
<ide> ],
<ide> [
<ide> 'http://example.com/test.html',
<ide> 'http://example.com/test.html',
<ide> [],
<ide> ['host' => 'example.com', 'scheme' => 'https'],
<del> 'options do not duplicate'
<add> 'options do not duplicate',
<ide> ],
<ide> [
<ide> 'http://example.com/search?q=hi+there&cat%5Bid%5D%5B0%5D=2&cat%5Bid%5D%5B1%5D=3',
<ide> 'http://example.com/search',
<ide> ['q' => 'hi there', 'cat' => ['id' => [2, 3]]],
<ide> [],
<del> 'query string data.'
<add> 'query string data.',
<ide> ],
<ide> [
<ide> 'http://example.com/search?q=hi+there&id=12',
<ide> 'http://example.com/search?q=hi+there',
<ide> ['id' => '12'],
<ide> [],
<del> 'query string data with some already on the url.'
<add> 'query string data with some already on the url.',
<ide> ],
<ide> [
<ide> 'http://example.com/test.html',
<ide> public static function urlProvider()
<ide> [
<ide> 'scheme' => 'http',
<ide> 'host' => 'example.com',
<del> 'protocolRelative' => false
<add> 'protocolRelative' => false,
<ide> ],
<ide> 'url with a double slash',
<ide> ],
<ide> public static function urlProvider()
<ide> [],
<ide> [
<ide> 'scheme' => 'http',
<del> 'protocolRelative' => true
<add> 'protocolRelative' => true,
<ide> ],
<ide> 'protocol relative url',
<ide> ],
<ide> public function testGetSimpleWithHeadersAndCookies()
<ide> 'Content-Type' => 'application/x-www-form-urlencoded',
<ide> ];
<ide> $cookies = [
<del> 'split' => 'value'
<add> 'split' => 'value',
<ide> ];
<ide>
<ide> $mock = $this->getMockBuilder('Cake\Http\Client\Adapter\Stream')
<ide> public function testGetNoData()
<ide>
<ide> $http = new Client([
<ide> 'host' => 'cakephp.org',
<del> 'adapter' => $mock
<add> 'adapter' => $mock,
<ide> ]);
<ide> $result = $http->get('/search');
<ide> $this->assertSame($result, $response);
<ide> public function testGetQuerystring()
<ide>
<ide> $http = new Client([
<ide> 'host' => 'cakephp.org',
<del> 'adapter' => $mock
<add> 'adapter' => $mock,
<ide> ]);
<ide> $result = $http->get('/search', [
<ide> 'q' => 'hi there',
<del> 'Category' => ['id' => [2, 3]]
<add> 'Category' => ['id' => [2, 3]],
<ide> ]);
<ide> $this->assertSame($result, $response);
<ide> }
<ide> public function testGetQuerystringString()
<ide>
<ide> $http = new Client([
<ide> 'host' => 'cakephp.org',
<del> 'adapter' => $mock
<add> 'adapter' => $mock,
<ide> ]);
<ide> $data = [
<ide> 'q' => 'hi there',
<del> 'Category' => ['id' => [2, 3]]
<add> 'Category' => ['id' => [2, 3]],
<ide> ];
<ide> $result = $http->get('/search', http_build_query($data));
<ide> $this->assertSame($response, $result);
<ide> public function testGetWithContent()
<ide>
<ide> $http = new Client([
<ide> 'host' => 'cakephp.org',
<del> 'adapter' => $mock
<add> 'adapter' => $mock,
<ide> ]);
<ide> $result = $http->get('/search', [
<del> '_content' => 'some data'
<add> '_content' => 'some data',
<ide> ]);
<ide> $this->assertSame($result, $response);
<ide> }
<ide> public function testInvalidAuthenticationType()
<ide>
<ide> $http = new Client([
<ide> 'host' => 'cakephp.org',
<del> 'adapter' => $mock
<add> 'adapter' => $mock,
<ide> ]);
<ide> $result = $http->get('/', [], [
<del> 'auth' => ['type' => 'horribly broken']
<add> 'auth' => ['type' => 'horribly broken'],
<ide> ]);
<ide> }
<ide>
<ide> public function testGetWithAuthenticationAndProxy()
<ide>
<ide> $http = new Client([
<ide> 'host' => 'cakephp.org',
<del> 'adapter' => $mock
<add> 'adapter' => $mock,
<ide> ]);
<ide> $result = $http->get('/', [], [
<ide> 'auth' => ['username' => 'mark', 'password' => 'secret'],
<ide> public function testAuthenticationWithMutation()
<ide>
<ide> $http = new Client([
<ide> 'host' => 'cakephp.org',
<del> 'adapter' => $mock
<add> 'adapter' => $mock,
<ide> ]);
<ide> $result = $http->get('/', [], [
<ide> 'auth' => ['type' => 'TestApp\Http\CompatAuth'],
<ide> public function testMethodsSimple($method)
<ide>
<ide> $http = new Client([
<ide> 'host' => 'cakephp.org',
<del> 'adapter' => $mock
<add> 'adapter' => $mock,
<ide> ]);
<ide> $result = $http->{$method}('/projects/add');
<ide> $this->assertSame($result, $response);
<ide> public function testPostWithTypeKey($type, $mime)
<ide>
<ide> $http = new Client([
<ide> 'host' => 'cakephp.org',
<del> 'adapter' => $mock
<add> 'adapter' => $mock,
<ide> ]);
<ide> $http->post('/projects/add', $data, ['type' => $type]);
<ide> }
<ide> public function testPostWithStringDataDefaultsToFormEncoding()
<ide>
<ide> $http = new Client([
<ide> 'host' => 'cakephp.org',
<del> 'adapter' => $mock
<add> 'adapter' => $mock,
<ide> ]);
<ide> $http->post('/projects/add', $data);
<ide> $http->put('/projects/add', $data);
<ide> public function testExceptionOnUnknownType()
<ide>
<ide> $http = new Client([
<ide> 'host' => 'cakephp.org',
<del> 'adapter' => $mock
<add> 'adapter' => $mock,
<ide> ]);
<ide> $http->post('/projects/add', 'it works', ['type' => 'invalid']);
<ide> }
<ide> public function testCookieStorage()
<ide> $headers = [
<ide> 'HTTP/1.0 200 Ok',
<ide> 'Set-Cookie: first=1',
<del> 'Set-Cookie: expiring=now; Expires=Wed, 09-Jun-1999 10:18:14 GMT'
<add> 'Set-Cookie: expiring=now; Expires=Wed, 09-Jun-1999 10:18:14 GMT',
<ide> ];
<ide> $response = new Response($headers, '');
<ide> $adapter->expects($this->at(0))
<ide> public function testCookieJar()
<ide> {
<ide> $jar = new CookieCollection();
<ide> $http = new Client([
<del> 'cookieJar' => $jar
<add> 'cookieJar' => $jar,
<ide> ]);
<ide>
<ide> $this->assertSame($jar, $http->cookies());
<ide> public function testHeadQuerystring()
<ide>
<ide> $http = new Client([
<ide> 'host' => 'cakephp.org',
<del> 'adapter' => $mock
<add> 'adapter' => $mock,
<ide> ]);
<ide> $result = $http->head('/search', [
<ide> 'q' => 'hi there',
<ide> public function testRedirects()
<ide> ->willReturn([$redirect2]);
<ide>
<ide> $response = new Response([
<del> 'HTTP/1.0 200'
<add> 'HTTP/1.0 200',
<ide> ]);
<ide> $adapter->expects($this->at(2))
<ide> ->method('send')
<ide> public function testRedirects()
<ide> ->willReturn([$response]);
<ide>
<ide> $client = new Client([
<del> 'adapter' => $adapter
<add> 'adapter' => $adapter,
<ide> ]);
<ide>
<ide> $result = $client->send(new Request($url), [
<del> 'redirect' => 10
<add> 'redirect' => 10,
<ide> ]);
<ide>
<ide> $this->assertInstanceOf(Response::class, $result);
<ide> public function testRedirectDifferentSubDomains()
<ide> ->willReturn([$redirect]);
<ide>
<ide> $response = new Response([
<del> 'HTTP/1.0 200'
<add> 'HTTP/1.0 200',
<ide> ]);
<ide> $adapter->expects($this->at(1))
<ide> ->method('send')
<ide> public function testRedirectDifferentSubDomains()
<ide> ->willReturn([$response]);
<ide>
<ide> $client = new Client([
<del> 'adapter' => $adapter
<add> 'adapter' => $adapter,
<ide> ]);
<ide> $client->addCookie(new Cookie('session', 'backend', null, '/', 'backstage.example.org'));
<ide> $client->addCookie(new Cookie('session', 'authz', null, '/', 'auth.example.org'));
<ide>
<ide> $result = $client->send(new Request($url), [
<del> 'redirect' => 10
<add> 'redirect' => 10,
<ide> ]);
<ide>
<ide> $this->assertInstanceOf(Response::class, $result);
<ide><path>tests/TestCase/Http/ControllerFactoryTest.php
<ide> public function testApplicationController()
<ide> 'params' => [
<ide> 'controller' => 'Cakes',
<ide> 'action' => 'index',
<del> ]
<add> ],
<ide> ]);
<ide> $result = $this->factory->create($request, $this->response);
<ide> $this->assertInstanceOf('TestApp\Controller\CakesController', $result);
<ide> public function testPrefixedAppController()
<ide> 'prefix' => 'admin',
<ide> 'controller' => 'Posts',
<ide> 'action' => 'index',
<del> ]
<add> ],
<ide> ]);
<ide> $result = $this->factory->create($request, $this->response);
<ide> $this->assertInstanceOf(
<ide> public function testNestedPrefixedAppController()
<ide> 'prefix' => 'admin/sub',
<ide> 'controller' => 'Posts',
<ide> 'action' => 'index',
<del> ]
<add> ],
<ide> ]);
<ide> $result = $this->factory->create($request, $this->response);
<ide> $this->assertInstanceOf(
<ide> public function testPluginController()
<ide> 'plugin' => 'TestPlugin',
<ide> 'controller' => 'TestPlugin',
<ide> 'action' => 'index',
<del> ]
<add> ],
<ide> ]);
<ide> $result = $this->factory->create($request, $this->response);
<ide> $this->assertInstanceOf(
<ide> public function testVendorPluginController()
<ide> 'plugin' => 'Company/TestPluginThree',
<ide> 'controller' => 'Ovens',
<ide> 'action' => 'index',
<del> ]
<add> ],
<ide> ]);
<ide> $result = $this->factory->create($request, $this->response);
<ide> $this->assertInstanceOf(
<ide> public function testPrefixedPluginController()
<ide> 'plugin' => 'TestPlugin',
<ide> 'controller' => 'Comments',
<ide> 'action' => 'index',
<del> ]
<add> ],
<ide> ]);
<ide> $result = $this->factory->create($request, $this->response);
<ide> $this->assertInstanceOf(
<ide> public function testAbstractClassFailure()
<ide> 'params' => [
<ide> 'controller' => 'Abstract',
<ide> 'action' => 'index',
<del> ]
<add> ],
<ide> ]);
<ide> $this->factory->create($request, $this->response);
<ide> }
<ide> public function testInterfaceFailure()
<ide> 'params' => [
<ide> 'controller' => 'Interface',
<ide> 'action' => 'index',
<del> ]
<add> ],
<ide> ]);
<ide> $this->factory->create($request, $this->response);
<ide> }
<ide> public function testMissingClassFailure()
<ide> 'params' => [
<ide> 'controller' => 'Invisible',
<ide> 'action' => 'index',
<del> ]
<add> ],
<ide> ]);
<ide> $this->factory->create($request, $this->response);
<ide> }
<ide> public function testSlashedControllerFailure()
<ide> 'params' => [
<ide> 'controller' => 'Admin/Posts',
<ide> 'action' => 'index',
<del> ]
<add> ],
<ide> ]);
<ide> $this->factory->create($request, $this->response);
<ide> }
<ide> public function testAbsoluteReferenceFailure()
<ide> 'params' => [
<ide> 'controller' => 'TestApp\Controller\CakesController',
<ide> 'action' => 'index',
<del> ]
<add> ],
<ide> ]);
<ide> $this->factory->create($request, $this->response);
<ide> }
<ide> public function testGetControllerClassNoControllerName()
<ide> 'plugin' => 'Company/TestPluginThree',
<ide> 'controller' => 'Ovens',
<ide> 'action' => 'index',
<del> ]
<add> ],
<ide> ]);
<ide> $result = $this->factory->getControllerClass($request);
<ide> $this->assertSame('Company\TestPluginThree\Controller\OvensController', $result);
<ide><path>tests/TestCase/Http/Cookie/CookieCollectionTest.php
<ide> public function testConstructorWithCookieArray()
<ide> {
<ide> $cookies = [
<ide> new Cookie('one', 'one'),
<del> new Cookie('two', 'two')
<add> new Cookie('two', 'two'),
<ide> ];
<ide>
<ide> $collection = new CookieCollection($cookies);
<ide> public function testIteration()
<ide> $cookies = [
<ide> new Cookie('remember_me', 'a'),
<ide> new Cookie('gtm', 'b'),
<del> new Cookie('three', 'tree')
<add> new Cookie('three', 'tree'),
<ide> ];
<ide>
<ide> $collection = new CookieCollection($cookies);
<ide> public function testHas()
<ide> {
<ide> $cookies = [
<ide> new Cookie('remember_me', 'a'),
<del> new Cookie('gtm', 'b')
<add> new Cookie('gtm', 'b'),
<ide> ];
<ide>
<ide> $collection = new CookieCollection($cookies);
<ide> public function testRemove()
<ide> {
<ide> $cookies = [
<ide> new Cookie('remember_me', 'a'),
<del> new Cookie('gtm', 'b')
<add> new Cookie('gtm', 'b'),
<ide> ];
<ide>
<ide> $collection = new CookieCollection($cookies);
<ide> public function testGetByName()
<ide> {
<ide> $cookies = [
<ide> new Cookie('remember_me', 'a'),
<del> new Cookie('gtm', 'b')
<add> new Cookie('gtm', 'b'),
<ide> ];
<ide>
<ide> $collection = new CookieCollection($cookies);
<ide> public function testConstructorWithInvalidCookieObjects()
<ide> $this->expectExceptionMessage('Expected `Cake\Http\Cookie\CookieCollection[]` as $cookies but instead got `array` at index 1');
<ide> $array = [
<ide> new Cookie('one', 'one'),
<del> []
<add> [],
<ide> ];
<ide>
<ide> new CookieCollection($array);
<ide> public function testAddFromResponse()
<ide> {
<ide> $collection = new CookieCollection();
<ide> $request = new ServerRequest([
<del> 'url' => '/app'
<add> 'url' => '/app',
<ide> ]);
<ide> $response = (new Response())
<ide> ->withAddedHeader('Set-Cookie', 'test=value')
<ide> public function testAddFromResponseValueUrldecodeData()
<ide> {
<ide> $collection = new CookieCollection();
<ide> $request = new ServerRequest([
<del> 'url' => '/app'
<add> 'url' => '/app',
<ide> ]);
<ide> $response = (new Response())
<ide> ->withAddedHeader('Set-Cookie', 'test=val%3Bue; Path=/example; Secure;');
<ide> public function testAddFromResponseIgnoreEmpty()
<ide> {
<ide> $collection = new CookieCollection();
<ide> $request = new ServerRequest([
<del> 'url' => '/app'
<add> 'url' => '/app',
<ide> ]);
<ide> $response = (new Response())
<ide> ->withAddedHeader('Set-Cookie', '');
<ide> public function testAddFromResponseIgnoreExpired()
<ide> {
<ide> $collection = new CookieCollection();
<ide> $request = new ServerRequest([
<del> 'url' => '/app'
<add> 'url' => '/app',
<ide> ]);
<ide> $response = (new Response())
<ide> ->withAddedHeader('Set-Cookie', 'test=value')
<ide> public function testAddFromResponseIgnoreExpired()
<ide> public function testAddFromResponseRemoveExpired()
<ide> {
<ide> $collection = new CookieCollection([
<del> new Cookie('expired', 'not yet', null, '/', 'example.com')
<add> new Cookie('expired', 'not yet', null, '/', 'example.com'),
<ide> ]);
<ide> $request = new ServerRequest([
<ide> 'url' => '/app',
<ide> 'environment' => [
<del> 'HTTP_HOST' => 'example.com'
<del> ]
<add> 'HTTP_HOST' => 'example.com',
<add> ],
<ide> ]);
<ide> $response = (new Response())
<ide> ->withAddedHeader('Set-Cookie', 'test=value')
<ide> public function testAddFromResponseInvalidExpires()
<ide> {
<ide> $collection = new CookieCollection();
<ide> $request = new ServerRequest([
<del> 'url' => '/app'
<add> 'url' => '/app',
<ide> ]);
<ide> $response = (new Response())
<ide> ->withAddedHeader('Set-Cookie', 'test=value')
<ide> public function testAddFromResponseInvalidExpires()
<ide> public function testAddFromResponseUpdateExisting()
<ide> {
<ide> $collection = new CookieCollection([
<del> new Cookie('key', 'old value', null, '/', 'example.com')
<add> new Cookie('key', 'old value', null, '/', 'example.com'),
<ide> ]);
<ide> $request = new ServerRequest([
<ide> 'url' => '/',
<ide> 'environment' => [
<del> 'HTTP_HOST' => 'example.com'
<del> ]
<add> 'HTTP_HOST' => 'example.com',
<add> ],
<ide> ]);
<ide> $response = (new Response())->withAddedHeader('Set-Cookie', 'key=new value');
<ide> $new = $collection->addFromResponse($response, $request);
<ide><path>tests/TestCase/Http/Cookie/CookieTest.php
<ide> public function testCheckArraySourceData()
<ide> {
<ide> $data = [
<ide> 'type' => 'mvc',
<del> 'user' => ['name' => 'mark']
<add> 'user' => ['name' => 'mark'],
<ide> ];
<ide> $cookie = new Cookie('cakephp', $data);
<ide> $this->assertTrue($cookie->check('type'));
<ide> public function testReadExpandsOnDemand()
<ide> $data = [
<ide> 'username' => 'florian',
<ide> 'profile' => [
<del> 'profession' => 'developer'
<del> ]
<add> 'profession' => 'developer',
<add> ],
<ide> ];
<ide> $cookie = new Cookie('cakephp', json_encode($data));
<ide> $this->assertFalse($cookie->isExpanded());
<ide> public function testReadComplexData()
<ide> $data = [
<ide> 'username' => 'florian',
<ide> 'profile' => [
<del> 'profession' => 'developer'
<del> ]
<add> 'profession' => 'developer',
<add> ],
<ide> ];
<ide> $cookie = new Cookie('cakephp', $data);
<ide>
<ide> public function testToHeaderValueCollapsesComplexData()
<ide> $data = [
<ide> 'username' => 'florian',
<ide> 'profile' => [
<del> 'profession' => 'developer'
<del> ]
<add> 'profession' => 'developer',
<add> ],
<ide> ];
<ide> $cookie = new Cookie('cakephp', $data);
<ide> $this->assertEquals('developer', $cookie->read('profile.profession'));
<ide><path>tests/TestCase/Http/Middleware/BodyParserMiddlewareTest.php
<ide> public static function safeHttpMethodProvider()
<ide> public static function httpMethodProvider()
<ide> {
<ide> return [
<del> ['PATCH'], ['PUT'], ['POST'], ['DELETE']
<add> ['PATCH'], ['PUT'], ['POST'], ['DELETE'],
<ide> ];
<ide> }
<ide>
<ide> public function testInvokeMismatchedType($method)
<ide> 'REQUEST_METHOD' => $method,
<ide> 'CONTENT_TYPE' => 'text/csv',
<ide> ],
<del> 'input' => 'a,b,c'
<add> 'input' => 'a,b,c',
<ide> ]);
<ide> $response = new Response();
<ide> $next = function ($req, $res) {
<ide> public function testInvokeCaseInsensitiveContentType($method)
<ide> 'REQUEST_METHOD' => $method,
<ide> 'CONTENT_TYPE' => 'ApPlIcAtIoN/JSoN',
<ide> ],
<del> 'input' => '{"title": "yay"}'
<add> 'input' => '{"title": "yay"}',
<ide> ]);
<ide> $response = new Response();
<ide> $next = function ($req, $res) {
<ide> public function testInvokeParse($method)
<ide> 'REQUEST_METHOD' => $method,
<ide> 'CONTENT_TYPE' => 'application/json',
<ide> ],
<del> 'input' => '{"title": "yay"}'
<add> 'input' => '{"title": "yay"}',
<ide> ]);
<ide> $response = new Response();
<ide> $next = function ($req, $res) {
<ide> public function testInvokeParseStripCharset()
<ide> 'REQUEST_METHOD' => 'POST',
<ide> 'CONTENT_TYPE' => 'application/json; charset=utf-8',
<ide> ],
<del> 'input' => '{"title": "yay"}'
<add> 'input' => '{"title": "yay"}',
<ide> ]);
<ide> $response = new Response();
<ide> $next = function ($req, $res) {
<ide> public function testInvokeNoParseOnSafe($method)
<ide> 'REQUEST_METHOD' => $method,
<ide> 'CONTENT_TYPE' => 'application/json',
<ide> ],
<del> 'input' => '{"title": "yay"}'
<add> 'input' => '{"title": "yay"}',
<ide> ]);
<ide> $response = new Response();
<ide> $next = function ($req, $res) {
<ide> public function testInvokeXml()
<ide> 'REQUEST_METHOD' => 'POST',
<ide> 'CONTENT_TYPE' => 'application/xml',
<ide> ],
<del> 'input' => $xml
<add> 'input' => $xml,
<ide> ]);
<ide> $response = new Response();
<ide> $next = function ($req, $res) {
<ide> $expected = [
<del> 'article' => ['title' => 'yay']
<add> 'article' => ['title' => 'yay'],
<ide> ];
<ide> $this->assertEquals($expected, $req->getParsedBody());
<ide> };
<ide> public function testInvokeXmlCdata()
<ide> 'REQUEST_METHOD' => 'POST',
<ide> 'CONTENT_TYPE' => 'application/xml',
<ide> ],
<del> 'input' => $xml
<add> 'input' => $xml,
<ide> ]);
<ide> $response = new Response();
<ide> $next = function ($req, $res) {
<ide> $expected = [
<ide> 'article' => [
<ide> 'id' => 1,
<del> 'title' => 'first'
<del> ]
<add> 'title' => 'first',
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, $req->getParsedBody());
<ide> };
<ide> public function testInvokeXmlInternalEntities()
<ide> 'REQUEST_METHOD' => 'POST',
<ide> 'CONTENT_TYPE' => 'application/xml',
<ide> ],
<del> 'input' => $xml
<add> 'input' => $xml,
<ide> ]);
<ide> $response = new Response();
<ide> $next = function ($req, $res) {
<ide> public function testInvokeParseNoArray()
<ide> 'REQUEST_METHOD' => 'POST',
<ide> 'CONTENT_TYPE' => 'application/json',
<ide> ],
<del> 'input' => 'lol'
<add> 'input' => 'lol',
<ide> ]);
<ide> $response = new Response();
<ide> $next = function ($req, $res) {
<ide><path>tests/TestCase/Http/Middleware/CsrfProtectionMiddlewareTest.php
<ide> public static function safeHttpMethodProvider()
<ide> public static function httpMethodProvider()
<ide> {
<ide> return [
<del> ['OPTIONS'], ['PATCH'], ['PUT'], ['POST'], ['DELETE'], ['PURGE'], ['INVALIDMETHOD']
<add> ['OPTIONS'], ['PATCH'], ['PUT'], ['POST'], ['DELETE'], ['PURGE'], ['INVALIDMETHOD'],
<ide> ];
<ide> }
<ide>
<ide> public function testSafeMethodNoCsrfRequired($method)
<ide> 'REQUEST_METHOD' => $method,
<ide> 'HTTP_X_CSRF_TOKEN' => 'nope',
<ide> ],
<del> 'cookies' => ['csrfToken' => 'testing123']
<add> 'cookies' => ['csrfToken' => 'testing123'],
<ide> ]);
<ide> $response = new Response();
<ide>
<ide> public function testValidTokenInHeader($method)
<ide> 'HTTP_X_CSRF_TOKEN' => 'testing123',
<ide> ],
<ide> 'post' => ['a' => 'b'],
<del> 'cookies' => ['csrfToken' => 'testing123']
<add> 'cookies' => ['csrfToken' => 'testing123'],
<ide> ]);
<ide> $response = new Response();
<ide>
<ide> public function testInvalidTokenInHeader($method)
<ide> 'HTTP_X_CSRF_TOKEN' => 'nope',
<ide> ],
<ide> 'post' => ['a' => 'b'],
<del> 'cookies' => ['csrfToken' => 'testing123']
<add> 'cookies' => ['csrfToken' => 'testing123'],
<ide> ]);
<ide> $response = new Response();
<ide>
<ide> public function testValidTokenRequestData($method)
<ide> 'REQUEST_METHOD' => $method,
<ide> ],
<ide> 'post' => ['_csrfToken' => 'testing123'],
<del> 'cookies' => ['csrfToken' => 'testing123']
<add> 'cookies' => ['csrfToken' => 'testing123'],
<ide> ]);
<ide> $response = new Response();
<ide>
<ide> public function testInvalidTokenRequestData($method)
<ide> 'REQUEST_METHOD' => $method,
<ide> ],
<ide> 'post' => ['_csrfToken' => 'nope'],
<del> 'cookies' => ['csrfToken' => 'testing123']
<add> 'cookies' => ['csrfToken' => 'testing123'],
<ide> ]);
<ide> $response = new Response();
<ide>
<ide> public function testInvalidTokenRequestDataMissing()
<ide> 'REQUEST_METHOD' => 'POST',
<ide> ],
<ide> 'post' => [],
<del> 'cookies' => ['csrfToken' => 'testing123']
<add> 'cookies' => ['csrfToken' => 'testing123'],
<ide> ]);
<ide> $response = new Response();
<ide>
<ide> public function testInvalidTokenMissingCookie($method)
<ide> $this->expectException(\Cake\Http\Exception\InvalidCsrfTokenException::class);
<ide> $request = new ServerRequest([
<ide> 'environment' => [
<del> 'REQUEST_METHOD' => $method
<add> 'REQUEST_METHOD' => $method,
<ide> ],
<ide> 'post' => ['_csrfToken' => 'could-be-valid'],
<del> 'cookies' => []
<add> 'cookies' => [],
<ide> ]);
<ide> $response = new Response();
<ide>
<ide> public function testConfigurationCookieCreate()
<ide> {
<ide> $request = new ServerRequest([
<ide> 'environment' => ['REQUEST_METHOD' => 'GET'],
<del> 'webroot' => '/dir/'
<add> 'webroot' => '/dir/',
<ide> ]);
<ide> $response = new Response();
<ide>
<ide> public function testConfigurationCookieCreate()
<ide> 'cookieName' => 'token',
<ide> 'expiry' => '+1 hour',
<ide> 'secure' => true,
<del> 'httpOnly' => true
<add> 'httpOnly' => true,
<ide> ]);
<ide> $middleware($request, $response, $closure);
<ide> }
<ide><path>tests/TestCase/Http/Middleware/EncryptedCookieMiddlewareTest.php
<ide> public function testDecodeRequestCookies()
<ide> $request = new ServerRequest(['url' => '/cookies/nom']);
<ide> $request = $request->withCookieParams([
<ide> 'plain' => 'always plain',
<del> 'secret' => $this->_encrypt('decoded', 'aes')
<add> 'secret' => $this->_encrypt('decoded', 'aes'),
<ide> ]);
<ide> $this->assertNotEquals('decoded', $request->getCookie('decoded'));
<ide>
<ide><path>tests/TestCase/Http/Middleware/SecurityHeadersMiddlewareTest.php
<ide> public function testAddingSecurityHeaders()
<ide> 'referrer-policy' => ['same-origin'],
<ide> 'x-frame-options' => ['sameorigin'],
<ide> 'x-download-options' => ['noopen'],
<del> 'x-content-type-options' => ['nosniff']
<add> 'x-content-type-options' => ['nosniff'],
<ide> ];
<ide>
<ide> $result = $middleware($request, $response, $next);
<ide><path>tests/TestCase/Http/RequestTransformerTest.php
<ide> public function testToCakeUploadedFiles()
<ide> 'type' => ['file' => ''],
<ide> 'tmp_name' => ['file' => ''],
<ide> 'error' => ['file' => UPLOAD_ERR_NO_FILE],
<del> 'size' => ['file' => 0]
<add> 'size' => ['file' => 0],
<ide> ],
<ide> 'image_main' => [
<ide> 'name' => ['file' => 'born on.txt'],
<ide> 'type' => ['file' => 'text/plain'],
<ide> 'tmp_name' => ['file' => __FILE__],
<ide> 'error' => ['file' => 0],
<del> 'size' => ['file' => 17178]
<add> 'size' => ['file' => 17178],
<ide> ],
<ide> 0 => [
<ide> 'name' => ['image' => 'scratch.text'],
<ide> 'type' => ['image' => 'text/plain'],
<ide> 'tmp_name' => ['image' => __FILE__],
<ide> 'error' => ['image' => 0],
<del> 'size' => ['image' => 1490]
<add> 'size' => ['image' => 1490],
<ide> ],
<ide> 'pictures' => [
<ide> 'name' => [
<ide> 0 => ['file' => 'a-file.png'],
<del> 1 => ['file' => 'a-moose.png']
<add> 1 => ['file' => 'a-moose.png'],
<ide> ],
<ide> 'type' => [
<ide> 0 => ['file' => 'image/png'],
<del> 1 => ['file' => 'image/jpg']
<add> 1 => ['file' => 'image/jpg'],
<ide> ],
<ide> 'tmp_name' => [
<ide> 0 => ['file' => __FILE__],
<del> 1 => ['file' => __FILE__]
<add> 1 => ['file' => __FILE__],
<ide> ],
<ide> 'error' => [
<ide> 0 => ['file' => 0],
<del> 1 => ['file' => 0]
<add> 1 => ['file' => 0],
<ide> ],
<ide> 'size' => [
<ide> 0 => ['file' => 17188],
<del> 1 => ['file' => 2010]
<add> 1 => ['file' => 2010],
<ide> ],
<del> ]
<add> ],
<ide> ];
<ide> $post = [
<ide> 'pictures' => [
<ide> 0 => ['name' => 'A cat'],
<del> 1 => ['name' => 'A moose']
<add> 1 => ['name' => 'A moose'],
<ide> ],
<ide> 0 => [
<del> 'name' => 'A dog'
<del> ]
<add> 'name' => 'A dog',
<add> ],
<ide> ];
<ide> $psr = ServerRequestFactory::fromGlobals(null, null, $post, null, $files);
<ide> $request = RequestTransformer::toCake($psr);
<ide> public function testToCakeUploadedFiles()
<ide> 'tmp_name' => __FILE__,
<ide> 'error' => 0,
<ide> 'size' => 17178,
<del> ]
<add> ],
<ide> ],
<ide> 'no_file' => [
<ide> 'file' => [
<ide> public function testToCakeUploadedFiles()
<ide> 'tmp_name' => '',
<ide> 'error' => UPLOAD_ERR_NO_FILE,
<ide> 'size' => 0,
<del> ]
<add> ],
<ide> ],
<ide> 'pictures' => [
<ide> 0 => [
<ide> public function testToCakeUploadedFiles()
<ide> 'tmp_name' => __FILE__,
<ide> 'error' => 0,
<ide> 'size' => 17188,
<del> ]
<add> ],
<ide> ],
<ide> 1 => [
<ide> 'name' => 'A moose',
<ide> public function testToCakeUploadedFiles()
<ide> 'tmp_name' => __FILE__,
<ide> 'error' => 0,
<ide> 'size' => 2010,
<del> ]
<del> ]
<add> ],
<add> ],
<ide> ],
<ide> 0 => [
<ide> 'name' => 'A dog',
<ide> public function testToCakeUploadedFiles()
<ide> 'type' => 'text/plain',
<ide> 'tmp_name' => __FILE__,
<ide> 'error' => 0,
<del> 'size' => 1490
<del> ]
<del> ]
<add> 'size' => 1490,
<add> ],
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, $request->data);
<ide> }
<ide><path>tests/TestCase/Http/ResponseEmitterTest.php
<ide> public function testEmitResponseSimple()
<ide> $expected = [
<ide> 'HTTP/1.1 201 Created',
<ide> 'Content-Type: text/html',
<del> 'Location: http://example.com/cake/1'
<add> 'Location: http://example.com/cake/1',
<ide> ];
<ide> $this->assertEquals($expected, $GLOBALS['mockedHeaders']);
<ide> }
<ide> public function testEmitResponseArrayCookies()
<ide> $this->assertEquals('ok', $out);
<ide> $expected = [
<ide> 'HTTP/1.1 200 OK',
<del> 'Content-Type: text/plain'
<add> 'Content-Type: text/plain',
<ide> ];
<ide> $this->assertEquals($expected, $GLOBALS['mockedHeaders']);
<ide> $expected = [
<ide> public function testEmitResponseArrayCookies()
<ide> 'expire' => 0,
<ide> 'domain' => '',
<ide> 'secure' => true,
<del> 'httponly' => false
<add> 'httponly' => false,
<ide> ],
<ide> [
<ide> 'name' => 'google',
<ide> public function testEmitResponseArrayCookies()
<ide> 'expire' => 0,
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httponly' => true
<add> 'httponly' => true,
<ide> ],
<ide> ];
<ide> $this->assertEquals($expected, $GLOBALS['mockedCookies']);
<ide> public function testEmitResponseCookies()
<ide> $this->assertEquals('ok', $out);
<ide> $expected = [
<ide> 'HTTP/1.1 200 OK',
<del> 'Content-Type: text/plain'
<add> 'Content-Type: text/plain',
<ide> ];
<ide> $this->assertEquals($expected, $GLOBALS['mockedHeaders']);
<ide> $expected = [
<ide> public function testEmitResponseCookies()
<ide> 'expire' => 0,
<ide> 'domain' => '',
<ide> 'secure' => true,
<del> 'httponly' => false
<add> 'httponly' => false,
<ide> ],
<ide> [
<ide> 'name' => 'people',
<ide> public function testEmitResponseCookies()
<ide> 'expire' => 0,
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httponly' => false
<add> 'httponly' => false,
<ide> ],
<ide> [
<ide> 'name' => 'google',
<ide> public function testEmitResponseCookies()
<ide> 'expire' => 0,
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httponly' => true
<add> 'httponly' => true,
<ide> ],
<ide> [
<ide> 'name' => 'a',
<ide> public function testEmitResponseCookies()
<ide> 'expire' => 1610576581,
<ide> 'domain' => 'www.example.com',
<ide> 'secure' => false,
<del> 'httponly' => false
<add> 'httponly' => false,
<ide> ],
<ide> [
<ide> 'name' => 'list[]',
<ide> public function testEmitResponseCookies()
<ide> 'expire' => 0,
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httponly' => false
<add> 'httponly' => false,
<ide> ],
<ide> ];
<ide> $this->assertEquals($expected, $GLOBALS['mockedCookies']);
<ide><path>tests/TestCase/Http/ResponseTest.php
<ide> public function testConstruct()
<ide> 'body' => 'This is the body',
<ide> 'charset' => 'my-custom-charset',
<ide> 'type' => 'mp3',
<del> 'status' => '203'
<add> 'status' => '203',
<ide> ];
<ide> $response = new Response($options);
<ide> $this->assertEquals('This is the body', (string)$response->getBody());
<ide> public function testConstructCustomCodes()
<ide> 'type' => 'txt',
<ide> 'status' => '422',
<ide> 'statusCodes' => [
<del> 422 => 'Unprocessable Entity'
<del> ]
<add> 422 => 'Unprocessable Entity',
<add> ],
<ide> ];
<ide> $response = new Response($options);
<ide> $this->assertEquals($options['body'], (string)$response->getBody());
<ide> public function testHeader()
<ide> $response->header('Location', 'http://example2.com');
<ide> $headers = [
<ide> 'Content-Type' => 'text/html; charset=UTF-8',
<del> 'Location' => 'http://example2.com'
<add> 'Location' => 'http://example2.com',
<ide> ];
<ide> $this->assertEquals($headers, $response->header());
<ide>
<ide> public function testHttpCodes()
<ide>
<ide> $codes = [
<ide> 381 => 'Unicorn Moved',
<del> 555 => 'Unexpected Minotaur'
<add> 555 => 'Unexpected Minotaur',
<ide> ];
<ide>
<ide> $result = $response->httpCodes($codes);
<ide> public function testHttpCodes()
<ide> 0 => 'Nothing Here',
<ide> -1 => 'Reverse Infinity',
<ide> 12345 => 'Universal Password',
<del> 'Hello' => 'World'
<add> 'Hello' => 'World',
<ide> ]);
<ide> });
<ide> }
<ide> public function testDownload()
<ide> $response = new Response();
<ide> $expected = [
<ide> 'Content-Type' => 'text/html; charset=UTF-8',
<del> 'Content-Disposition' => 'attachment; filename="myfile.mp3"'
<add> 'Content-Disposition' => 'attachment; filename="myfile.mp3"',
<ide> ];
<ide> $response->download('myfile.mp3');
<ide> $this->assertEquals($expected, $response->header());
<ide> public function testCookieSettings()
<ide> $this->deprecated(function () {
<ide> $response = new Response();
<ide> $cookie = [
<del> 'name' => 'CakeTestCookie[Testing]'
<add> 'name' => 'CakeTestCookie[Testing]',
<ide> ];
<ide> $response->cookie($cookie);
<ide> $expected = [
<ide> public function testCookieSettings()
<ide> 'path' => '/',
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httpOnly' => false
<add> 'httpOnly' => false,
<ide> ];
<ide> $result = $response->cookie('CakeTestCookie[Testing]');
<ide> $this->assertEquals($expected, $result);
<ide> public function testCookieSettings()
<ide> 'value' => '[a,b,c]',
<ide> 'expire' => 1000,
<ide> 'path' => '/test',
<del> 'secure' => true
<add> 'secure' => true,
<ide> ];
<ide> $response->cookie($cookie);
<ide> $expected = [
<ide> public function testCookieSettings()
<ide> 'path' => '/',
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httpOnly' => false
<add> 'httpOnly' => false,
<ide> ],
<ide> 'CakeTestCookie[Testing2]' => [
<ide> 'name' => 'CakeTestCookie[Testing2]',
<ide> public function testCookieSettings()
<ide> 'path' => '/test',
<ide> 'domain' => '',
<ide> 'secure' => true,
<del> 'httpOnly' => false
<del> ]
<add> 'httpOnly' => false,
<add> ],
<ide> ];
<ide>
<ide> $result = $response->cookie();
<ide> public function testCookieSettings()
<ide> 'path' => '/',
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httpOnly' => false
<add> 'httpOnly' => false,
<ide> ],
<ide> 'CakeTestCookie[Testing2]' => [
<ide> 'name' => 'CakeTestCookie[Testing2]',
<ide> public function testCookieSettings()
<ide> 'path' => '/test',
<ide> 'domain' => '',
<ide> 'secure' => true,
<del> 'httpOnly' => false
<del> ]
<add> 'httpOnly' => false,
<add> ],
<ide> ];
<ide>
<ide> $result = $response->cookie();
<ide> public function testWithDuplicateCookie()
<ide> 'path' => '/test',
<ide> 'domain' => '',
<ide> 'secure' => true,
<del> 'httpOnly' => false
<add> 'httpOnly' => false,
<ide> ];
<ide>
<ide> // Match the date time formatting to Response::convertCookieToArray
<ide> public function testGetCookies()
<ide> 'path' => '/',
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httpOnly' => false
<add> 'httpOnly' => false,
<ide> ],
<ide> 'test2' => [
<ide> 'name' => 'test2',
<ide> public function testGetCookies()
<ide> 'path' => '/test',
<ide> 'domain' => '',
<ide> 'secure' => true,
<del> 'httpOnly' => false
<del> ]
<add> 'httpOnly' => false,
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, $new->getCookies());
<ide> }
<ide> public function testGetCookiesArrayValue()
<ide> 'path' => '/',
<ide> 'domain' => '',
<ide> 'secure' => false,
<del> 'httpOnly' => true
<add> 'httpOnly' => true,
<ide> ],
<ide> ];
<ide> $this->assertEquals($expected, $new->getCookies());
<ide> public function testWithCookieCollection()
<ide> public function testCors()
<ide> {
<ide> $request = new ServerRequest([
<del> 'environment' => ['HTTP_ORIGIN' => 'http://example.com']
<add> 'environment' => ['HTTP_ORIGIN' => 'http://example.com'],
<ide> ]);
<ide> $response = new Response();
<ide> $builder = $response->cors($request);
<ide> public function testFileWithUnknownFileTypeIE()
<ide> ->will($this->returnValue(true));
<ide>
<ide> $response->file(CONFIG . 'no_section.ini', [
<del> 'name' => 'config.ini'
<add> 'name' => 'config.ini',
<ide> ]);
<ide>
<ide> ob_start();
<ide> public function testFileWithUnknownFileNoDownload()
<ide> ->method('download');
<ide>
<ide> $response->file(CONFIG . 'no_section.ini', [
<del> 'download' => false
<add> 'download' => false,
<ide> ]);
<ide> $this->assertEquals('bytes', $response->getHeaderLine('Accept-Ranges'));
<ide> $this->assertEquals('text/html', $response->getType());
<ide> public function testWithFileNoDownload()
<ide> {
<ide> $response = new Response();
<ide> $new = $response->withFile(CONFIG . 'no_section.ini', [
<del> 'download' => false
<add> 'download' => false,
<ide> ]);
<ide> $this->assertEquals(
<ide> 'text/html; charset=UTF-8',
<ide> public static function rangeProvider()
<ide> return [
<ide> // suffix-byte-range
<ide> [
<del> 'bytes=-25', 25, 'bytes 13-37/38'
<add> 'bytes=-25', 25, 'bytes 13-37/38',
<ide> ],
<ide>
<ide> [
<del> 'bytes=0-', 38, 'bytes 0-37/38'
<add> 'bytes=0-', 38, 'bytes 0-37/38',
<ide> ],
<ide>
<ide> [
<del> 'bytes=10-', 28, 'bytes 10-37/38'
<add> 'bytes=10-', 28, 'bytes 10-37/38',
<ide> ],
<ide>
<ide> [
<del> 'bytes=10-20', 11, 'bytes 10-20/38'
<add> 'bytes=10-20', 11, 'bytes 10-20/38',
<ide> ],
<ide>
<ide> // Spaced out
<ide> [
<del> 'bytes = 10 - 20', 11, 'bytes 10-20/38'
<add> 'bytes = 10 - 20', 11, 'bytes 10-20/38',
<ide> ],
<ide> ];
<ide> }
<ide> public function invalidFileRangeProvider()
<ide> return [
<ide> // malformed range
<ide> [
<del> 'bytes=0,38'
<add> 'bytes=0,38',
<ide> ],
<ide>
<ide> // malformed punctuation
<ide> [
<del> 'bytes: 0 - 38'
<add> 'bytes: 0 - 38',
<ide> ],
<ide> ];
<ide> }
<ide> public function testWithHeader()
<ide> $result = $response2->getHeaders();
<ide> $expected = [
<ide> 'Content-Type' => ['text/html; charset=UTF-8'],
<del> 'Accept' => ['application/json']
<add> 'Accept' => ['application/json'],
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> public function testGetHeaders()
<ide> $expected = [
<ide> 'Content-Type' => ['text/html; charset=UTF-8'],
<ide> 'Location' => ['localhost'],
<del> 'Accept' => ['application/json']
<add> 'Accept' => ['application/json'],
<ide> ];
<ide>
<ide> $this->assertEquals($expected, $headers);
<ide> public function testWithoutHeader()
<ide>
<ide> $expected = [
<ide> 'Content-Type' => ['text/html; charset=UTF-8'],
<del> 'Accept' => ['application/json']
<add> 'Accept' => ['application/json'],
<ide> ];
<ide>
<ide> $this->assertEquals($expected, $headers);
<ide> public function testDebugInfo()
<ide> 'status' => 200,
<ide> 'contentType' => 'text/html',
<ide> 'headers' => [
<del> 'Content-Type' => ['text/html; charset=UTF-8']
<add> 'Content-Type' => ['text/html; charset=UTF-8'],
<ide> ],
<ide> 'file' => null,
<ide> 'fileRange' => [],
<ide> 'cookies' => new CookieCollection(),
<ide> 'cacheDirectives' => [],
<del> 'body' => 'Foo'
<add> 'body' => 'Foo',
<ide> ];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide><path>tests/TestCase/Http/ResponseTransformerTest.php
<ide> public function testToCakeHeaders()
<ide> $result = ResponseTransformer::toCake($psr);
<ide> $expected = [
<ide> 'Content-Type' => 'text/html; charset=UTF-8',
<del> 'X-testing' => 'value'
<add> 'X-testing' => 'value',
<ide> ];
<ide> $this->assertSame($expected, $result->header());
<ide> }
<ide> public function testToCakeCookies()
<ide> {
<ide> $cookies = [
<ide> 'remember_me=1";"1',
<del> 'forever=yes; Expires=Wed, 13 Jan 2021 12:30:40 GMT; Path=/some/path; Domain=example.com; HttpOnly; Secure'
<add> 'forever=yes; Expires=Wed, 13 Jan 2021 12:30:40 GMT; Path=/some/path; Domain=example.com; HttpOnly; Secure',
<ide> ];
<ide> $psr = new PsrResponse('php://memory', 200, ['Set-Cookie' => $cookies]);
<ide> $result = ResponseTransformer::toCake($psr);
<ide> public function testToPsrCookieSimple()
<ide> $cake = new CakeResponse(['status' => 200]);
<ide> $cake->cookie([
<ide> 'name' => 'remember_me',
<del> 'value' => 1
<add> 'value' => 1,
<ide> ]);
<ide> $result = ResponseTransformer::toPsr($cake);
<ide> $this->assertEquals('remember_me=1; Path=/', $result->getHeader('Set-Cookie')[0]);
<ide> public function testToPsrCookieMultiple()
<ide> $cake = new CakeResponse(['status' => 200]);
<ide> $cake->cookie([
<ide> 'name' => 'remember_me',
<del> 'value' => 1
<add> 'value' => 1,
<ide> ]);
<ide> $cake->cookie([
<ide> 'name' => 'forever',
<del> 'value' => 2
<add> 'value' => 2,
<ide> ]);
<ide> $result = ResponseTransformer::toPsr($cake);
<ide> $this->assertEquals('remember_me=1; Path=/', $result->getHeader('Set-Cookie')[0]);
<ide> public function testToPsrHeaders()
<ide> $cake = new CakeResponse(['status' => 403]);
<ide> $cake->header([
<ide> 'X-testing' => ['one', 'two'],
<del> 'Location' => 'http://example.com/testing'
<add> 'Location' => 'http://example.com/testing',
<ide> ]);
<ide> $result = ResponseTransformer::toPsr($cake);
<ide> $expected = [
<ide><path>tests/TestCase/Http/ServerRequestFactoryTest.php
<ide> public function tearDown()
<ide> public function testFromGlobalsSuperGlobals()
<ide> {
<ide> $_POST = [
<del> 'title' => 'custom'
<add> 'title' => 'custom',
<ide> ];
<ide> $_FILES = [
<ide> 'image' => [
<ide> 'tmp_name' => __FILE__,
<ide> 'error' => 0,
<ide> 'name' => 'cats.png',
<ide> 'type' => 'image/png',
<del> 'size' => 2112
<del> ]
<add> 'size' => 2112,
<add> ],
<ide> ];
<ide> $_COOKIE = ['key' => 'value'];
<ide> $_GET = ['query' => 'string'];
<ide> public function testFromGlobalsUrlNoModRewriteWebrootDir()
<ide> 'dir' => 'app',
<ide> 'webroot' => 'www',
<ide> 'base' => false,
<del> 'baseUrl' => '/cake/index.php'
<add> 'baseUrl' => '/cake/index.php',
<ide> ]);
<ide> $server = [
<ide> 'DOCUMENT_ROOT' => '/Users/markstory/Sites',
<ide> public function testFromGlobalsUrlNoModRewrite()
<ide> 'dir' => 'app',
<ide> 'webroot' => 'webroot',
<ide> 'base' => false,
<del> 'baseUrl' => '/cake/index.php'
<add> 'baseUrl' => '/cake/index.php',
<ide> ]);
<ide> $server = [
<ide> 'DOCUMENT_ROOT' => '/Users/markstory/Sites',
<ide> public function testFromGlobalsUrlNoModRewriteRootDir()
<ide> 'dir' => 'cake',
<ide> 'webroot' => 'webroot',
<ide> 'base' => false,
<del> 'baseUrl' => '/index.php'
<add> 'baseUrl' => '/index.php',
<ide> ]);
<ide> $server = [
<ide> 'DOCUMENT_ROOT' => '/Users/markstory/Sites/cake',
<ide><path>tests/TestCase/Http/ServerRequestTest.php
<ide> public function testAcceptHeaderDetector()
<ide> public function testNoAutoParseConstruction()
<ide> {
<ide> $_GET = [
<del> 'one' => 'param'
<add> 'one' => 'param',
<ide> ];
<ide> $request = new ServerRequest();
<ide> $this->assertNull($request->getQuery('one'));
<ide> public function testConstructionQueryData()
<ide> $data = [
<ide> 'query' => [
<ide> 'one' => 'param',
<del> 'two' => 'banana'
<add> 'two' => 'banana',
<ide> ],
<del> 'url' => 'some/path'
<add> 'url' => 'some/path',
<ide> ];
<ide> $request = new ServerRequest($data);
<ide> $this->assertEquals($request->getQueryParams(), $data['query']);
<ide> public function testAddPaths()
<ide> $request = new ServerRequest();
<ide> $request->webroot = '/some/path/going/here/';
<ide> $result = $request->addPaths([
<del> 'random' => '/something', 'webroot' => '/', 'here' => '/', 'base' => '/base_dir'
<add> 'random' => '/something', 'webroot' => '/', 'here' => '/', 'base' => '/base_dir',
<ide> ]);
<ide>
<ide> $this->assertSame($result, $request, 'Method did not return itself. %s');
<ide> public function testAddPaths()
<ide> public function testPostParsing()
<ide> {
<ide> $post = [
<del> 'Article' => ['title']
<add> 'Article' => ['title'],
<ide> ];
<ide> $request = new ServerRequest(compact('post'));
<ide> $this->assertEquals($post, $request->getData());
<ide> public function testPostParsing()
<ide>
<ide> $post = [
<ide> 'Article' => ['title' => 'Testing'],
<del> 'action' => 'update'
<add> 'action' => 'update',
<ide> ];
<ide> $request = new ServerRequest(compact('post'));
<ide> $this->assertEquals($post, $request->getData());
<ide> public function testPostParsing()
<ide> public function testPutParsing()
<ide> {
<ide> $data = [
<del> 'Article' => ['title']
<add> 'Article' => ['title'],
<ide> ];
<ide> $request = new ServerRequest([
<ide> 'input' => 'Article[]=title',
<ide> 'environment' => [
<ide> 'REQUEST_METHOD' => 'PUT',
<del> 'CONTENT_TYPE' => 'application/x-www-form-urlencoded; charset=UTF-8'
<del> ]
<add> 'CONTENT_TYPE' => 'application/x-www-form-urlencoded; charset=UTF-8',
<add> ],
<ide> ]);
<ide> $this->assertEquals($data, $request->getData());
<ide>
<ide> public function testPutParsing()
<ide> 'input' => 'one=1&two=three',
<ide> 'environment' => [
<ide> 'REQUEST_METHOD' => 'PUT',
<del> 'CONTENT_TYPE' => 'application/x-www-form-urlencoded; charset=UTF-8'
<del> ]
<add> 'CONTENT_TYPE' => 'application/x-www-form-urlencoded; charset=UTF-8',
<add> ],
<ide> ]);
<ide> $this->assertEquals($data, $request->getData());
<ide>
<ide> $request = new ServerRequest([
<ide> 'input' => 'Article[title]=Testing&action=update',
<ide> 'environment' => [
<ide> 'REQUEST_METHOD' => 'DELETE',
<del> 'CONTENT_TYPE' => 'application/x-www-form-urlencoded; charset=UTF-8'
<del> ]
<add> 'CONTENT_TYPE' => 'application/x-www-form-urlencoded; charset=UTF-8',
<add> ],
<ide> ]);
<ide> $expected = [
<ide> 'Article' => ['title' => 'Testing'],
<del> 'action' => 'update'
<add> 'action' => 'update',
<ide> ];
<ide> $this->assertEquals($expected, $request->getData());
<ide>
<ide> $data = [
<ide> 'Article' => ['title'],
<del> 'Tag' => ['Tag' => [1, 2]]
<add> 'Tag' => ['Tag' => [1, 2]],
<ide> ];
<ide> $request = new ServerRequest([
<ide> 'input' => 'Article[]=title&Tag[Tag][]=1&Tag[Tag][]=2',
<ide> 'environment' => [
<ide> 'REQUEST_METHOD' => 'PATCH',
<del> 'CONTENT_TYPE' => 'application/x-www-form-urlencoded; charset=UTF-8'
<del> ]
<add> 'CONTENT_TYPE' => 'application/x-www-form-urlencoded; charset=UTF-8',
<add> ],
<ide> ]);
<ide> $this->assertEquals($data, $request->getData());
<ide> }
<ide> public function testPutParsingJSON()
<ide> 'input' => $data,
<ide> 'environment' => [
<ide> 'REQUEST_METHOD' => 'PUT',
<del> 'CONTENT_TYPE' => 'application/json'
<del> ]
<add> 'CONTENT_TYPE' => 'application/json',
<add> ],
<ide> ]);
<ide> $this->assertEquals([], $request->getData());
<ide> $result = $request->input('json_decode', true);
<ide> public function testFilesNested()
<ide> 'type' => ['file' => 'text/plain'],
<ide> 'tmp_name' => ['file' => __FILE__],
<ide> 'error' => ['file' => 0],
<del> 'size' => ['file' => 17178]
<add> 'size' => ['file' => 17178],
<ide> ],
<ide> 0 => [
<ide> 'name' => ['image' => 'scratch.text'],
<ide> 'type' => ['image' => 'text/plain'],
<ide> 'tmp_name' => ['image' => __FILE__],
<ide> 'error' => ['image' => 0],
<del> 'size' => ['image' => 1490]
<add> 'size' => ['image' => 1490],
<ide> ],
<ide> 'pictures' => [
<ide> 'name' => [
<ide> 0 => ['file' => 'a-file.png'],
<del> 1 => ['file' => 'a-moose.png']
<add> 1 => ['file' => 'a-moose.png'],
<ide> ],
<ide> 'type' => [
<ide> 0 => ['file' => 'image/png'],
<del> 1 => ['file' => 'image/jpg']
<add> 1 => ['file' => 'image/jpg'],
<ide> ],
<ide> 'tmp_name' => [
<ide> 0 => ['file' => __FILE__],
<del> 1 => ['file' => __FILE__]
<add> 1 => ['file' => __FILE__],
<ide> ],
<ide> 'error' => [
<ide> 0 => ['file' => 0],
<del> 1 => ['file' => 0]
<add> 1 => ['file' => 0],
<ide> ],
<ide> 'size' => [
<ide> 0 => ['file' => 17188],
<del> 1 => ['file' => 2010]
<add> 1 => ['file' => 2010],
<ide> ],
<del> ]
<add> ],
<ide> ];
<ide> $post = [
<ide> 'pictures' => [
<ide> 0 => ['name' => 'A cat'],
<del> 1 => ['name' => 'A moose']
<add> 1 => ['name' => 'A moose'],
<ide> ],
<ide> 0 => [
<del> 'name' => 'A dog'
<del> ]
<add> 'name' => 'A dog',
<add> ],
<ide> ];
<ide> $request = new ServerRequest(compact('files', 'post'));
<ide> $expected = [
<ide> public function testFilesNested()
<ide> 'tmp_name' => __FILE__,
<ide> 'error' => 0,
<ide> 'size' => 17178,
<del> ]
<add> ],
<ide> ],
<ide> 'pictures' => [
<ide> 0 => [
<ide> public function testFilesNested()
<ide> 'tmp_name' => __FILE__,
<ide> 'error' => '0',
<ide> 'size' => 17188,
<del> ]
<add> ],
<ide> ],
<ide> 1 => [
<ide> 'name' => 'A moose',
<ide> public function testFilesNested()
<ide> 'tmp_name' => __FILE__,
<ide> 'error' => '0',
<ide> 'size' => 2010,
<del> ]
<del> ]
<add> ],
<add> ],
<ide> ],
<ide> 0 => [
<ide> 'name' => 'A dog',
<ide> public function testFilesNested()
<ide> 'type' => 'text/plain',
<ide> 'tmp_name' => __FILE__,
<ide> 'error' => 0,
<del> 'size' => 1490
<del> ]
<del> ]
<add> 'size' => 1490,
<add> ],
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, $request->getData());
<ide>
<ide> public function testFilesFlat()
<ide> 'tmp_name' => __FILE__,
<ide> 'error' => 0,
<ide> 'size' => 123,
<del> ]
<add> ],
<ide> ];
<ide>
<ide> $request = new ServerRequest(compact('files'));
<ide> public function testFilesFlat()
<ide> 'type' => 'application/octet-stream',
<ide> 'tmp_name' => __FILE__,
<ide> 'error' => 0,
<del> 'size' => 123
<del> ]
<add> 'size' => 123,
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, $request->getData());
<ide>
<ide> public function testFilesZeroithIndex()
<ide> ];
<ide>
<ide> $request = new ServerRequest([
<del> 'files' => $files
<add> 'files' => $files,
<ide> ]);
<ide> $this->assertEquals($files, $request->getData());
<ide>
<ide> public function testGetUploadedFile()
<ide> $new = $request->withUploadedFiles([
<ide> 'pictures' => [
<ide> [
<del> 'image' => $file
<del> ]
<del> ]
<add> 'image' => $file,
<add> ],
<add> ],
<ide> ]);
<ide> $this->assertNull($new->getUploadedFile('pictures'));
<ide> $this->assertNull($new->getUploadedFile('pictures.0'));
<ide> public function testMethodOverrides()
<ide>
<ide> $request = new ServerRequest([
<ide> 'environment' => ['REQUEST_METHOD' => 'POST'],
<del> 'post' => ['_method' => 'PUT']
<add> 'post' => ['_method' => 'PUT'],
<ide> ]);
<ide> $this->assertEquals('PUT', $request->getEnv('REQUEST_METHOD'));
<ide> $this->assertEquals('POST', $request->getEnv('ORIGINAL_REQUEST_METHOD'));
<ide> public function testClientIpWithTrustedProxies()
<ide> '192.168.1.0',
<ide> '192.168.1.1',
<ide> '192.168.1.2',
<del> '192.168.1.3'
<add> '192.168.1.3',
<ide> ]);
<ide>
<ide> $this->assertEquals('real.ip', $request->clientIp());
<ide> public function testRefererBasePath()
<ide> $request = new ServerRequest([
<ide> 'url' => '/waves/users/login',
<ide> 'webroot' => '/waves/',
<del> 'base' => '/waves'
<add> 'base' => '/waves',
<ide> ]);
<ide> $request = $request->withEnv('HTTP_REFERER', Configure::read('App.fullBaseUrl') . '/waves/waves/add');
<ide>
<ide> public function testMethod()
<ide> public function testGetMethod()
<ide> {
<ide> $request = new ServerRequest([
<del> 'environment' => ['REQUEST_METHOD' => 'delete']
<add> 'environment' => ['REQUEST_METHOD' => 'delete'],
<ide> ]);
<ide> $this->assertEquals('delete', $request->getMethod());
<ide> }
<ide> public function testGetMethod()
<ide> public function testWithMethod()
<ide> {
<ide> $request = new ServerRequest([
<del> 'environment' => ['REQUEST_METHOD' => 'delete']
<add> 'environment' => ['REQUEST_METHOD' => 'delete'],
<ide> ]);
<ide> $new = $request->withMethod('put');
<ide> $this->assertNotSame($new, $request);
<ide> public function testWithMethodInvalid()
<ide> $this->expectException(\InvalidArgumentException::class);
<ide> $this->expectExceptionMessage('Unsupported HTTP method "no good" provided');
<ide> $request = new ServerRequest([
<del> 'environment' => ['REQUEST_METHOD' => 'delete']
<add> 'environment' => ['REQUEST_METHOD' => 'delete'],
<ide> ]);
<ide> $request->withMethod('no good');
<ide> }
<ide> public function testGetProtocolVersion()
<ide>
<ide> // SERVER var.
<ide> $request = new ServerRequest([
<del> 'environment' => ['SERVER_PROTOCOL' => 'HTTP/1.0']
<add> 'environment' => ['SERVER_PROTOCOL' => 'HTTP/1.0'],
<ide> ]);
<ide> $this->assertEquals('1.0', $request->getProtocolVersion());
<ide> }
<ide> public function testHeader()
<ide> 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-ca) AppleWebKit/534.8+ (KHTML, like Gecko) Version/5.0 Safari/533.16',
<ide> 'CONTENT_TYPE' => 'application/json',
<ide> 'CONTENT_LENGTH' => 1337,
<del> 'HTTP_CONTENT_MD5' => 'abc123'
<add> 'HTTP_CONTENT_MD5' => 'abc123',
<ide> ]]);
<ide>
<ide> $this->assertEquals($request->getEnv('HTTP_HOST'), $request->getHeaderLine('host'));
<ide> public function testGetHeaders()
<ide> 'CONTENT_TYPE' => 'application/json',
<ide> 'CONTENT_LENGTH' => 1337,
<ide> 'HTTP_CONTENT_MD5' => 'abc123',
<del> 'HTTP_DOUBLE' => ['a', 'b']
<add> 'HTTP_DOUBLE' => ['a', 'b'],
<ide> ]]);
<ide> $headers = $request->getHeaders();
<ide> $expected = [
<ide> public function testHasHeader()
<ide> 'CONTENT_TYPE' => 'application/json',
<ide> 'CONTENT_LENGTH' => 1337,
<ide> 'HTTP_CONTENT_MD5' => 'abc123',
<del> 'HTTP_DOUBLE' => ['a', 'b']
<add> 'HTTP_DOUBLE' => ['a', 'b'],
<ide> ]]);
<ide> $this->assertTrue($request->hasHeader('Host'));
<ide> $this->assertTrue($request->hasHeader('Content-Type'));
<ide> public function testGetHeader()
<ide> 'CONTENT_TYPE' => 'application/json',
<ide> 'CONTENT_LENGTH' => 1337,
<ide> 'HTTP_CONTENT_MD5' => 'abc123',
<del> 'HTTP_DOUBLE' => ['a', 'b']
<add> 'HTTP_DOUBLE' => ['a', 'b'],
<ide> ]]);
<ide> $this->assertEquals([], $request->getHeader('Not-there'));
<ide>
<ide> public function testGetHeaderLine()
<ide> 'CONTENT_TYPE' => 'application/json',
<ide> 'CONTENT_LENGTH' => 1337,
<ide> 'HTTP_CONTENT_MD5' => 'abc123',
<del> 'HTTP_DOUBLE' => ['a', 'b']
<add> 'HTTP_DOUBLE' => ['a', 'b'],
<ide> ]]);
<ide> $this->assertEquals('', $request->getHeaderLine('Authorization'));
<ide>
<ide> public function testWithHeader()
<ide> 'CONTENT_TYPE' => 'application/json',
<ide> 'CONTENT_LENGTH' => 1337,
<ide> 'HTTP_CONTENT_MD5' => 'abc123',
<del> 'HTTP_DOUBLE' => ['a', 'b']
<add> 'HTTP_DOUBLE' => ['a', 'b'],
<ide> ]]);
<ide> $new = $request->withHeader('Content-Length', 999);
<ide> $this->assertNotSame($new, $request);
<ide> public function testWithAddedHeader()
<ide> 'CONTENT_TYPE' => 'application/json',
<ide> 'CONTENT_LENGTH' => 1337,
<ide> 'HTTP_CONTENT_MD5' => 'abc123',
<del> 'HTTP_DOUBLE' => ['a', 'b']
<add> 'HTTP_DOUBLE' => ['a', 'b'],
<ide> ]]);
<ide> $new = $request->withAddedHeader('Double', 'c');
<ide> $this->assertNotSame($new, $request);
<ide> public function testWithoutHeader()
<ide> 'CONTENT_TYPE' => 'application/json',
<ide> 'CONTENT_LENGTH' => 1337,
<ide> 'HTTP_CONTENT_MD5' => 'abc123',
<del> 'HTTP_DOUBLE' => ['a', 'b']
<add> 'HTTP_DOUBLE' => ['a', 'b'],
<ide> ]]);
<ide> $new = $request->withoutHeader('Content-Length', 999);
<ide> $this->assertNotSame($new, $request);
<ide> public function testWithoutHeader()
<ide> public function testAccepts()
<ide> {
<ide> $request = new ServerRequest(['environment' => [
<del> 'HTTP_ACCEPT' => 'text/xml,application/xml;q=0.9,application/xhtml+xml,text/html,text/plain,image/png'
<add> 'HTTP_ACCEPT' => 'text/xml,application/xml;q=0.9,application/xhtml+xml,text/html,text/plain,image/png',
<ide> ]]);
<ide>
<ide> $result = $request->accepts();
<ide> $expected = [
<del> 'text/xml', 'application/xhtml+xml', 'text/html', 'text/plain', 'image/png', 'application/xml'
<add> 'text/xml', 'application/xhtml+xml', 'text/html', 'text/plain', 'image/png', 'application/xml',
<ide> ];
<ide> $this->assertEquals($expected, $result, 'Content types differ.');
<ide>
<ide> public function testAccepts()
<ide> public function testAcceptWithWhitespace()
<ide> {
<ide> $request = new ServerRequest(['environment' => [
<del> 'HTTP_ACCEPT' => 'text/xml , text/html , text/plain,image/png'
<add> 'HTTP_ACCEPT' => 'text/xml , text/html , text/plain,image/png',
<ide> ]]);
<ide> $result = $request->accepts();
<ide> $expected = [
<del> 'text/xml', 'text/html', 'text/plain', 'image/png'
<add> 'text/xml', 'text/html', 'text/plain', 'image/png',
<ide> ];
<ide> $this->assertEquals($expected, $result, 'Content types differ.');
<ide>
<ide> public function testAcceptWithWhitespace()
<ide> public function testAcceptWithQvalueSorting()
<ide> {
<ide> $request = new ServerRequest(['environment' => [
<del> 'HTTP_ACCEPT' => 'text/html;q=0.8,application/json;q=0.7,application/xml;q=1.0'
<add> 'HTTP_ACCEPT' => 'text/html;q=0.8,application/json;q=0.7,application/xml;q=1.0',
<ide> ]]);
<ide> $result = $request->accepts();
<ide> $expected = ['application/xml', 'text/html', 'application/json'];
<ide> public function testAcceptWithQvalueSorting()
<ide> public function testParseAcceptWithQValue()
<ide> {
<ide> $request = new ServerRequest(['environment' => [
<del> 'HTTP_ACCEPT' => 'text/html;q=0.8,application/json;q=0.7,application/xml;q=1.0,image/png'
<add> 'HTTP_ACCEPT' => 'text/html;q=0.8,application/json;q=0.7,application/xml;q=1.0,image/png',
<ide> ]]);
<ide> $result = $request->parseAccept();
<ide> $expected = [
<ide> public function testParseAcceptWithQValue()
<ide> public function testParseAcceptNoQValues()
<ide> {
<ide> $request = new ServerRequest(['environment' => [
<del> 'HTTP_ACCEPT' => 'application/json, text/plain, */*'
<add> 'HTTP_ACCEPT' => 'application/json, text/plain, */*',
<ide> ]]);
<ide> $result = $request->parseAccept();
<ide> $expected = [
<ide> public function testParseAcceptIgnoreAcceptExtensions()
<ide> {
<ide> $request = new ServerRequest(['environment' => [
<ide> 'url' => '/',
<del> 'HTTP_ACCEPT' => 'application/json;level=1, text/plain, */*'
<add> 'HTTP_ACCEPT' => 'application/json;level=1, text/plain, */*',
<ide> ]], false);
<ide>
<ide> $result = $request->parseAccept();
<ide> public function testParseAcceptInvalidSyntax()
<ide> {
<ide> $request = new ServerRequest(['environment' => [
<ide> 'url' => '/',
<del> 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;image/png,image/jpeg,image/*;q=0.9,*/*;q=0.8'
<add> 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;image/png,image/jpeg,image/*;q=0.9,*/*;q=0.8',
<ide> ]], false);
<ide> $result = $request->parseAccept();
<ide> $expected = [
<ide> public function testBaseUrlWithNoModRewrite()
<ide> 'dir' => APP_DIR,
<ide> 'webroot' => 'webroot',
<ide> 'base' => false,
<del> 'baseUrl' => '/cake/index.php'
<add> 'baseUrl' => '/cake/index.php',
<ide> ]);
<ide>
<ide> $request = ServerRequestFactory::fromGlobals();
<ide> public static function environmentGenerator()
<ide> 'base' => false,
<ide> 'baseUrl' => '/index.php',
<ide> 'dir' => 'TestApp',
<del> 'webroot' => 'webroot'
<add> 'webroot' => 'webroot',
<ide> ],
<ide> 'SERVER' => [
<ide> 'SCRIPT_NAME' => '/index.php',
<ide> public static function environmentGenerator()
<ide> [
<ide> 'base' => '/index.php',
<ide> 'webroot' => '/webroot/',
<del> 'url' => ''
<add> 'url' => '',
<ide> ],
<ide> ],
<ide> [
<ide> public static function environmentGenerator()
<ide> 'base' => false,
<ide> 'baseUrl' => '/index.php?',
<ide> 'dir' => 'TestApp',
<del> 'webroot' => 'webroot'
<add> 'webroot' => 'webroot',
<ide> ],
<ide> 'SERVER' => [
<ide> 'QUERY_STRING' => '/posts/add',
<ide> public static function environmentGenerator()
<ide> 'URL' => '/index.php?/posts/add',
<ide> 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot',
<ide> 'argv' => ['/posts/add'],
<del> 'argc' => 1
<add> 'argc' => 1,
<ide> ],
<ide> ],
<ide> [
<ide> 'url' => 'posts/add',
<ide> 'base' => '/index.php?',
<del> 'webroot' => '/webroot/'
<del> ]
<add> 'webroot' => '/webroot/',
<add> ],
<ide> ],
<ide> [
<ide> 'IIS - No rewrite sub dir 2',
<ide> public static function environmentGenerator()
<ide> 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot',
<ide> 'PHP_SELF' => '/site/index.php',
<ide> 'argv' => [],
<del> 'argc' => 0
<add> 'argc' => 0,
<ide> ],
<ide> ],
<ide> [
<ide> 'url' => '',
<ide> 'base' => '/site/index.php',
<del> 'webroot' => '/site/webroot/'
<add> 'webroot' => '/site/webroot/',
<ide> ],
<ide> ],
<ide> [
<ide> public static function environmentGenerator()
<ide> 'base' => false,
<ide> 'baseUrl' => '/site/index.php',
<ide> 'dir' => 'TestApp',
<del> 'webroot' => 'webroot'
<add> 'webroot' => 'webroot',
<ide> ],
<ide> 'GET' => ['/posts/add' => ''],
<ide> 'SERVER' => [
<ide> public static function environmentGenerator()
<ide> 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot',
<ide> 'PHP_SELF' => '/site/index.php/posts/add',
<ide> 'argv' => ['/posts/add'],
<del> 'argc' => 1
<add> 'argc' => 1,
<ide> ],
<ide> ],
<ide> [
<ide> 'url' => 'posts/add',
<ide> 'base' => '/site/index.php',
<del> 'webroot' => '/site/webroot/'
<del> ]
<add> 'webroot' => '/site/webroot/',
<add> ],
<ide> ],
<ide> [
<ide> 'Apache - No rewrite, document root set to webroot, requesting path',
<ide> public static function environmentGenerator()
<ide> 'base' => false,
<ide> 'baseUrl' => '/index.php',
<ide> 'dir' => 'TestApp',
<del> 'webroot' => 'webroot'
<add> 'webroot' => 'webroot',
<ide> ],
<ide> 'SERVER' => [
<ide> 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/App/webroot',
<ide> public static function environmentGenerator()
<ide> [
<ide> 'url' => 'posts/index',
<ide> 'base' => '/index.php',
<del> 'webroot' => '/'
<add> 'webroot' => '/',
<ide> ],
<ide> ],
<ide> [
<ide> public static function environmentGenerator()
<ide> 'base' => false,
<ide> 'baseUrl' => '/index.php',
<ide> 'dir' => 'TestApp',
<del> 'webroot' => 'webroot'
<add> 'webroot' => 'webroot',
<ide> ],
<ide> 'SERVER' => [
<ide> 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/App/webroot',
<ide> public static function environmentGenerator()
<ide> [
<ide> 'url' => '',
<ide> 'base' => '/index.php',
<del> 'webroot' => '/'
<add> 'webroot' => '/',
<ide> ],
<ide> ],
<ide> [
<ide> public static function environmentGenerator()
<ide> 'base' => false,
<ide> 'baseUrl' => '/site/index.php',
<ide> 'dir' => 'TestApp',
<del> 'webroot' => 'webroot'
<add> 'webroot' => 'webroot',
<ide> ],
<ide> 'SERVER' => [
<ide> 'SERVER_NAME' => 'localhost',
<ide> public static function environmentGenerator()
<ide> 'base' => false,
<ide> 'baseUrl' => '/site/index.php',
<ide> 'dir' => 'TestApp',
<del> 'webroot' => 'webroot'
<add> 'webroot' => 'webroot',
<ide> ],
<ide> 'SERVER' => [
<ide> 'SERVER_NAME' => 'localhost',
<ide> public static function environmentGenerator()
<ide> 'base' => false,
<ide> 'baseUrl' => '/site/index.php',
<ide> 'dir' => 'TestApp',
<del> 'webroot' => 'webroot'
<add> 'webroot' => 'webroot',
<ide> ],
<ide> 'GET' => ['a' => 'b', 'c' => 'd'],
<ide> 'SERVER' => [
<ide> public static function environmentGenerator()
<ide> 'SCRIPT_NAME' => '/site/index.php',
<ide> 'PATH_INFO' => '/posts/index',
<ide> 'PHP_SELF' => '/site/index.php/posts/index',
<del> 'QUERY_STRING' => 'a=b&c=d'
<add> 'QUERY_STRING' => 'a=b&c=d',
<ide> ],
<ide> ],
<ide> [
<ide> public static function environmentGenerator()
<ide> 'base' => false,
<ide> 'baseUrl' => false,
<ide> 'dir' => 'TestApp',
<del> 'webroot' => 'webroot'
<add> 'webroot' => 'webroot',
<ide> ],
<ide> 'SERVER' => [
<ide> 'SERVER_NAME' => 'localhost',
<ide> public static function environmentGenerator()
<ide> 'base' => false,
<ide> 'baseUrl' => false,
<ide> 'dir' => 'TestApp',
<del> 'webroot' => 'webroot'
<add> 'webroot' => 'webroot',
<ide> ],
<ide> 'SERVER' => [
<ide> 'SERVER_NAME' => 'localhost',
<ide> public static function environmentGenerator()
<ide> 'base' => false,
<ide> 'baseUrl' => false,
<ide> 'dir' => 'TestApp',
<del> 'webroot' => 'webroot'
<add> 'webroot' => 'webroot',
<ide> ],
<ide> 'SERVER' => [
<ide> 'SERVER_NAME' => 'localhost',
<ide> public static function environmentGenerator()
<ide> 'base' => false,
<ide> 'baseUrl' => false,
<ide> 'dir' => 'TestApp',
<del> 'webroot' => 'webroot'
<add> 'webroot' => 'webroot',
<ide> ],
<ide> 'SERVER' => [
<ide> 'SERVER_NAME' => 'localhost',
<ide> public static function environmentGenerator()
<ide> 'base' => false,
<ide> 'baseUrl' => false,
<ide> 'dir' => 'TestApp',
<del> 'webroot' => 'webroot'
<add> 'webroot' => 'webroot',
<ide> ],
<ide> 'GET' => ['/posts/add' => ''],
<ide> 'SERVER' => [
<ide> public static function environmentGenerator()
<ide> 'url' => 'posts/add',
<ide> 'base' => '',
<ide> 'webroot' => '/',
<del> 'urlParams' => []
<add> 'urlParams' => [],
<ide> ],
<ide> ],
<ide> [
<ide> public static function environmentGenerator()
<ide> 'base' => false,
<ide> 'baseUrl' => false,
<ide> 'dir' => 'app',
<del> 'webroot' => 'webroot'
<add> 'webroot' => 'webroot',
<ide> ],
<ide> 'GET' => ['/site/posts/add' => ''],
<ide> 'SERVER' => [
<ide> public static function environmentGenerator()
<ide> 'url' => 'posts/add',
<ide> 'base' => '/site',
<ide> 'webroot' => '/site/',
<del> 'urlParams' => []
<add> 'urlParams' => [],
<ide> ],
<ide> ],
<ide> ];
<ide> public function testQuery()
<ide> {
<ide> $this->deprecated(function () {
<ide> $array = [
<del> 'query' => ['foo' => 'bar', 'zero' => '0']
<add> 'query' => ['foo' => 'bar', 'zero' => '0'],
<ide> ];
<ide> $request = new ServerRequest($array);
<ide>
<ide> public function testGetQuery()
<ide> 'foo' => 'bar',
<ide> 'zero' => '0',
<ide> 'test' => [
<del> 'foo', 'bar'
<del> ]
<del> ]
<add> 'foo', 'bar',
<add> ],
<add> ],
<ide> ];
<ide> $request = new ServerRequest($array);
<ide>
<ide> $this->assertEquals([
<ide> 'foo' => 'bar',
<ide> 'zero' => '0',
<ide> 'test' => [
<del> 'foo', 'bar'
<del> ]
<add> 'foo', 'bar',
<add> ],
<ide> ], $request->getQuery());
<ide>
<ide> $this->assertSame('bar', $request->getQuery('foo'));
<ide> public function testGetQueryParams()
<ide> {
<ide> $get = [
<ide> 'test' => ['foo', 'bar'],
<del> 'key' => 'value'
<add> 'key' => 'value',
<ide> ];
<ide>
<ide> $request = new ServerRequest([
<del> 'query' => $get
<add> 'query' => $get,
<ide> ]);
<ide> $this->assertSame($get, $request->getQueryParams());
<ide> }
<ide> public function testWithQueryParams()
<ide> {
<ide> $get = [
<ide> 'test' => ['foo', 'bar'],
<del> 'key' => 'value'
<add> 'key' => 'value',
<ide> ];
<ide>
<ide> $request = new ServerRequest([
<del> 'query' => $get
<add> 'query' => $get,
<ide> ]);
<ide> $new = $request->withQueryParams(['new' => 'data']);
<ide> $this->assertSame($get, $request->getQueryParams());
<ide> public function testGetServerParams()
<ide> ];
<ide>
<ide> $request = new ServerRequest([
<del> 'environment' => $vars
<add> 'environment' => $vars,
<ide> ]);
<ide> $expected = $vars + [
<ide> 'CONTENT_TYPE' => null,
<ide> public function testReadingParams()
<ide> 'admin' => true,
<ide> 'truthy' => 1,
<ide> 'zero' => '0',
<del> ]
<add> ],
<ide> ]);
<ide> $this->assertFalse($request->getParam('not_set'));
<ide> $this->assertTrue($request->getParam('admin'));
<ide> public function testReadingParamsOld()
<ide> 'admin' => true,
<ide> 'truthy' => 1,
<ide> 'zero' => '0',
<del> ]
<add> ],
<ide> ]);
<ide> $this->assertFalse($request->param('not_set'));
<ide> $this->assertTrue($request->param('admin'));
<ide> public function testGetData()
<ide> {
<ide> $post = [
<ide> 'Model' => [
<del> 'field' => 'value'
<del> ]
<add> 'field' => 'value',
<add> ],
<ide> ];
<ide> $request = new ServerRequest(compact('post'));
<ide> $this->deprecated(function () use ($post, $request) {
<ide> public function testDataWriting()
<ide> $this->deprecated(function () {
<ide> $_POST['data'] = [
<ide> 'Model' => [
<del> 'field' => 'value'
<del> ]
<add> 'field' => 'value',
<add> ],
<ide> ];
<ide> $request = new ServerRequest();
<ide> $result = $request->data('Model.new_value', 'new value');
<ide> public function testGetParam($toRead, $expected)
<ide> 'admin' => true,
<ide> 'truthy' => 1,
<ide> 'zero' => '0',
<del> ]
<add> ],
<ide> ]);
<ide> $this->deprecated(function () use ($expected, $request, $toRead) {
<ide> $this->assertSame($expected, $request->param($toRead));
<ide> public function testGetParamDefault()
<ide> 'params' => [
<ide> 'controller' => 'Articles',
<ide> 'null' => null,
<del> ]
<add> ],
<ide> ]);
<ide> $this->assertSame('Articles', $request->getParam('controller', 'default'));
<ide> $this->assertSame('default', $request->getParam('null', 'default'));
<ide> public function testHere()
<ide> $request = new ServerRequest([
<ide> 'query' => $q,
<ide> 'url' => '/posts/add/1/value',
<del> 'base' => '/base_path'
<add> 'base' => '/base_path',
<ide> ]);
<ide>
<ide> $result = $request->here();
<ide> public function testHere()
<ide> $request = new ServerRequest([
<ide> 'url' => '/posts/base_path/1/value',
<ide> 'query' => ['test' => 'value'],
<del> 'base' => '/base_path'
<add> 'base' => '/base_path',
<ide> ]);
<ide> $result = $request->here();
<ide> $this->assertEquals('/base_path/posts/base_path/1/value?test=value', $result);
<ide> public function testSetInput()
<ide> public function testInput()
<ide> {
<ide> $request = new ServerRequest([
<del> 'input' => 'I came from stdin'
<add> 'input' => 'I came from stdin',
<ide> ]);
<ide> $result = $request->input();
<ide> $this->assertEquals('I came from stdin', $result);
<ide> public function testInput()
<ide> public function testInputDecode()
<ide> {
<ide> $request = new ServerRequest([
<del> 'input' => '{"name":"value"}'
<add> 'input' => '{"name":"value"}',
<ide> ]);
<ide>
<ide> $result = $request->input('json_decode');
<ide> public function testInputDecodeExtraParams()
<ide> XML;
<ide>
<ide> $request = new ServerRequest([
<del> 'input' => $xml
<add> 'input' => $xml,
<ide> ]);
<ide>
<ide> $result = $request->input('Cake\Utility\Xml::build', ['return' => 'domdocument']);
<ide> public function testInputDecodeExtraParams()
<ide> public function testGetBody()
<ide> {
<ide> $request = new ServerRequest([
<del> 'input' => 'key=val&some=data'
<add> 'input' => 'key=val&some=data',
<ide> ]);
<ide> $result = $request->getBody();
<ide> $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $result);
<ide> public function testGetBody()
<ide> public function testWithBody()
<ide> {
<ide> $request = new ServerRequest([
<del> 'input' => 'key=val&some=data'
<add> 'input' => 'key=val&some=data',
<ide> ]);
<ide> $body = $this->getMockBuilder('Psr\Http\Message\StreamInterface')->getMock();
<ide> $new = $request->withBody($body);
<ide> public function testWithUri()
<ide> 'environment' => [
<ide> 'HTTP_HOST' => 'example.com',
<ide> ],
<del> 'url' => 'articles/view/3'
<add> 'url' => 'articles/view/3',
<ide> ]);
<ide> $uri = $this->getMockBuilder('Psr\Http\Message\UriInterface')->getMock();
<ide> $new = $request->withUri($uri);
<ide> public function testWithUriCompatibility()
<ide> 'environment' => [
<ide> 'HTTP_HOST' => 'example.com',
<ide> ],
<del> 'url' => 'articles/view/3'
<add> 'url' => 'articles/view/3',
<ide> ]);
<ide> $uri = $this->getMockBuilder('Psr\Http\Message\UriInterface')->getMock();
<ide> $new = $request->withUri($uri);
<ide> public function testWithUriPreserveHost()
<ide> {
<ide> $request = new ServerRequest([
<ide> 'environment' => [
<del> 'HTTP_HOST' => 'localhost'
<add> 'HTTP_HOST' => 'localhost',
<ide> ],
<del> 'url' => 'articles/view/3'
<add> 'url' => 'articles/view/3',
<ide> ]);
<ide> $uri = new Uri();
<ide> $uri = $uri->withHost('example.com')
<ide> public function testWithUriPreserveHost()
<ide> public function testWithUriPreserveHostNoHostHeader()
<ide> {
<ide> $request = new ServerRequest([
<del> 'url' => 'articles/view/3'
<add> 'url' => 'articles/view/3',
<ide> ]);
<ide> $uri = new Uri();
<ide> $uri = $uri->withHost('example.com')
<ide> public function testIsRequested()
<ide> 'controller' => 'posts',
<ide> 'action' => 'index',
<ide> 'plugin' => null,
<del> 'requested' => 1
<del> ]
<add> 'requested' => 1,
<add> ],
<ide> ]);
<ide> $this->assertTrue($request->is('requested'));
<ide> $this->assertTrue($request->isRequested());
<ide> public function testIsRequested()
<ide> 'controller' => 'posts',
<ide> 'action' => 'index',
<ide> 'plugin' => null,
<del> ]
<add> ],
<ide> ]);
<ide> $this->assertFalse($request->is('requested'));
<ide> $this->assertFalse($request->isRequested());
<ide> public function testGetCookie()
<ide> 'cookies' => [
<ide> 'testing' => 'A value in the cookie',
<ide> 'user' => [
<del> 'remember' => '1'
<del> ]
<del> ]
<add> 'remember' => '1',
<add> ],
<add> ],
<ide> ]);
<ide>
<ide> $this->deprecated(function () use ($request) {
<ide> public function testGetCookie()
<ide> public function testGetCookieParams()
<ide> {
<ide> $cookies = [
<del> 'testing' => 'A value in the cookie'
<add> 'testing' => 'A value in the cookie',
<ide> ];
<ide> $request = new ServerRequest(['cookies' => $cookies]);
<ide> $this->assertSame($cookies, $request->getCookieParams());
<ide> public function testGetCookieParams()
<ide> public function testWithCookieParams()
<ide> {
<ide> $cookies = [
<del> 'testing' => 'A value in the cookie'
<add> 'testing' => 'A value in the cookie',
<ide> ];
<ide> $request = new ServerRequest(['cookies' => $cookies]);
<ide> $new = $request->withCookieParams(['remember_me' => 1]);
<ide> public function testGetCookieCollection()
<ide> {
<ide> $cookies = [
<ide> 'remember_me' => '1',
<del> 'color' => 'blue'
<add> 'color' => 'blue',
<ide> ];
<ide> $request = new ServerRequest(['cookies' => $cookies]);
<ide>
<ide> public function testAllowMethod()
<ide> {
<ide> $request = new ServerRequest(['environment' => [
<ide> 'url' => '/posts/edit/1',
<del> 'REQUEST_METHOD' => 'PUT'
<add> 'REQUEST_METHOD' => 'PUT',
<ide> ]]);
<ide>
<ide> $this->assertTrue($request->allowMethod('put'));
<ide> public function testAllowMethodException()
<ide> {
<ide> $request = new ServerRequest([
<ide> 'url' => '/posts/edit/1',
<del> 'environment' => ['REQUEST_METHOD' => 'PUT']
<add> 'environment' => ['REQUEST_METHOD' => 'PUT'],
<ide> ]);
<ide>
<ide> try {
<ide> public function testMethodOverrideEmptyData()
<ide> $post = ['_method' => 'GET', 'foo' => 'bar'];
<ide> $request = new ServerRequest([
<ide> 'post' => $post,
<del> 'environment' => ['REQUEST_METHOD' => 'POST']
<add> 'environment' => ['REQUEST_METHOD' => 'POST'],
<ide> ]);
<ide> $this->assertEmpty($request->getData());
<ide>
<ide> public function testMethodOverrideEmptyData()
<ide> 'post' => ['foo' => 'bar'],
<ide> 'environment' => [
<ide> 'REQUEST_METHOD' => 'POST',
<del> 'HTTP_X_HTTP_METHOD_OVERRIDE' => 'GET'
<del> ]
<add> 'HTTP_X_HTTP_METHOD_OVERRIDE' => 'GET',
<add> ],
<ide> ]);
<ide> $this->assertEmpty($request->getData());
<ide> }
<ide> public function testMethodOverrideEmptyData()
<ide> public function testWithParam()
<ide> {
<ide> $request = new ServerRequest([
<del> 'params' => ['controller' => 'Articles']
<add> 'params' => ['controller' => 'Articles'],
<ide> ]);
<ide> $result = $request->withParam('action', 'view');
<ide> $this->assertNotSame($result, $request, 'New instance should be made');
<ide> public function testWithData()
<ide> $request = new ServerRequest([
<ide> 'post' => [
<ide> 'Model' => [
<del> 'field' => 'value'
<del> ]
<del> ]
<add> 'field' => 'value',
<add> ],
<add> ],
<ide> ]);
<ide> $result = $request->withData('Model.new_value', 'new value');
<ide> $this->assertNull($request->getData('Model.new_value'), 'Original request should not change.');
<ide> public function testWithoutData()
<ide> 'post' => [
<ide> 'Model' => [
<ide> 'id' => 1,
<del> 'field' => 'value'
<del> ]
<del> ]
<add> 'field' => 'value',
<add> ],
<add> ],
<ide> ]);
<ide> $updated = $request->withoutData('Model.field');
<ide> $this->assertNotSame($updated, $request);
<ide> public function testWithDataMissingIntermediaryKeys()
<ide> $request = new ServerRequest([
<ide> 'post' => [
<ide> 'Model' => [
<del> 'field' => 'value'
<del> ]
<del> ]
<add> 'field' => 'value',
<add> ],
<add> ],
<ide> ]);
<ide> $result = $request->withData('Model.field.new_value', 'new value');
<ide> $this->assertEquals(
<ide> public function testWithDataMissingIntermediaryKeys()
<ide> public function testWithDataFalseyValues()
<ide> {
<ide> $request = new ServerRequest([
<del> 'post' => []
<add> 'post' => [],
<ide> ]);
<ide> $result = $request->withData('false', false)
<ide> ->withData('null', null)
<ide> public function testWithDataFalseyValues()
<ide> 'null' => null,
<ide> 'empty_string' => '',
<ide> 'zero' => 0,
<del> 'zero_string' => '0'
<add> 'zero_string' => '0',
<ide> ];
<ide> $this->assertSame($expected, $result->getData());
<ide> }
<ide> public function testWithAttributesCompatibility()
<ide> $request = new ServerRequest([
<ide> 'params' => [
<ide> 'controller' => 'Articles',
<del> 'action' => 'index'
<add> 'action' => 'index',
<ide> ],
<ide> 'base' => '/cakeapp',
<del> 'webroot' => '/cakeapp/'
<add> 'webroot' => '/cakeapp/',
<ide> ]);
<ide>
<ide> $new = $request->withAttribute('base', '/replace')
<ide> public function testGetAttributesCompatibility($prop)
<ide> $request = new ServerRequest([
<ide> 'params' => [
<ide> 'controller' => 'Articles',
<del> 'action' => 'index'
<add> 'action' => 'index',
<ide> ],
<ide> 'url' => '/articles/view',
<ide> 'base' => '/cakeapp',
<del> 'webroot' => '/cakeapp/'
<add> 'webroot' => '/cakeapp/',
<ide> ]);
<ide>
<ide> if ($prop === 'session') {
<ide> public function testGetAttributes()
<ide> ],
<ide> 'webroot' => '',
<ide> 'base' => '',
<del> 'here' => '/'
<add> 'here' => '/',
<ide> ];
<ide> $this->assertEquals($expected, $new->getAttributes());
<ide> }
<ide> public function testWithRequestTarget()
<ide> $request = new ServerRequest([
<ide> 'environment' => [
<ide> 'REQUEST_URI' => '/articles/view/1',
<del> 'QUERY_STRING' => 'comments=1&open=0'
<add> 'QUERY_STRING' => 'comments=1&open=0',
<ide> ],
<del> 'base' => '/basedir'
<add> 'base' => '/basedir',
<ide> ]);
<ide> $this->assertEquals(
<ide> '/articles/view/1?comments=1&open=0',
<ide> public function emulatedPropertyProvider()
<ide> ['params'],
<ide> ['base'],
<ide> ['webroot'],
<del> ['session']
<add> ['session'],
<ide> ];
<ide> }
<ide>
<ide><path>tests/TestCase/Http/SessionTest.php
<ide> public function testSessionConfigIniSetting()
<ide> 'timeout' => 86400,
<ide> 'ini' => [
<ide> 'session.referer_check' => 'example.com',
<del> 'session.use_trans_sid' => false
<del> ]
<add> 'session.use_trans_sid' => false,
<add> ],
<ide> ];
<ide>
<ide> Session::create($config);
<ide> public function testWriteArray()
<ide> 'one' => 1,
<ide> 'two' => 2,
<ide> 'three' => ['something'],
<del> 'null' => null
<add> 'null' => null,
<ide> ]);
<ide> $this->assertEquals(1, $session->read('one'));
<ide> $this->assertEquals(['something'], $session->read('three'));
<ide> public function testUsingAppLibsHandler()
<ide> 'handler' => [
<ide> 'engine' => 'TestAppLibSession',
<ide> 'these' => 'are',
<del> 'a few' => 'options'
<del> ]
<add> 'a few' => 'options',
<add> ],
<ide> ];
<ide>
<ide> $session = Session::create($config);
<ide> public function testUsingPluginHandler()
<ide> $config = [
<ide> 'defaults' => 'cake',
<ide> 'handler' => [
<del> 'engine' => 'TestPlugin.TestPluginSession'
<del> ]
<add> 'engine' => 'TestPlugin.TestPluginSession',
<add> ],
<ide> ];
<ide>
<ide> $session = Session::create($config);
<ide> public function testCheckStartsSessionWithCookiesDisabled()
<ide> 'ini' => [
<ide> 'session.use_cookies' => 0,
<ide> 'session.use_trans_sid' => 0,
<del> ]
<add> ],
<ide> ]);
<ide>
<ide> $this->assertFalse($session->started());
<ide> public function testCheckStartsSessionWithCookie()
<ide> 'ini' => [
<ide> 'session.use_cookies' => 1,
<ide> 'session.use_trans_sid' => 0,
<del> ]
<add> ],
<ide> ]);
<ide>
<ide> $this->assertFalse($session->started());
<ide> public function testCheckStartsSessionWithSIDinURL()
<ide> 'ini' => [
<ide> 'session.use_cookies' => 1,
<ide> 'session.use_trans_sid' => 1,
<del> ]
<add> ],
<ide> ]);
<ide>
<ide> $this->assertFalse($session->started());
<ide> public function testCheckDoesntStartSessionWithoutTransSID()
<ide> 'ini' => [
<ide> 'session.use_cookies' => 1,
<ide> 'session.use_trans_sid' => 0,
<del> ]
<add> ],
<ide> ]);
<ide>
<ide> $this->assertFalse($session->started());
<ide><path>tests/TestCase/I18n/DateTest.php
<ide> public function testTimeAgoInWordsTimezone($class)
<ide> [
<ide> 'timezone' => 'America/Vancouver',
<ide> 'end' => '+1month',
<del> 'format' => 'dd-MM-YYYY'
<add> 'format' => 'dd-MM-YYYY',
<ide> ]
<ide> );
<ide> $this->assertEquals('on 31-07-1990', $result);
<ide> public function timeAgoEndProvider()
<ide> [
<ide> '+4 months +2 weeks +3 days',
<ide> '4 months, 2 weeks, 3 days',
<del> '8 years'
<add> '8 years',
<ide> ],
<ide> [
<ide> '+4 months +2 weeks +1 day',
<ide> '4 months, 2 weeks, 1 day',
<del> '8 years'
<add> '8 years',
<ide> ],
<ide> [
<ide> '+3 months +2 weeks',
<ide> '3 months, 2 weeks',
<del> '8 years'
<add> '8 years',
<ide> ],
<ide> [
<ide> '+3 months +2 weeks +1 day',
<ide> '3 months, 2 weeks, 1 day',
<del> '8 years'
<add> '8 years',
<ide> ],
<ide> [
<ide> '+1 months +1 week +1 day',
<ide> '1 month, 1 week, 1 day',
<del> '8 years'
<add> '8 years',
<ide> ],
<ide> [
<ide> '+2 months +2 days',
<ide> '2 months, 2 days',
<del> '+2 months +2 days'
<add> '+2 months +2 days',
<ide> ],
<ide> [
<ide> '+2 months +12 days',
<ide> '2 months, 1 week, 5 days',
<del> '3 months'
<add> '3 months',
<ide> ],
<ide> ];
<ide> }
<ide> public function testTimeAgoInWordsCustomStrings($class)
<ide> $result = $date->timeAgoInWords([
<ide> 'relativeString' => 'at least %s ago',
<ide> 'accuracy' => ['year' => 'year'],
<del> 'end' => '+10 years'
<add> 'end' => '+10 years',
<ide> ]);
<ide> $expected = 'at least 8 years ago';
<ide> $this->assertEquals($expected, $result);
<ide> public function testTimeAgoInWordsCustomStrings($class)
<ide> $result = $date->timeAgoInWords([
<ide> 'absoluteString' => 'exactly on %s',
<ide> 'accuracy' => ['year' => 'year'],
<del> 'end' => '+2 months'
<add> 'end' => '+2 months',
<ide> ]);
<ide> $expected = 'exactly on ' . date('n/j/y', strtotime('+4 months +2 weeks +3 days'));
<ide> $this->assertEquals($expected, $result);
<ide> public function testDateAgoInWordsAccuracy($class)
<ide> $date = new $class('+8 years +4 months +2 weeks +3 days');
<ide> $result = $date->timeAgoInWords([
<ide> 'accuracy' => ['year' => 'year'],
<del> 'end' => '+10 years'
<add> 'end' => '+10 years',
<ide> ]);
<ide> $expected = '8 years';
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $date = new $class('+8 years +4 months +2 weeks +3 days');
<ide> $result = $date->timeAgoInWords([
<ide> 'accuracy' => ['year' => 'month'],
<del> 'end' => '+10 years'
<add> 'end' => '+10 years',
<ide> ]);
<ide> $expected = '8 years, 4 months';
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $date = new $class('+8 years +4 months +2 weeks +3 days');
<ide> $result = $date->timeAgoInWords([
<ide> 'accuracy' => ['year' => 'week'],
<del> 'end' => '+10 years'
<add> 'end' => '+10 years',
<ide> ]);
<ide> $expected = '8 years, 4 months, 2 weeks';
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $date = new $class('+8 years +4 months +2 weeks +3 days');
<ide> $result = $date->timeAgoInWords([
<ide> 'accuracy' => ['year' => 'day'],
<del> 'end' => '+10 years'
<add> 'end' => '+10 years',
<ide> ]);
<ide> $expected = '8 years, 4 months, 2 weeks, 3 days';
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $date = new $class('+1 years +5 weeks');
<ide> $result = $date->timeAgoInWords([
<ide> 'accuracy' => ['year' => 'year'],
<del> 'end' => '+10 years'
<add> 'end' => '+10 years',
<ide> ]);
<ide> $expected = '1 year';
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $date = new $class('+23 hours');
<ide> $result = $date->timeAgoInWords([
<del> 'accuracy' => 'day'
<add> 'accuracy' => 'day',
<ide> ]);
<ide> $expected = 'today';
<ide> $this->assertEquals($expected, $result);
<ide><path>tests/TestCase/I18n/I18nTest.php
<ide> public function testCreateCustomTranslationPackage()
<ide> I18n::setTranslator('custom', function () {
<ide> $package = new Package('default');
<ide> $package->setMessages([
<del> 'Cow' => 'Le moo'
<add> 'Cow' => 'Le moo',
<ide> ]);
<ide>
<ide> return $package;
<ide> public function testPluginMesagesLoad()
<ide> {
<ide> $this->loadPlugins([
<ide> 'TestPlugin',
<del> 'Company/TestPluginThree'
<add> 'Company/TestPluginThree',
<ide> ]);
<ide>
<ide> $translator = I18n::getTranslator('test_plugin');
<ide> public function testGetTranslatorByDefaultLocale()
<ide> I18n::setTranslator('custom', function () {
<ide> $package = new Package('default');
<ide> $package->setMessages([
<del> 'Cow' => 'Le moo'
<add> 'Cow' => 'Le moo',
<ide> ]);
<ide>
<ide> return $package;
<ide> public function testBasicDomainPluralFunction()
<ide> 'Cow' => 'Le Moo',
<ide> 'Cows' => [
<ide> 'Le Moo',
<del> 'Les Moos'
<add> 'Les Moos',
<ide> ],
<ide> '{0} years' => [
<ide> '',
<del> ''
<del> ]
<add> '',
<add> ],
<ide> ]);
<ide>
<ide> return $package;
<ide> public function testBasicContextFunction()
<ide> 'letter' => [
<ide> '_context' => [
<ide> 'character' => 'The letter {0}',
<del> 'communication' => 'She wrote a letter to {0}'
<del> ]
<add> 'communication' => 'She wrote a letter to {0}',
<add> ],
<ide> ],
<ide> 'letters' => [
<ide> '_context' => [
<ide> 'character' => [
<ide> 'The letter {0}',
<del> 'The letters {0} and {1}'
<add> 'The letters {0} and {1}',
<ide> ],
<ide> 'communication' => [
<ide> 'She wrote a letter to {0}',
<del> 'She wrote a letter to {0} and {1}'
<del> ]
<del> ]
<del> ]
<add> 'She wrote a letter to {0} and {1}',
<add> ],
<add> ],
<add> ],
<ide> ]);
<ide>
<ide> return $package;
<ide> public function testBasicContextFunctionNoString()
<ide> 'letter' => [
<ide> '_context' => [
<ide> 'character' => '',
<del> ]
<del> ]
<add> ],
<add> ],
<ide> ]);
<ide>
<ide> return $package;
<ide> public function testBasicContextFunctionInvalidContext()
<ide> 'letter' => [
<ide> '_context' => [
<ide> 'noun' => 'a paper letter',
<del> ]
<del> ]
<add> ],
<add> ],
<ide> ]);
<ide>
<ide> return $package;
<ide> public function testPluralContextFunction()
<ide> '_context' => [
<ide> 'character' => 'The letter {0}',
<ide> 'communication' => 'She wrote a letter to {0}',
<del> ]
<add> ],
<ide> ],
<ide> 'letters' => [
<ide> '_context' => [
<ide> 'character' => [
<ide> 'The letter {0}',
<del> 'The letters {0} and {1}'
<add> 'The letters {0} and {1}',
<ide> ],
<ide> 'communication' => [
<ide> 'She wrote a letter to {0}',
<del> 'She wrote a letter to {0} and {1}'
<del> ]
<del> ]
<del> ]
<add> 'She wrote a letter to {0} and {1}',
<add> ],
<add> ],
<add> ],
<ide> ]);
<ide>
<ide> return $package;
<ide> public function testDomainContextFunction()
<ide> 'letter' => [
<ide> '_context' => [
<ide> 'character' => 'The letter {0}',
<del> 'communication' => 'She wrote a letter to {0}'
<del> ]
<add> 'communication' => 'She wrote a letter to {0}',
<add> ],
<ide> ],
<ide> 'letters' => [
<ide> '_context' => [
<ide> 'character' => [
<ide> 'The letter {0}',
<del> 'The letters {0} and {1}'
<add> 'The letters {0} and {1}',
<ide> ],
<ide> 'communication' => [
<ide> 'She wrote a letter to {0}',
<del> 'She wrote a letter to {0} and {1}'
<del> ]
<del> ]
<del> ]
<add> 'She wrote a letter to {0} and {1}',
<add> ],
<add> ],
<add> ],
<ide> ]);
<ide>
<ide> return $package;
<ide> public function testDomainPluralContextFunction()
<ide> '_context' => [
<ide> 'character' => 'The letter {0}',
<ide> 'communication' => 'She wrote a letter to {0}',
<del> ]
<add> ],
<ide> ],
<ide> 'letters' => [
<ide> '_context' => [
<ide> 'character' => [
<ide> 'The letter {0}',
<del> 'The letters {0} and {1}'
<add> 'The letters {0} and {1}',
<ide> ],
<ide> 'communication' => [
<ide> 'She wrote a letter to {0}',
<del> 'She wrote a letter to {0} and {1}'
<del> ]
<del> ]
<del> ]
<add> 'She wrote a letter to {0} and {1}',
<add> ],
<add> ],
<add> ],
<ide> ]);
<ide>
<ide> return $package;
<ide> public function testLoaderFactory()
<ide> 'Cow' => 'Le Moo',
<ide> 'Cows' => [
<ide> 'Le Moo',
<del> 'Les Moos'
<del> ]
<add> 'Les Moos',
<add> ],
<ide> ]);
<ide> }
<ide>
<ide> public function testLoaderFactory()
<ide> 'Cow' => 'El Moo',
<ide> 'Cows' => [
<ide> 'El Moo',
<del> 'Los Moos'
<del> ]
<add> 'Los Moos',
<add> ],
<ide> ]);
<ide> }
<ide>
<ide> public function testFallbackTranslator()
<ide> I18n::setTranslator('default', function () {
<ide> $package = new Package('default');
<ide> $package->setMessages([
<del> 'Dog' => 'Le bark'
<add> 'Dog' => 'Le bark',
<ide> ]);
<ide>
<ide> return $package;
<ide> public function testFallbackTranslator()
<ide> I18n::setTranslator('custom', function () {
<ide> $package = new Package('default');
<ide> $package->setMessages([
<del> 'Cow' => 'Le moo'
<add> 'Cow' => 'Le moo',
<ide> ]);
<ide>
<ide> return $package;
<ide> public function testFallbackTranslatorWithFactory()
<ide> I18n::setTranslator('default', function () {
<ide> $package = new Package('default');
<ide> $package->setMessages([
<del> 'Dog' => 'Le bark'
<add> 'Dog' => 'Le bark',
<ide> ]);
<ide>
<ide> return $package;
<ide><path>tests/TestCase/I18n/NumberTest.php
<ide> public function testConfig()
<ide> $this->assertEquals('₹ 15,000.00', $result);
<ide>
<ide> Number::config('en_IN', \NumberFormatter::CURRENCY, [
<del> 'pattern' => '¤ #,##,##0'
<add> 'pattern' => '¤ #,##,##0',
<ide> ]);
<ide>
<ide> $result = $this->Number->currency(15000, 'INR', ['locale' => 'en_IN']);
<ide> public function testOrdinal()
<ide> $this->assertEquals('2nd', $result);
<ide>
<ide> $result = $this->Number->ordinal(2, [
<del> 'locale' => 'fr_FR'
<add> 'locale' => 'fr_FR',
<ide> ]);
<ide> $this->assertEquals('2e', $result);
<ide>
<ide><path>tests/TestCase/I18n/Parser/MoFileParserTest.php
<ide> public function testParse()
<ide> $expected = [
<ide> '%d = 1 (from core)' => [
<ide> '_context' => [
<del> '' => '%d = 1 (from core translated)'
<del> ]
<add> '' => '%d = 1 (from core translated)',
<add> ],
<ide> ],
<ide> '%d = 0 or > 1 (from core)' => [
<ide> '_context' => [
<ide> '' => [
<ide> '%d = 1 (from core translated)',
<del> '%d = 0 or > 1 (from core translated)'
<del> ]
<del> ]
<add> '%d = 0 or > 1 (from core translated)',
<add> ],
<add> ],
<ide> ],
<ide> 'Plural Rule 1 (from core)' => [
<ide> '_context' => [
<del> '' => 'Plural Rule 1 (from core translated)'
<del> ]
<del> ]
<add> '' => 'Plural Rule 1 (from core translated)',
<add> ],
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, $messages);
<ide> }
<ide> public function testParse0()
<ide> $expected = [
<ide> 'Plural Rule 1 (from core)' => [
<ide> '_context' => [
<del> '' => 'Plural Rule 0 (from core translated)'
<del> ]
<add> '' => 'Plural Rule 0 (from core translated)',
<add> ],
<ide> ],
<ide> '%d = 1 (from core)' => [
<ide> '_context' => [
<del> '' => '%d ends with any # (from core translated)'
<del> ]
<add> '' => '%d ends with any # (from core translated)',
<add> ],
<ide> ],
<ide> '%d = 0 or > 1 (from core)' => [
<ide> '_context' => [
<ide> '' => [
<ide> '%d ends with any # (from core translated)',
<del> ]
<del> ]
<add> ],
<add> ],
<ide> ],
<ide> ];
<ide> $this->assertEquals($expected, $messages);
<ide> public function testParse2()
<ide> $expected = [
<ide> '%d = 1 (from core)' => [
<ide> '_context' => [
<del> '' => '%d is 1 (from core translated)'
<del> ]
<add> '' => '%d is 1 (from core translated)',
<add> ],
<ide> ],
<ide> '%d = 0 or > 1 (from core)' => [
<ide> '_context' => [
<ide> '' => [
<ide> '%d is 1 (from core translated)',
<ide> '%d ends in 2-4, not 12-14 (from core translated)',
<del> '%d everything else (from core translated)'
<del> ]
<del> ]
<add> '%d everything else (from core translated)',
<add> ],
<add> ],
<ide> ],
<ide> 'Plural Rule 1 (from core)' => [
<ide> '_context' => [
<del> '' => 'Plural Rule 9 (from core translated)'
<del> ]
<del> ]
<add> '' => 'Plural Rule 9 (from core translated)',
<add> ],
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, $messages);
<ide> }
<ide> public function testParseFull()
<ide> $expected = [
<ide> 'Plural Rule 1' => [
<ide> '_context' => [
<del> '' => 'Plural Rule 1 (translated)'
<del> ]
<add> '' => 'Plural Rule 1 (translated)',
<add> ],
<ide> ],
<ide> '%d = 1' => [
<ide> '_context' => [
<ide> 'This is the context' => 'First Context trasnlation',
<del> 'Another Context' => '%d = 1 (translated)'
<del> ]
<add> 'Another Context' => '%d = 1 (translated)',
<add> ],
<ide> ],
<ide> '%d = 0 or > 1' => [
<ide> '_context' => [
<ide> 'Another Context' => [
<ide> 0 => '%d = 1 (translated)',
<del> 1 => '%d = 0 or > 1 (translated)'
<del> ]
<del> ]
<add> 1 => '%d = 0 or > 1 (translated)',
<add> ],
<add> ],
<ide> ],
<ide> '%-5d = 1' => [
<ide> '_context' => [
<del> '' => '%-5d = 1 (translated)'
<del> ]
<add> '' => '%-5d = 1 (translated)',
<add> ],
<ide> ],
<ide> '%-5d = 0 or > 1' => [
<ide> '_context' => [
<ide> '' => [
<ide> '%-5d = 1 (translated)',
<del> '%-5d = 0 or > 1 (translated)'
<del> ]
<del> ]
<del> ]
<add> '%-5d = 0 or > 1 (translated)',
<add> ],
<add> ],
<add> ],
<ide> ];
<ide> $this->assertEquals($expected, $messages);
<ide> }
<ide><path>tests/TestCase/I18n/Parser/PoFileParserTest.php
<ide> public function testParse()
<ide> $expected = [
<ide> 'Plural Rule 1' => [
<ide> '_context' => [
<del> '' => 'Plural Rule 1 (translated)'
<del> ]
<add> '' => 'Plural Rule 1 (translated)',
<add> ],
<ide> ],
<ide> '%d = 1' => [
<ide> '_context' => [
<ide> 'This is the context' => 'First Context translation',
<del> 'Another Context' => '%d = 1 (translated)'
<del> ]
<add> 'Another Context' => '%d = 1 (translated)',
<add> ],
<ide> ],
<ide> 'p:%d = 0 or > 1' => [
<ide> '_context' => [
<ide> 'Another Context' => [
<ide> 0 => '%d = 1 (translated)',
<del> 1 => '%d = 0 or > 1 (translated)'
<del> ]
<del> ]
<add> 1 => '%d = 0 or > 1 (translated)',
<add> ],
<add> ],
<ide> ],
<ide> '%-5d = 1' => [
<ide> '_context' => [
<del> '' => '%-5d = 1 (translated)'
<del> ]
<add> '' => '%-5d = 1 (translated)',
<add> ],
<ide> ],
<ide> 'p:%-5d = 0 or > 1' => [
<ide> '_context' => [
<ide> public function testParse()
<ide> 1 => '',
<ide> 2 => '',
<ide> 3 => '',
<del> 4 => '%-5d = 0 or > 1 (translated)'
<del> ]
<del> ]
<add> 4 => '%-5d = 0 or > 1 (translated)',
<add> ],
<add> ],
<ide> ],
<ide> '%d = 2' => [
<ide> '_context' => [
<ide> 'This is another translated context' => 'First Context translation',
<del> ]
<add> ],
<ide> ],
<ide> '%-6d = 3' => [
<ide> '_context' => [
<ide> '' => '%-6d = 1 (translated)',
<del> ]
<add> ],
<ide> ],
<ide> 'p:%-6d = 0 or > 1' => [
<ide> '_context' => [
<ide> public function testParse()
<ide> 2 => '',
<ide> 3 => '',
<ide> 4 => '%-6d = 0 or > 1 (translated)',
<del> ]
<del> ]
<add> ],
<add> ],
<ide> ],
<ide> ];
<ide> $this->assertEquals($expected, $messages); | 300 |
Java | Java | introduce support for sorted properties | c39c4211df15500996142a265d7afcc31c23c6f8 | <ide><path>spring-core/src/main/java/org/springframework/core/CollectionFactory.java
<ide> public String getProperty(String key) {
<ide> };
<ide> }
<ide>
<add> /**
<add> * Create a variant of {@link java.util.Properties} that sorts properties
<add> * alphanumerically based on their keys.
<add> *
<add> * <p>This can be useful when storing the {@link Properties} instance in a
<add> * properties file, since it allows such files to be generated in a repeatable
<add> * manner with consistent ordering of properties. Comments in generated
<add> * properties files can also be optionally omitted.
<add> *
<add> * @param omitComments {@code true} if comments should be omitted when
<add> * storing properties in a file
<add> * @return a new {@code Properties} instance
<add> * @since 5.2
<add> * @see #createSortedProperties(Properties, boolean)
<add> */
<add> public static Properties createSortedProperties(boolean omitComments) {
<add> return new SortedProperties(omitComments);
<add> }
<add>
<add> /**
<add> * Create a variant of {@link java.util.Properties} that sorts properties
<add> * alphanumerically based on their keys.
<add> *
<add> * <p>This can be useful when storing the {@code Properties} instance in a
<add> * properties file, since it allows such files to be generated in a repeatable
<add> * manner with consistent ordering of properties. Comments in generated
<add> * properties files can also be optionally omitted.
<add> *
<add> * <p>The returned {@code Properties} instance will be populated with
<add> * properties from the supplied {@code properties} object, but default
<add> * properties from the supplied {@code properties} object will not be copied.
<add> *
<add> * @param properties the {@code Properties} object from which to copy the
<add> * initial properties
<add> * @param omitComments {@code true} if comments should be omitted when
<add> * storing properties in a file
<add> * @return a new {@code Properties} instance
<add> * @since 5.2
<add> * @see #createSortedProperties(boolean)
<add> */
<add> public static Properties createSortedProperties(Properties properties, boolean omitComments) {
<add> return new SortedProperties(properties, omitComments);
<add> }
<add>
<ide> /**
<ide> * Cast the given type to a subtype of {@link Enum}.
<ide> * @param enumType the enum type, never {@code null}
<ide><path>spring-core/src/main/java/org/springframework/core/SortedProperties.java
<add>/*
<add> * Copyright 2002-2019 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * https://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<add>package org.springframework.core;
<add>
<add>import java.io.ByteArrayOutputStream;
<add>import java.io.IOException;
<add>import java.io.OutputStream;
<add>import java.io.StringWriter;
<add>import java.io.Writer;
<add>import java.nio.charset.StandardCharsets;
<add>import java.util.Collections;
<add>import java.util.Comparator;
<add>import java.util.Enumeration;
<add>import java.util.Map.Entry;
<add>import java.util.Properties;
<add>import java.util.Set;
<add>import java.util.TreeSet;
<add>
<add>import org.springframework.util.StringUtils;
<add>
<add>/**
<add> * Specialization of {@link Properties} that sorts properties alphanumerically
<add> * based on their keys.
<add> *
<add> * <p>This can be useful when storing the {@link Properties} instance in a
<add> * properties file, since it allows such files to be generated in a repeatable
<add> * manner with consistent ordering of properties.
<add> *
<add> * <p>Comments in generated properties files can also be optionally omitted.
<add> *
<add> * @author Sam Brannen
<add> * @since 5.2
<add> * @see java.util.Properties
<add> */
<add>@SuppressWarnings("serial")
<add>class SortedProperties extends Properties {
<add>
<add> static final String EOL = System.getProperty("line.separator");
<add>
<add> private static final Comparator<Object> keyComparator = //
<add> (key1, key2) -> String.valueOf(key1).compareTo(String.valueOf(key2));
<add>
<add> private static final Comparator<Entry<Object, Object>> entryComparator = //
<add> Entry.comparingByKey(keyComparator);
<add>
<add> private final boolean omitComments;
<add>
<add>
<add> /**
<add> * Construct a new {@code SortedProperties} instance that honors the supplied
<add> * {@code omitComments} flag.
<add> *
<add> * @param omitComments {@code true} if comments should be omitted when
<add> * storing properties in a file
<add> */
<add> SortedProperties(boolean omitComments) {
<add> this.omitComments = omitComments;
<add> }
<add>
<add> /**
<add> * Construct a new {@code SortedProperties} instance with properties populated
<add> * from the supplied {@link Properties} object and honoring the supplied
<add> * {@code omitComments} flag.
<add> *
<add> * <p>Default properties from the supplied {@code Properties} object will
<add> * not be copied.
<add> *
<add> * @param properties the {@code Properties} object from which to copy the
<add> * initial properties
<add> * @param omitComments {@code true} if comments should be omitted when
<add> * storing properties in a file
<add> */
<add> SortedProperties(Properties properties, boolean omitComments) {
<add> this(omitComments);
<add> putAll(properties);
<add> }
<add>
<add> @Override
<add> public void store(OutputStream out, String comments) throws IOException {
<add> ByteArrayOutputStream baos = new ByteArrayOutputStream();
<add> super.store(baos, (this.omitComments ? null : comments));
<add> String contents = new String(baos.toByteArray(), StandardCharsets.ISO_8859_1);
<add> for (String line : StringUtils.tokenizeToStringArray(contents, EOL)) {
<add> if (!this.omitComments || !line.startsWith("#")) {
<add> out.write((line + EOL).getBytes(StandardCharsets.ISO_8859_1));
<add> }
<add> }
<add> }
<add>
<add> @Override
<add> public void store(Writer writer, String comments) throws IOException {
<add> StringWriter stringWriter = new StringWriter();
<add> super.store(stringWriter, (this.omitComments ? null : comments));
<add> String contents = stringWriter.toString();
<add> for (String line : StringUtils.tokenizeToStringArray(contents, EOL)) {
<add> if (!this.omitComments || !line.startsWith("#")) {
<add> writer.write(line + EOL);
<add> }
<add> }
<add> }
<add>
<add> @Override
<add> public void storeToXML(OutputStream out, String comments) throws IOException {
<add> super.storeToXML(out, (this.omitComments ? null : comments));
<add> }
<add>
<add> @Override
<add> public void storeToXML(OutputStream out, String comments, String encoding) throws IOException {
<add> super.storeToXML(out, (this.omitComments ? null : comments), encoding);
<add> }
<add>
<add> /**
<add> * Return a sorted enumeration of the keys in this {@link Properties} object.
<add> * @see #keySet()
<add> */
<add> @Override
<add> public synchronized Enumeration<Object> keys() {
<add> return Collections.enumeration(keySet());
<add> }
<add>
<add> /**
<add> * Return a sorted set of the keys in this {@link Properties} object.
<add> * <p>The keys will be converted to strings if necessary using
<add> * {@link String#valueOf(Object)} and sorted alphanumerically according to
<add> * the natural order of strings.
<add> */
<add> @Override
<add> public Set<Object> keySet() {
<add> Set<Object> sortedKeys = new TreeSet<>(keyComparator);
<add> sortedKeys.addAll(super.keySet());
<add> return Collections.synchronizedSet(sortedKeys);
<add> }
<add>
<add> /**
<add> * Return a sorted set of the entries in this {@link Properties} object.
<add> * <p>The entries will be sorted based on their keys, and the keys will be
<add> * converted to strings if necessary using {@link String#valueOf(Object)}
<add> * and compared alphanumerically according to the natural order of strings.
<add> */
<add> @Override
<add> public Set<Entry<Object, Object>> entrySet() {
<add> Set<Entry<Object, Object>> sortedEntries = new TreeSet<>(entryComparator);
<add> sortedEntries.addAll(super.entrySet());
<add> return Collections.synchronizedSet(sortedEntries);
<add> }
<add>
<add>}
<ide><path>spring-core/src/test/java/org/springframework/core/SortedPropertiesTests.java
<add>/*
<add> * Copyright 2002-2019 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * https://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<add>package org.springframework.core;
<add>
<add>import java.io.ByteArrayOutputStream;
<add>import java.io.IOException;
<add>import java.io.StringWriter;
<add>import java.nio.charset.StandardCharsets;
<add>import java.util.Collections;
<add>import java.util.Properties;
<add>
<add>import org.junit.Test;
<add>
<add>import static java.util.Arrays.stream;
<add>import static org.assertj.core.api.Assertions.assertThat;
<add>import static org.assertj.core.api.Assertions.entry;
<add>
<add>/**
<add> * Unit tests for {@link SortedProperties}.
<add> *
<add> * @author Sam Brannen
<add> * @since 5.2
<add> */
<add>public class SortedPropertiesTests {
<add>
<add> @Test
<add> public void keys() {
<add> assertKeys(createSortedProps());
<add> }
<add>
<add> @Test
<add> public void keysFromPrototype() {
<add> assertKeys(createSortedPropsFromPrototype());
<add> }
<add>
<add> @Test
<add> public void keySet() {
<add> assertKeySet(createSortedProps());
<add> }
<add>
<add> @Test
<add> public void keySetFromPrototype() {
<add> assertKeySet(createSortedPropsFromPrototype());
<add> }
<add>
<add> @Test
<add> public void entrySet() {
<add> assertEntrySet(createSortedProps());
<add> }
<add>
<add> @Test
<add> public void entrySetFromPrototype() {
<add> assertEntrySet(createSortedPropsFromPrototype());
<add> }
<add>
<add> @Test
<add> public void sortsPropertiesUsingOutputStream() throws IOException {
<add> SortedProperties sortedProperties = createSortedProps();
<add>
<add> ByteArrayOutputStream baos = new ByteArrayOutputStream();
<add> sortedProperties.store(baos, "custom comment");
<add>
<add> String[] lines = lines(baos);
<add> assertThat(lines).hasSize(7);
<add> assertThat(lines[0]).isEqualTo("#custom comment");
<add> assertThat(lines[1]).as("timestamp").startsWith("#");
<add>
<add> assertPropsAreSorted(lines);
<add> }
<add>
<add> @Test
<add> public void sortsPropertiesUsingWriter() throws IOException {
<add> SortedProperties sortedProperties = createSortedProps();
<add>
<add> StringWriter writer = new StringWriter();
<add> sortedProperties.store(writer, "custom comment");
<add>
<add> String[] lines = lines(writer);
<add> assertThat(lines).hasSize(7);
<add> assertThat(lines[0]).isEqualTo("#custom comment");
<add> assertThat(lines[1]).as("timestamp").startsWith("#");
<add>
<add> assertPropsAreSorted(lines);
<add> }
<add>
<add> @Test
<add> public void sortsPropertiesAndOmitsCommentsUsingOutputStream() throws IOException {
<add> SortedProperties sortedProperties = createSortedProps(true);
<add>
<add> ByteArrayOutputStream baos = new ByteArrayOutputStream();
<add> sortedProperties.store(baos, "custom comment");
<add>
<add> String[] lines = lines(baos);
<add> assertThat(lines).hasSize(5);
<add>
<add> assertPropsAreSorted(lines);
<add> }
<add>
<add> @Test
<add> public void sortsPropertiesAndOmitsCommentsUsingWriter() throws IOException {
<add> SortedProperties sortedProperties = createSortedProps(true);
<add>
<add> StringWriter writer = new StringWriter();
<add> sortedProperties.store(writer, "custom comment");
<add>
<add> String[] lines = lines(writer);
<add> assertThat(lines).hasSize(5);
<add>
<add> assertPropsAreSorted(lines);
<add> }
<add>
<add> @Test
<add> public void storingAsXmlSortsPropertiesAndOmitsComments() throws IOException {
<add> SortedProperties sortedProperties = createSortedProps(true);
<add>
<add> ByteArrayOutputStream baos = new ByteArrayOutputStream();
<add> sortedProperties.storeToXML(baos, "custom comment");
<add>
<add> String[] lines = lines(baos);
<add>
<add> assertThat(lines).containsExactly( //
<add> "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>", //
<add> "<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\">", //
<add> "<properties>", //
<add> "<entry key=\"color\">blue</entry>", //
<add> "<entry key=\"fragrance\">sweet</entry>", //
<add> "<entry key=\"fruit\">apple</entry>", //
<add> "<entry key=\"size\">medium</entry>", //
<add> "<entry key=\"vehicle\">car</entry>", //
<add> "</properties>" //
<add> );
<add> }
<add>
<add> private SortedProperties createSortedProps() {
<add> return createSortedProps(false);
<add> }
<add>
<add> private SortedProperties createSortedProps(boolean omitComments) {
<add> SortedProperties sortedProperties = new SortedProperties(omitComments);
<add> populateProperties(sortedProperties);
<add> return sortedProperties;
<add> }
<add>
<add> private SortedProperties createSortedPropsFromPrototype() {
<add> Properties properties = new Properties();
<add> populateProperties(properties);
<add> return new SortedProperties(properties, false);
<add> }
<add>
<add> private void populateProperties(Properties properties) {
<add> properties.setProperty("color", "blue");
<add> properties.setProperty("fragrance", "sweet");
<add> properties.setProperty("fruit", "apple");
<add> properties.setProperty("size", "medium");
<add> properties.setProperty("vehicle", "car");
<add> }
<add>
<add> private String[] lines(ByteArrayOutputStream baos) {
<add> return lines(new String(baos.toByteArray(), StandardCharsets.ISO_8859_1));
<add> }
<add>
<add> private String[] lines(StringWriter writer) {
<add> return lines(writer.toString());
<add> }
<add>
<add> private String[] lines(String input) {
<add> return input.trim().split(SortedProperties.EOL);
<add> }
<add>
<add> private void assertKeys(Properties properties) {
<add> assertThat(Collections.list(properties.keys())) //
<add> .containsExactly("color", "fragrance", "fruit", "size", "vehicle");
<add> }
<add>
<add> private void assertKeySet(Properties properties) {
<add> assertThat(properties.keySet()).containsExactly("color", "fragrance", "fruit", "size", "vehicle");
<add> }
<add>
<add> private void assertEntrySet(Properties properties) {
<add> assertThat(properties.entrySet()).containsExactly( //
<add> entry("color", "blue"), //
<add> entry("fragrance", "sweet"), //
<add> entry("fruit", "apple"), //
<add> entry("size", "medium"), //
<add> entry("vehicle", "car") //
<add> );
<add> }
<add>
<add> private void assertPropsAreSorted(String[] lines) {
<add> assertThat(stream(lines).filter(s -> !s.startsWith("#"))).containsExactly( //
<add> "color=blue", //
<add> "fragrance=sweet", //
<add> "fruit=apple", //
<add> "size=medium", //
<add> "vehicle=car"//
<add> );
<add> }
<add>
<add>} | 3 |
Ruby | Ruby | simplify re-definition of `targets` | fa635db8a1bd7494c355416421d52f87cdd0491c | <ide><path>Library/Homebrew/formula.rb
<ide> def time
<ide> # universal binaries in a {Formula}'s {Keg}.
<ide> sig { params(targets: T.nilable(T.any(Pathname, String))).void }
<ide> def deuniversalize_machos(*targets)
<del> if targets.blank?
<del> targets = any_installed_keg.mach_o_files.select do |file|
<del> file.arch == :universal && file.archs.include?(Hardware::CPU.arch)
<del> end
<add> targets ||= any_installed_keg.mach_o_files.select do |file|
<add> file.arch == :universal && file.archs.include?(Hardware::CPU.arch)
<ide> end
<ide>
<ide> targets.each { |t| extract_macho_slice_from(Pathname.new(t), Hardware::CPU.arch) } | 1 |
PHP | PHP | allow port on remote host | 3f7c47cb243be3ba201bf75c6c0c38e7b96b43b3 | <ide><path>src/Illuminate/Remote/SecLibGateway.php
<ide> class SecLibGateway implements GatewayInterface {
<ide> */
<ide> protected $host;
<ide>
<add> /**
<add> * The SSH port on the server.
<add> *
<add> * @var int
<add> */
<add> protected $port = 22;
<add>
<ide> /**
<ide> * The authentication credential set.
<ide> *
<ide> class SecLibGateway implements GatewayInterface {
<ide> */
<ide> public function __construct($host, array $auth, Filesystem $files)
<ide> {
<del> $this->host = $host;
<ide> $this->auth = $auth;
<ide> $this->files = $files;
<del> $this->connection = new Net_SFTP($this->host);
<add> $this->setHostAndPort($host);
<add>
<add> $this->connection = new Net_SFTP($this->host, $this->port);
<add> }
<add>
<add> /**
<add> * Set the host and port from a full host string.
<add> *
<add> * @param string $host
<add> * @return void
<add> */
<add> protected function setHostAndPort($host)
<add> {
<add> if ( ! str_contains($host, ':'))
<add> {
<add> $this->host = $host;
<add> }
<add> else
<add> {
<add> list($this->host, $this->post) = explode($host, ':');
<add>
<add> $this->port = (int) $this->port;
<add> }
<ide> }
<ide>
<ide> /** | 1 |
Python | Python | fix progress bar | edfea3a513349ca575d77c62ab1b708030542823 | <ide><path>spacy/train.py
<ide> def _epoch(indices):
<ide> golds = self.make_golds(docs, paragraph_tuples)
<ide> all_docs.extend(docs)
<ide> all_golds.extend(golds)
<del> for batch in tqdm.tqdm(partition_all(12, zip(all_docs, all_golds))):
<add> for batch in partition_all(12, zip(tqdm.tqdm(all_docs), all_golds)):
<ide> X, y = zip(*batch)
<ide> yield X, y
<ide> | 1 |
Ruby | Ruby | remove unused code | 4abb8c9d5bccca0e3c092031d87d000a21f57723 | <ide><path>actionpack/lib/action_controller/test_case.rb
<ide> def process(action, *args)
<ide> end
<ide> @response.prepare!
<ide>
<del> @assigns = @controller.respond_to?(:view_assigns) ? @controller.view_assigns : {}
<del>
<ide> if flash_value = @request.flash.to_session_value
<ide> @request.session['flash'] = flash_value
<ide> else | 1 |
Ruby | Ruby | make flag lists into constants | a458555ccb5d4d34befabde63eddacdd7a4613a8 | <ide><path>Library/Homebrew/extend/ENV.rb
<ide> require 'hardware'
<ide>
<ide> module HomebrewEnvExtension
<del> # -w: keep signal to noise high
<ide> SAFE_CFLAGS_FLAGS = "-w -pipe"
<add> CC_FLAG_VARS = %w{CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS}
<add> FC_FLAG_VARS = %w{FCFLAGS FFLAGS}
<add> DEFAULT_FLAGS = '-march=core2 -msse4'
<ide>
<ide> def setup_build_environment
<ide> # Clear CDPATH to avoid make issues that depend on changing directories
<ide> def universal_binary
<ide> end
<ide>
<ide> def replace_in_cflags before, after
<del> cc_flag_vars.each do |key|
<add> CC_FLAG_VARS.each do |key|
<ide> self[key] = self[key].sub before, after if self[key]
<ide> end
<ide> end
<ide>
<ide> # Convenience method to set all C compiler flags in one shot.
<ide> def set_cflags f
<del> cc_flag_vars.each do |key|
<add> CC_FLAG_VARS.each do |key|
<ide> self[key] = f
<ide> end
<ide> end
<ide>
<ide> # Sets architecture-specific flags for every environment variable
<ide> # given in the list `flags`.
<del> def set_cpu_flags flags, default='-march=core2 -msse4', map=Hardware::CPU.optimization_flags
<add> def set_cpu_flags flags, default=DEFAULT_FLAGS, map=Hardware::CPU.optimization_flags
<ide> cflags =~ %r{(-Xarch_i386 )-march=}
<ide> xarch = $1.to_s
<ide> remove flags, %r{(-Xarch_i386 )?-march=\S*}
<ide> def set_cpu_flags flags, default='-march=core2 -msse4', map=Hardware::CPU.optimi
<ide> remove flags, '-Qunused-arguments'
<ide> end
<ide>
<del> def set_cpu_cflags default='-march=core2 -msse4', map=Hardware::CPU.optimization_flags
<del> set_cpu_flags cc_flag_vars, default, map
<add> def set_cpu_cflags default=DEFAULT_FLAGS, map=Hardware::CPU.optimization_flags
<add> set_cpu_flags CC_FLAG_VARS, default, map
<ide> end
<ide>
<ide> # actually c-compiler, so cc would be a better name
<ide> def remove_cc_etc
<ide> end
<ide> removed
<ide> end
<del> def cc_flag_vars
<del> %w{CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS}
<del> end
<ide> def append_to_cflags newflags
<del> append(cc_flag_vars, newflags)
<add> append(CC_FLAG_VARS, newflags)
<ide> end
<ide> def remove_from_cflags f
<del> remove cc_flag_vars, f
<add> remove CC_FLAG_VARS, f
<ide> end
<ide> def append keys, value, separator = ' '
<ide> value = value.to_s
<ide> def with_build_environment
<ide> end
<ide>
<ide> def fortran
<del> fc_flag_vars = %w{FCFLAGS FFLAGS}
<del>
<ide> # superenv removes these PATHs, but this option needs them
<ide> # TODO fix better, probably by making a super-fc
<ide> ENV['PATH'] += ":#{HOMEBREW_PREFIX}/bin:/usr/local/bin"
<ide> def fortran
<ide> self['FC'] = which 'gfortran'
<ide> self['F77'] = self['FC']
<ide>
<del> fc_flag_vars.each {|key| self[key] = cflags}
<del> set_cpu_flags(fc_flag_vars)
<add> FC_FLAG_VARS.each {|key| self[key] = cflags}
<add> set_cpu_flags(FC_FLAG_VARS)
<ide> else
<ide> onoe <<-EOS
<ide> This formula requires a fortran compiler, but we could not find one by | 1 |
Text | Text | use the reduce method to analyze data | a489ac9df8e569354f33b7564380f28bb4d98be8 | <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-reduce-method-to-analyze-data.english.md
<ide> However, before we get there, let's practice using <code>reduce</code> first.
<ide>
<ide> ## Instructions
<ide> <section id='instructions'>
<del>The variable <code>watchList</code> holds an array of objects with information on several movies. Use <code>reduce</code> to find the average IMDB rating of the movies <strong>directed by Christopher Nolan</strong>. Recall from prior challenges how to <code>filter</code> data and <code>map</code> over it to pull what you need. You may need to create other variables, but save the final average into the variable <code>averageRating</code>. Note that the rating values are saved as strings in the object and need to be converted into numbers before they are used in any mathematical operations.
<add>The variable <code>watchList</code> holds an array of objects with information on several movies. Use <code>reduce</code> to find the average IMDB rating of the movies <strong>directed by Christopher Nolan</strong>. Recall from prior challenges how to <code>filter</code> data and <code>map</code> over it to pull what you need. You may need to create other variables, and return the average rating from <code>getRating</code> function. Note that the rating values are saved as strings in the object and need to be converted into numbers before they are used in any mathematical operations.
<ide> </section>
<ide>
<ide> ## Tests
<ide> tests:
<ide> testString: assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron", 'The <code>watchList</code> variable should not change.');
<ide> - text: Your code should use the <code>reduce</code> method.
<ide> testString: assert(code.match(/\.reduce/g), 'Your code should use the <code>reduce</code> method.');
<del> - text: The <code>averageRating</code> should equal 8.675.
<del> testString: assert(averageRating == 8.675, 'The <code>averageRating</code> should equal 8.675.');
<add> - text: The <code>getRating(watchList)</code> should equal 8.675.
<add> testString: assert(getRating(watchList) === 8.675, 'The <code>getRating(watchList)</code> should equal 8.675.');
<ide> - text: Your code should not use a <code>for</code> loop.
<ide> testString: assert(!code.match(/for\s*?\(.*\)/g), 'Your code should not use a <code>for</code> loop.');
<add> - text: Your code should return correct output after modifying the <code>watchList</code> object.
<add> testString: assert(getRating(watchList.filter((_, i) => i < 1 || i > 2)) === 8.55, 'Your code should return correct output after modifying the <code>watchList</code> object');
<ide>
<ide> ```
<ide>
<ide> var watchList = [
<ide> }
<ide> ];
<ide>
<del>// Add your code below this line
<add>function getRating(watchList){
<add> // Add your code below this line
<add> var averageRating;
<ide>
<del>var averageRating;
<ide>
<del>// Add your code above this line
<del>
<del>console.log(averageRating);
<add> // Add your code above this line
<add> return averageRating;
<add>}
<add>console.log(getRating(watchList));
<ide> ```
<ide>
<ide> </div>
<ide> console.log(averageRating);
<ide> <section id='solution'>
<ide>
<ide> ```js
<del>// solution required
<add>// the global variable
<add>var watchList = [
<add> {
<add> "Title": "Inception",
<add> "Year": "2010",
<add> "Rated": "PG-13",
<add> "Released": "16 Jul 2010",
<add> "Runtime": "148 min",
<add> "Genre": "Action, Adventure, Crime",
<add> "Director": "Christopher Nolan",
<add> "Writer": "Christopher Nolan",
<add> "Actors": "Leonardo DiCaprio, Joseph Gordon-Levitt, Ellen Page, Tom Hardy",
<add> "Plot": "A thief, who steals corporate secrets through use of dream-sharing technology, is given the inverse task of planting an idea into the mind of a CEO.",
<add> "Language": "English, Japanese, French",
<add> "Country": "USA, UK",
<add> "Awards": "Won 4 Oscars. Another 143 wins & 198 nominations.",
<add> "Poster": "http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1_SX300.jpg",
<add> "Metascore": "74",
<add> "imdbRating": "8.8",
<add> "imdbVotes": "1,446,708",
<add> "imdbID": "tt1375666",
<add> "Type": "movie",
<add> "Response": "True"
<add> },
<add> {
<add> "Title": "Interstellar",
<add> "Year": "2014",
<add> "Rated": "PG-13",
<add> "Released": "07 Nov 2014",
<add> "Runtime": "169 min",
<add> "Genre": "Adventure, Drama, Sci-Fi",
<add> "Director": "Christopher Nolan",
<add> "Writer": "Jonathan Nolan, Christopher Nolan",
<add> "Actors": "Ellen Burstyn, Matthew McConaughey, Mackenzie Foy, John Lithgow",
<add> "Plot": "A team of explorers travel through a wormhole in space in an attempt to ensure humanity's survival.",
<add> "Language": "English",
<add> "Country": "USA, UK",
<add> "Awards": "Won 1 Oscar. Another 39 wins & 132 nominations.",
<add> "Poster": "http://ia.media-imdb.com/images/M/MV5BMjIxNTU4MzY4MF5BMl5BanBnXkFtZTgwMzM4ODI3MjE@._V1_SX300.jpg",
<add> "Metascore": "74",
<add> "imdbRating": "8.6",
<add> "imdbVotes": "910,366",
<add> "imdbID": "tt0816692",
<add> "Type": "movie",
<add> "Response": "True"
<add> },
<add> {
<add> "Title": "The Dark Knight",
<add> "Year": "2008",
<add> "Rated": "PG-13",
<add> "Released": "18 Jul 2008",
<add> "Runtime": "152 min",
<add> "Genre": "Action, Adventure, Crime",
<add> "Director": "Christopher Nolan",
<add> "Writer": "Jonathan Nolan (screenplay), Christopher Nolan (screenplay), Christopher Nolan (story), David S. Goyer (story), Bob Kane (characters)",
<add> "Actors": "Christian Bale, Heath Ledger, Aaron Eckhart, Michael Caine",
<add> "Plot": "When the menace known as the Joker wreaks havoc and chaos on the people of Gotham, the caped crusader must come to terms with one of the greatest psychological tests of his ability to fight injustice.",
<add> "Language": "English, Mandarin",
<add> "Country": "USA, UK",
<add> "Awards": "Won 2 Oscars. Another 146 wins & 142 nominations.",
<add> "Poster": "http://ia.media-imdb.com/images/M/MV5BMTMxNTMwODM0NF5BMl5BanBnXkFtZTcwODAyMTk2Mw@@._V1_SX300.jpg",
<add> "Metascore": "82",
<add> "imdbRating": "9.0",
<add> "imdbVotes": "1,652,832",
<add> "imdbID": "tt0468569",
<add> "Type": "movie",
<add> "Response": "True"
<add> },
<add> {
<add> "Title": "Batman Begins",
<add> "Year": "2005",
<add> "Rated": "PG-13",
<add> "Released": "15 Jun 2005",
<add> "Runtime": "140 min",
<add> "Genre": "Action, Adventure",
<add> "Director": "Christopher Nolan",
<add> "Writer": "Bob Kane (characters), David S. Goyer (story), Christopher Nolan (screenplay), David S. Goyer (screenplay)",
<add> "Actors": "Christian Bale, Michael Caine, Liam Neeson, Katie Holmes",
<add> "Plot": "After training with his mentor, Batman begins his fight to free crime-ridden Gotham City from the corruption that Scarecrow and the League of Shadows have cast upon it.",
<add> "Language": "English, Urdu, Mandarin",
<add> "Country": "USA, UK",
<add> "Awards": "Nominated for 1 Oscar. Another 15 wins & 66 nominations.",
<add> "Poster": "http://ia.media-imdb.com/images/M/MV5BNTM3OTc0MzM2OV5BMl5BanBnXkFtZTYwNzUwMTI3._V1_SX300.jpg",
<add> "Metascore": "70",
<add> "imdbRating": "8.3",
<add> "imdbVotes": "972,584",
<add> "imdbID": "tt0372784",
<add> "Type": "movie",
<add> "Response": "True"
<add> },
<add> {
<add> "Title": "Avatar",
<add> "Year": "2009",
<add> "Rated": "PG-13",
<add> "Released": "18 Dec 2009",
<add> "Runtime": "162 min",
<add> "Genre": "Action, Adventure, Fantasy",
<add> "Director": "James Cameron",
<add> "Writer": "James Cameron",
<add> "Actors": "Sam Worthington, Zoe Saldana, Sigourney Weaver, Stephen Lang",
<add> "Plot": "A paraplegic marine dispatched to the moon Pandora on a unique mission becomes torn between following his orders and protecting the world he feels is his home.",
<add> "Language": "English, Spanish",
<add> "Country": "USA, UK",
<add> "Awards": "Won 3 Oscars. Another 80 wins & 121 nominations.",
<add> "Poster": "http://ia.media-imdb.com/images/M/MV5BMTYwOTEwNjAzMl5BMl5BanBnXkFtZTcwODc5MTUwMw@@._V1_SX300.jpg",
<add> "Metascore": "83",
<add> "imdbRating": "7.9",
<add> "imdbVotes": "876,575",
<add> "imdbID": "tt0499549",
<add> "Type": "movie",
<add> "Response": "True"
<add> }
<add>];
<add>
<add>function getRating(watchList){
<add> var averageRating;
<add> const rating = watchList
<add> .filter(obj => obj.Director === "Christopher Nolan")
<add> .map(obj => Number(obj.imdbRating));
<add> averageRating = rating.reduce((accum, curr) => accum + curr)/rating.length;
<add> return averageRating;
<add>}
<add>
<ide> ```
<ide> </section> | 1 |
Javascript | Javascript | add mimetype type to source object when possible | 62ff3f66a50c0a908188de9c140011e7c5fd44dc | <ide><path>src/js/utils/filter-source.js
<ide> * @module filter-source
<ide> */
<ide> import {isObject} from './obj';
<add>import {MimetypesKind} from './mimetypes';
<add>import * as Url from '../utils/url.js';
<ide>
<ide> /**
<ide> * Filter out single bad source objects or multiple source objects in an
<ide> const filterSource = function(src) {
<ide> src = newsrc;
<ide> } else if (typeof src === 'string' && src.trim()) {
<ide> // convert string into object
<del> src = [{src}];
<add> src = [checkMimetype({src})];
<ide> } else if (isObject(src) && typeof src.src === 'string' && src.src && src.src.trim()) {
<ide> // src is already valid
<del> src = [src];
<add> src = [checkMimetype(src)];
<ide> } else {
<ide> // invalid source, turn it into an empty array
<ide> src = [];
<ide> const filterSource = function(src) {
<ide> return src;
<ide> };
<ide>
<add>/**
<add> * Checks src mimetype, adding it when possible
<add> *
<add> * @param {Tech~SourceObject} src
<add> * The src object to check
<add> * @return {Tech~SourceObject}
<add> * src Object with known type
<add> */
<add>function checkMimetype(src) {
<add> const ext = Url.getFileExtension(src.src);
<add> const mimetype = MimetypesKind[ext.toLowerCase()];
<add>
<add> if (!src.type && mimetype) {
<add> src.type = mimetype;
<add> }
<add>
<add> return src;
<add>}
<add>
<ide> export default filterSource;
<ide><path>src/js/utils/mimetypes.js
<add>/**
<add> * Mimetypes
<add> *
<add> * @see http://hul.harvard.edu/ois/////systems/wax/wax-public-help/mimetypes.htm
<add> * @typedef Mimetypes~Kind
<add> * @enum
<add> */
<add>export const MimetypesKind = {
<add> opus: 'video/ogg',
<add> ogv: 'video/ogg',
<add> mp4: 'video/mp4',
<add> mov: 'video/mp4',
<add> m4v: 'video/mp4',
<add> mkv: 'video/x-matroska',
<add> mp3: 'audio/mpeg',
<add> aac: 'audio/aac',
<add> oga: 'audio/ogg',
<add> m3u8: 'application/x-mpegURL'
<add>};
<ide><path>test/unit/utils/filter-source.test.js
<ide> QUnit.test('Dont filter extra object properties', function(assert) {
<ide> );
<ide>
<ide> });
<add>
<add>QUnit.test('SourceObject type is filled with default values when extension is known', function(assert) {
<add> assert.deepEqual(
<add> filterSource('some-url.mp4'),
<add> [{src: 'some-url.mp4', type: 'video/mp4'}],
<add> 'string source filters to object'
<add> );
<add>
<add> assert.deepEqual(
<add> filterSource('some-url.ogv'),
<add> [{src: 'some-url.ogv', type: 'video/ogg'}],
<add> 'string source filters to object'
<add> );
<add>
<add> assert.deepEqual(
<add> filterSource('some-url.aac'),
<add> [{src: 'some-url.aac', type: 'audio/aac'}],
<add> 'string source filters to object'
<add> );
<add>
<add> assert.deepEqual(
<add> filterSource({src: 'some-url.mp4'}),
<add> [{src: 'some-url.mp4', type: 'video/mp4'}],
<add> 'string source filters to object'
<add> );
<add>
<add> assert.deepEqual(
<add> filterSource({src: 'some-url.ogv'}),
<add> [{src: 'some-url.ogv', type: 'video/ogg'}],
<add> 'string source filters to object'
<add> );
<add>
<add> assert.deepEqual(
<add> filterSource([{src: 'some-url.MP4'}, {src: 'some-url.OgV'}, {src: 'some-url.AaC'}]),
<add> [{src: 'some-url.MP4', type: 'video/mp4'}, {src: 'some-url.OgV', type: 'video/ogg'}, {src: 'some-url.AaC', type: 'audio/aac'}],
<add> 'string source filters to object'
<add> );
<add>});
<add>
<add>QUnit.test('SourceObject type is not filled when extension is unknown', function(assert) {
<add> assert.deepEqual(
<add> filterSource('some-url.ppp'),
<add> [{src: 'some-url.ppp'}],
<add> 'string source filters to object'
<add> );
<add>
<add> assert.deepEqual(
<add> filterSource('some-url.a'),
<add> [{src: 'some-url.a'}],
<add> 'string source filters to object'
<add> );
<add>
<add> assert.deepEqual(
<add> filterSource('some-url.mp8'),
<add> [{src: 'some-url.mp8'}],
<add> 'string source filters to object'
<add> );
<add>});
<add>
<add>QUnit.test('SourceObject type is not changed when type exists', function(assert) {
<add> assert.deepEqual(
<add> filterSource({src: 'some-url.aac', type: 'video/zzz'}),
<add> [{src: 'some-url.aac', type: 'video/zzz'}],
<add> 'string source filters to object'
<add> );
<add>}); | 3 |
Text | Text | correct a broken link and its context | fcc706343f9d3cbe0781bd83250e39c2dad5379f | <ide><path>README.md
<ide> An example on how to use this class is given in the [`extract_features.py`](./ex
<ide> - the masked language modeling logits, and
<ide> - the next sentence classification logits.
<ide>
<del>An example on how to use this class is given in the [`run_lm_finetuning.py`](./examples/run_lm_finetuning.py) script which can be used to fine-tune the BERT language model on your specific different text corpus. This should improve model performance, if the language style is different from the original BERT training corpus (Wiki + BookCorpus).
<add>There are two examples on how to use this class is given in the [`lm_finetuning/`](./examples/lm_finetuning/) directory. The scripts in this directory can be used to fine-tune the BERT language model. This should improve model performance, if the language style is different from the original BERT training corpus (Wiki + BookCorpus).
<ide>
<ide>
<ide> #### 3. `BertForMaskedLM`
<ide> An overview of the implemented schedules:
<ide> | Sub-section | Description |
<ide> |-|-|
<ide> | [Training large models: introduction, tools and examples](#Training-large-models-introduction,-tools-and-examples) | How to use gradient-accumulation, multi-gpu training, distributed training, optimize on CPU and 16-bits training to train Bert models |
<del>| [Fine-tuning with BERT: running the examples](#Fine-tuning-with-BERT-running-the-examples) | Running the examples in [`./examples`](./examples/): `extract_classif.py`, `run_classifier.py`, `run_squad.py` and `run_lm_finetuning.py` |
<add>| [Fine-tuning with BERT: running the examples](#Fine-tuning-with-BERT-running-the-examples) | Running the examples in [`./examples`](./examples/): `extract_classif.py`, `run_classifier.py`, `run_squad.py` and `lm_finetuning/simple_lm_finetuning.py` |
<ide> | [Fine-tuning with OpenAI GPT, Transformer-XL and GPT-2](#openai-gpt-transformer-xl-and-gpt-2-running-the-examples) | Running the examples in [`./examples`](./examples/): `run_openai_gpt.py`, `run_transfo_xl.py` and `run_gpt2.py` |
<ide> | [Fine-tuning BERT-large on GPUs](#Fine-tuning-BERT-large-on-GPUs) | How to fine tune `BERT large`|
<ide> | 1 |
Ruby | Ruby | fix oom with large bottles | ac9af0dbbc3b466dbef58ffd3a7ee14b1cec87db | <ide><path>Library/Homebrew/github_packages.rb
<ide>
<ide> require "utils/curl"
<ide> require "json"
<add>require "zlib"
<ide>
<ide> # GitHub Packages client.
<ide> #
<ide> class GitHubPackages
<ide>
<ide> URL_REGEX = %r{(?:#{Regexp.escape(URL_PREFIX)}|#{Regexp.escape(DOCKER_PREFIX)})([\w-]+)/([\w-]+)}.freeze
<ide>
<add> GZIP_BUFFER_SIZE = 64 * 1024
<add> private_constant :GZIP_BUFFER_SIZE
<add>
<ide> # Translate Homebrew tab.arch to OCI platform.architecture
<ide> TAB_ARCH_TO_PLATFORM_ARCHITECTURE = {
<ide> "arm64" => "arm64",
<ide> def upload_bottle(user, token, skopeo, formula_full_name, bottle_hash, keep_old:
<ide> "os.version" => os_version,
<ide> }.reject { |_, v| v.blank? }
<ide>
<del> tar_sha256 = Digest::SHA256.hexdigest(
<del> Utils.safe_popen_read("gunzip", "--stdout", "--decompress", local_file),
<del> )
<add> tar_sha256 = Digest::SHA256.new
<add> Zlib::GzipReader.open(local_file) do |gz|
<add> while (data = gz.read(GZIP_BUFFER_SIZE))
<add> tar_sha256 << data
<add> end
<add> end
<ide>
<del> config_json_sha256, config_json_size = write_image_config(platform_hash, tar_sha256, blobs)
<add> config_json_sha256, config_json_size = write_image_config(platform_hash, tar_sha256.hexdigest, blobs)
<ide>
<ide> formulae_dir = tag_hash["formulae_brew_sh_path"]
<ide> documentation = "https://formulae.brew.sh/#{formulae_dir}/#{formula_name}" if formula_core_tap | 1 |
Text | Text | update installation instructions on the blog | 3d52856bb6e833c06ce885d10715069662c92a38 | <ide><path>docs/_posts/2016-11-16-react-v15.4.0.md
<ide> You can learn more about snapshot testing in [this Jest blog post](https://faceb
<ide>
<ide> ## Installation
<ide>
<del>We recommend using React from `npm` and using a tool like browserify or webpack to build your code into a single bundle. To install the two packages:
<add>We recommend using [Yarn](https://yarnpkg.com/) or [npm](https://www.npmjs.com/) for managing front-end dependencies. If you're new to package managers, [Yarn documentation](https://yarnpkg.com/en/docs/getting-started) is a good place to get started.
<ide>
<del>* `npm install --save [email protected] [email protected]`
<add>To install React with Yarn, run:
<ide>
<del>Remember that by default, React runs extra checks and provides helpful warnings in development mode. When deploying your app, set the `NODE_ENV` environment variable to `production` to use the production build of React which does not include the development warnings and runs significantly faster.
<add>```bash
<add>yarn add [email protected] [email protected]
<add>```
<add>
<add>To install React with npm, run:
<add>
<add>```bash
<add>npm install --save [email protected] [email protected]
<add>```
<add>
<add>We recommend using a bundler like [webpack](https://webpack.github.io/) or [Browserify](http://browserify.org/) so you can write modular code and bundle it together into small packages to optimize load time.
<add>
<add>Remember that by default, React runs extra checks and provides helpful warnings in development mode. When deploying your app, make sure to [compile it in production mode](/react/docs/installation.html#development-and-production-versions).
<ide>
<del>If you can’t use `npm` yet, we provide pre-built browser builds for your convenience, which are also available in the `react` package on bower.
<add>In case you don't use a bundler, we also provide pre-built bundles in the npm packages which you can [include as script tags](/react/docs/installation.html#using-a-cdn) on your page:
<ide>
<ide> * **React**
<del> Dev build with warnings: [react.js](https://unpkg.com/[email protected]/dist/react.js)
<del> Minified build for production: [react.min.js](https://unpkg.com/[email protected]/dist/react.min.js)
<add> Dev build with warnings: [react/dist/react.js](https://unpkg.com/[email protected]/dist/react.js)
<add> Minified build for production: [react/dist/react.min.js](https://unpkg.com/[email protected]/dist/react.min.js)
<ide> * **React with Add-Ons**
<del> Dev build with warnings: [react-with-addons.js](https://unpkg.com/[email protected]/dist/react-with-addons.js)
<del> Minified build for production: [react-with-addons.min.js](https://unpkg.com/[email protected]/dist/react-with-addons.min.js)
<add> Dev build with warnings: [react/dist/react-with-addons.js](https://unpkg.com/[email protected]/dist/react-with-addons.js)
<add> Minified build for production: [react/dist/react-with-addons.min.js](https://unpkg.com/[email protected]/dist/react-with-addons.min.js)
<ide> * **React DOM** (include React in the page before React DOM)
<del> Dev build with warnings: [react-dom.js](https://unpkg.com/[email protected]/dist/react-dom.js)
<del> Minified build for production: [react-dom.min.js](https://unpkg.com/[email protected]/dist/react-dom.min.js)
<add> Dev build with warnings: [react-dom/dist/react-dom.js](https://unpkg.com/[email protected]/dist/react-dom.js)
<add> Minified build for production: [react-dom/dist/react-dom.min.js](https://unpkg.com/[email protected]/dist/react-dom.min.js)
<ide> * **React DOM Server** (include React in the page before React DOM Server)
<del> Dev build with warnings: [react-dom-server.js](https://unpkg.com/[email protected]/dist/react-dom-server.js)
<del> Minified build for production: [react-dom-server.min.js](https://unpkg.com/[email protected]/dist/react-dom-server.min.js)
<add> Dev build with warnings: [react-dom/dist/react-dom-server.js](https://unpkg.com/[email protected]/dist/react-dom-server.js)
<add> Minified build for production: [react-dom/dist/react-dom-server.min.js](https://unpkg.com/[email protected]/dist/react-dom-server.min.js)
<ide>
<ide> We've also published version `15.4.0` of the `react`, `react-dom`, and addons packages on npm and the `react` package on bower.
<ide> | 1 |
Javascript | Javascript | simplify jquery#offsetparent method | 74ae5444832b2fb966768a97281d2ad8c088bc58 | <ide><path>src/offset.js
<ide> jQuery.fn.extend({
<ide> };
<ide> },
<ide>
<add> // This method will return documentElement in the following cases:
<add> // 1) For the element inside the iframe without offsetParent, this method will return
<add> // documentElement of the parent window
<add> // 2) For the hidden or detached element
<add> // 3) For body or html element, i.e. in case of the html node - it will return itself
<add> //
<add> // but those exceptions were never presented as a real life use-cases
<add> // and might be considered as more preferable results.
<add> //
<add> // This logic, however, is not guaranteed and can change at any point in the future
<ide> offsetParent: function() {
<ide> return this.map(function() {
<del> var offsetParent = this.offsetParent || documentElement;
<add> var offsetParent = this.offsetParent;
<ide>
<del> while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) &&
<del> jQuery.css( offsetParent, "position" ) === "static" ) ) {
<add> while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
<ide> offsetParent = offsetParent.offsetParent;
<ide> }
<ide> | 1 |
Java | Java | add infer_method constant and update @bean javadoc | 870d9034174ed9373619c13fcc71f0cf3bc57d30 | <ide><path>org.springframework.context/src/main/java/org/springframework/context/annotation/Bean.java
<ide> * The optional name of a method to call on the bean instance upon closing the
<ide> * application context, for example a {@code close()} method on a {@code DataSource}.
<ide> * The method must have no arguments but may throw any exception.
<add> * <p>As a convenience to the user, the container will attempt to infer a destroy
<add> * method based on the return type of the {@code @Bean} method. For example, given a
<add> * {@code @Bean} method returning an Apache Commons DBCP {@code BasicDataSource}, the
<add> * container will notice the {@code close()} method available on that type and
<add> * automatically register it as the {@code destroyMethod}. By contrast, for a return
<add> * type of JDBC {@code DataSource} interface (which does not declare a {@code close()}
<add> * method, no inference is possible and the user must fall back to manually declaring
<add> * {@code @Bean(destroyMethod="close")}.
<add> * <p>To disable destroy method inference for a particular {@code @Bean}, specify an
<add> * empty string as the value, e.g. {@code @Bean(destroyMethod="")}.
<ide> * <p>Note: Only invoked on beans whose lifecycle is under the full control of the
<ide> * factory, which is always the case for singletons but not guaranteed
<ide> * for any other scope.
<ide> * @see org.springframework.context.ConfigurableApplicationContext#close()
<ide> */
<del> String destroyMethod() default "";
<add> String destroyMethod() default ConfigurationClassUtils.INFER_METHOD;
<ide>
<ide> }
<ide><path>org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java
<ide> abstract class ConfigurationClassUtils {
<ide> private static final String CONFIGURATION_CLASS_ATTRIBUTE =
<ide> Conventions.getQualifiedAttributeName(ConfigurationClassPostProcessor.class, "configurationClass");
<ide>
<add> static final String INFER_METHOD = ""; // TODO SPR-8751 update to '-' or some such
<add>
<ide>
<ide> /**
<ide> * Check whether the given bean definition is a candidate for a configuration class, | 2 |
Text | Text | reflect recent changes to tap commands | add10c64f12d65e7d1950633c991c1c78ca59b27 | <ide><path>docs/Homebrew-linuxbrew-core-Maintainer-Guide.md
<ide> running `git push your-fork master`
<ide> After merging changes, we must rebuild bottles for all the PRs that
<ide> had conflicts.
<ide>
<del>To do this, tap `Linuxbrew/homebrew-developer` and run the following
<add>To do this, tap `Homebrew/homebrew-linux-dev` and run the following
<ide> command where the merge commit is `HEAD`:
<ide>
<ide> ```sh
<ide> against the formulae:
<ide> And it skips formulae if any of the following are true:
<ide> - it doesn't need a bottle
<ide> - it already has a bottle
<del>- the formula depends on macOS to build
<ide> - the formula's tap is Homebrew/homebrew-core (the upstream macOS repo)
<ide> - there is already an open PR for the formula's bottle
<ide> - the current branch is not master
<ide> run `brew find-formulae-to-bottle --verbose` separate to the `for`
<ide> loop above.
<ide>
<ide> The `build-bottle-pr` script creates a branch called `bottle-<FORMULA>`, adds `# Build a bottle
<del>for Linuxbrew` to the top of the formula, pushes the branch to GitHub
<add>for Linux` to the top of the formula, pushes the branch to GitHub
<ide> at the specified remote (default: `origin`), and opens a pull request using `hub
<ide> pull-request`.
<ide> | 1 |
Javascript | Javascript | handle emit before constructor call | d345c1173ac9c7ba861039707a142e187651f71d | <ide><path>lib/events.js
<ide> EventEmitter.prototype.emit = function(type) {
<ide> }
<ide> }
<ide>
<add> if (!this._events)
<add> this._events = {};
<add>
<ide> handler = this._events[type];
<ide>
<ide> if (typeof handler === 'undefined')
<ide><path>test/simple/test-event-emitter-subclass.js
<ide> var util = require('util');
<ide> util.inherits(MyEE, EventEmitter);
<ide>
<ide> function MyEE(cb) {
<add> this.emit('bar');
<ide> this.on('foo', cb);
<ide> process.nextTick(this.emit.bind(this, 'foo'));
<ide> EventEmitter.call(this); | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.