Download the PHP package box/shmock without Composer

On this page you can find all versions of the php package box/shmock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package shmock

Shmock (SHorthand for MOCKing)

What is this?

Shmock is a smooth alternative for creating mocks with PHPUnit that uses the mock/replay concept from EasyMock but uses closures to define the scope for mocking.

Installation

Shmock can be installed directly from Packagist.

Alternatively you can download Shmock.php and Shmockers.php into your test directory and run

PHPUnit should already be on the load path for this to work.

Type Safety

Shmock is typesafe by default and will attempt to tell you when you're using the wrong mocking approach. Shmock will throw errors in cases where:

These checks can be disabled by calling $mock_object->disable_strict_method_checking() inside the shmock closure. We also plan on supporting parameter and return value checking if it complies with yet-to-be-defined PHPDoc conventions.

Documentation:

http://box.github.io/shmock/namespaces/Shmock.html

Full list of Shmock features:

  1. Shmock lets you configure a mock object inside a closure. You work with a proxy object that feels like the real thing.
  2. Invoking a method sets up the expectation that it will be called once.
  3. Invoking a method with arguments causes it to expect those arguments when actually invoked.
  4. You can return values from specific invocations. In the example, the value 100 will be returned when you call the method.
  5. You can specify an expectation for the number of times a method will be called. By default it's expected once.
  6. Or you can specify "0 or more" times with any()
  7. You can nest your Shmock invocations, letting you define your mock dependencies elegantly. (If you have a two-way dependency, you can always just return_value($other_shmock) and define it somewhere else )
  8. On an object-level you can specify "order matters", meaning that the ordering of function invocations should be asserted against as well. Under the hood, this uses PHPUnit's at(N) calls automatically
  9. You have some options as far as defining constructor arguments. a) You can opt to disable the original constructor. Normally PHPUnit will run the original constructor. b) You can run the original constructor with the given arguments.
  10. Instead of returning a value, you can throw an exception when a method gets called.
  11. Even more sophisticated, you can execute an arbitrary closure when the function gets called.
  12. If you want to mock static functions, you call shmock_class which will give you all the same Shmock semantics as instances (where it makes sense). This is particularly useful when you want to partially mock an object, keeping some of the original behavior, but mocking out static / protected methods that may exist that the method you are testing is dependent on.
  13. You can also mock a class independently of a mock instance.

Copyright and License

Copyright 2014 Box, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


All versions of shmock with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
phpunit/phpunit Version >=3.7
nicmart/string-template Version 0.1.0
sebastian/diff Version >=1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package box/shmock contains the following files

Loading the files please wait ....