mockery
Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL).
File Explorer
Download Latest Version (.zip)- BUG_REPORT.yml
- codecov.yml
- framework.yml
- phpunit.yml
- psalm.yml
- tests.yml
- .gitkeep
- big_parent_class.rst
- class_constants.rst
- default_expectations.rst
- detecting_mock_objects.rst
- index.rst
- map.rst.inc
- mockery_on.rst
- mocking_class_within_class.rst
- mocking_hard_dependencies.rst
- not_calling_the_constructor.rst
- index.rst
- installation.rst
- map.rst.inc
- quick_reference.rst
- simple_example.rst
- upgrading.rst
- configuration.rst
- exceptions.rst
- gotchas.rst
- index.rst
- map.rst.inc
- reserved_method_names.rst
- alternative_should_receive_syntax.rst
- argument_validation.rst
- creating_test_doubles.rst
- demeter_chains.rst
- expectations.rst
- final_methods_classes.rst
- index.rst
- instance_mocking.rst
- magic_methods.rst
- map.rst.inc
- partial_mocks.rst
- pass_by_reference_behaviours.rst
- phpunit_integration.rst
- protected_methods.rst
- public_properties.rst
- public_static_properties.rst
- spies.rst
- .gitignore
- conf.py
- index.rst
- Makefile
- README.md
- requirements.txt
- TestFinishedSubscriber.php
- TestSuiteStartedSubscriber.php
- Extension.php
- MockeryPHPUnitIntegration.php
- MockeryPHPUnitIntegrationAssertPostConditions.php
- MockeryTestCase.php
- MockeryTestCaseSetUp.php
- TestListener.php
- TestListenerTrait.php
- AtLeast.php
- AtMost.php
- CountValidatorAbstract.php
- CountValidatorInterface.php
- Exact.php
- Exception.php
- BadMethodCallException.php
- InvalidArgumentException.php
- InvalidCountException.php
- InvalidOrderException.php
- MockeryExceptionInterface.php
- NoMatchingExpectationException.php
- RuntimeException.php
- AvoidMethodClashPass.php
- CallTypeHintPass.php
- ClassAttributesPass.php
- ClassNamePass.php
- ClassPass.php
- ConstantsPass.php
- InstanceMockPass.php
- InterfacePass.php
- MagicMethodTypeHintsPass.php
- MethodDefinitionPass.php
- Pass.php
- RemoveBuiltinMethodsThatAreFinalPass.php
- RemoveDestructorPass.php
- RemoveUnserializeForInternalSerializableClassesPass.php
- TraitPass.php
- CachingGenerator.php
- DefinedTargetClass.php
- Generator.php
- Method.php
- MockConfiguration.php
- MockConfigurationBuilder.php
- MockDefinition.php
- MockNameBuilder.php
- Parameter.php
- StringManipulationGenerator.php
- TargetClassInterface.php
- UndefinedTargetClass.php
- EvalLoader.php
- Loader.php
- RequireLoader.php
- AndAnyOtherArgs.php
- Any.php
- AnyArgs.php
- AnyOf.php
- ArgumentListMatcher.php
- Closure.php
- Contains.php
- Ducktype.php
- HasKey.php
- HasValue.php
- IsEqual.php
- IsSame.php
- MatcherAbstract.php
- MatcherInterface.php
- MultiArgumentClosure.php
- MustBe.php
- NoArgs.php
- Not.php
- NotAnyOf.php
- Pattern.php
- Subset.php
- Type.php
- ClosureWrapper.php
- CompositeExpectation.php
- Configuration.php
- Container.php
- Exception.php
- Expectation.php
- ExpectationDirector.php
- ExpectationInterface.php
- ExpectsHigherOrderMessage.php
- HigherOrderMessage.php
- Instantiator.php
- LegacyMockInterface.php
- MethodCall.php
- Mock.php
- MockInterface.php
- QuickDefinitionsConfiguration.php
- ReceivedMethodCalls.php
- Reflector.php
- Undefined.php
- VerificationDirector.php
- VerificationExpectation.php
- helpers.php
- Mockery.php
- file.txt
- A.php
- B.php
- C.php
- Main.php
- Plant.php
- Animal.php
- Habitat.php
- EmptyTestCase.php
- Gardener.php
- BaseClassStub.php
- Chatroulette_ConnectionInterface.php
- ChildClass.php
- ClassChildOfWithCustomFormatter.php
- ClassImplementsWithCustomFormatter.php
- ClassWithAllLowerCaseMethod.php
- ClassWithAllowsMethod.php
- ClassWithConstants.php
- ClassWithCustomFormatter.php
- ClassWithDebugInfo.php
- ClassWithExpectsMethod.php
- ClassWithFinalMethod.php
- ClassWithGetter.php
- ClassWithGetterWithParam.php
- ClassWithMagicCall.php
- ClassWithMethods.php
- ClassWithNoToString.php
- ClassWithoutCustomFormatter.php
- ClassWithProtectedMethod.php
- ClassWithPublicStaticGetter.php
- ClassWithPublicStaticProperty.php
- ClassWithStaticMethods.php
- ClassWithToString.php
- CustomValueObject.php
- CustomValueObjectInterface.php
- CustomValueObjectMatcher.php
- EmptyConstructorTest.php
- Evenement_EventEmitter.php
- Evenement_EventEmitterInterface.php
- ExampleClassForTestingNonExistentMethod.php
- Gateway.php
- HasUnknownClassAsTypeHintOnMethod.php
- InterfaceWithCustomFormatter.php
- IWater.php
- MethodWithIterableTypeHints.php
- MethodWithNullableReturnType.php
- MethodWithNullableTypedParameter.php
- MethodWithParametersWithDefaultValues.php
- MethodWithVoidReturnType.php
- Mockery_Demeterowski.php
- Mockery_Duck.php
- Mockery_Duck_Nonswimmer.php
- Mockery_Magic.php
- Mockery_UseDemeter.php
- MockeryFoo3.php
- MockeryFoo4.php
- MockeryTest_AbstractWithAbstractMethod.php
- MockeryTest_AbstractWithAbstractPublicMethod.php
- MockeryTest_Call1.php
- MockeryTest_Call2.php
- MockeryTest_CallStatic.php
- MockeryTest_ClassConstructor.php
- MockeryTest_ClassConstructor2.php
- MockeryTest_ClassMultipleConstructorParams.php
- MockeryTest_ClassThatDescendsFromInternalClass.php
- MockeryTest_ClassThatExtendsArrayObject.php
- MockeryTest_ExistingProperty.php
- MockeryTest_Foo.php
- MockeryTest_ImplementsIterator.php
- MockeryTest_ImplementsIteratorAggregate.php
- MockeryTest_Interface.php
- MockeryTest_Interface1.php
- MockeryTest_Interface2.php
- MockeryTest_InterfaceThatExtendsIterator.php
- MockeryTest_InterfaceThatExtendsIteratorAggregate.php
- MockeryTest_InterfaceWithAbstractMethod.php
- MockeryTest_InterfaceWithMethodParamSelf.php
- MockeryTest_InterfaceWithPublicStaticMethod.php
- MockeryTest_InterfaceWithTraversable.php
- MockeryTest_InterMethod1.php
- MockeryTest_IssetMethod.php
- MockeryTest_Lowercase_ToString.php
- MockeryTest_MethodParamRef.php
- MockeryTest_MethodParamRef2.php
- MockeryTest_MethodWithRequiredParamWithDefaultValue.php
- MockeryTest_MockCallableTypeHint.php
- MockeryTest_PartialAbstractClass.php
- MockeryTest_PartialAbstractClass2.php
- MockeryTest_PartialNormalClass.php
- MockeryTest_PartialNormalClass2.php
- MockeryTest_PartialStatic.php
- MockeryTest_ReturnByRef.php
- MockeryTest_SubjectCall1.php
- MockeryTest_TestInheritedType.php
- MockeryTest_UnsetMethod.php
- MockeryTest_Wakeup1.php
- MockeryTest_WithProtectedAndPrivate.php
- MockeryTest_WithToString.php
- MockeryTestBar1.php
- MockeryTestFoo.php
- MockeryTestFoo2.php
- MockeryTestIsset_Bar.php
- MockeryTestIsset_Foo.php
- MockeryTestRef1.php
- MyInterface.php
- MyService2.php
- NameOfAbstract.php
- NameOfExistingClass.php
- NameOfExistingClassWithDestructor.php
- NameOfInterface.php
- NullableObject.php
- OldStyleConstructor.php
- ParentClass.php
- React_ReadableStreamInterface.php
- React_StreamInterface.php
- React_WritableStreamInterface.php
- ReturnTypeIterableTypeHint.php
- SemiReservedWordsAsMethods.php
- SimpleTrait.php
- SoCool.php
- SubclassWithFinalToString.php
- SubclassWithFinalWakeup.php
- TestFinal.php
- TestIncreasedVisibilityChild.php
- TestIncreasedVisibilityParent.php
- TestInterface.php
- TestInterface2.php
- TestSubject.php
- TestTraversableInterface.php
- TestTraversableInterface2.php
- TestTraversableInterface3.php
- TestWithFinalToString.php
- TestWithFinalWakeup.php
- TestWithMethodOverloading.php
- TestWithMethodOverloadingWithoutCall.php
- TestWithNonFinalToString.php
- TestWithNonFinalWakeup.php
- TestWithProtectedMethods.php
- TestWithVariadicArguments.php
- TraitWithAbstractMethod.php
- UnmockableClass.php
- ClassWithCloneMethod.php
- ClassWithConstructorAndCloneMethod.php
- InterfaceWithCloneMethod.php
- InitTrait.php
- Service.php
- DummyClass.php
- RestrictReturnType.php
- ArgumentMixedTypeHint.php
- ArgumentParentTypeHint.php
- ArgumentUnionTypeHint.php
- ArgumentUnionTypeHintWithNull.php
- ImplementsIterator.php
- ImplementsIteratorAggregate.php
- MethodWithStaticReturnType.php
- MultiArgument.php
- PHP80TestInterface.php
- ReturnTypeMixedTypeHint.php
- ReturnTypeParentTypeHint.php
- ReturnTypeUnionTypeHint.php
- A.php
- ArgumentIntersectionTypeHint.php
- B.php
- C.php
- ClassThatImplementsSerializable.php
- ClassWithNewInInitializer.php
- HandlerClass.php
- IntersectionTypeHelper1Interface.php
- IntersectionTypeHelper2Interface.php
- IntersectionTypeHelperClass.php
- LoggerInterface.php
- MockClass.php
- MockeryTest_ClassThatImplementsSerializable.php
- NeverReturningTypehintClass.php
- NullLogger.php
- ReturnTypeWillChangeAttributeNoReturnType.php
- ReturnTypeWillChangeAttributeWrongReturnType.php
- SimpleEnum.php
- SomeAttribute.php
- UsesEnums.php
- AClass.php
- AInterface.php
- BClass.php
- BInterface.php
- CClass.php
- CInterface.php
- DInterface.php
- HasNullReturnType.php
- HasReservedWordFalse.php
- HasReservedWordTrue.php
- IReturnCoVarianceTest.php
- IterableObject.php
- IterableObjectString.php
- IterableStdClassString.php
- ITest.php
- ITestTwo.php
- ReadonlyClass.php
- Sut.php
- TestOne.php
- TestReturnCoVarianceOne.php
- TestReturnCoVarianceThree.php
- TestReturnCoVarianceTwo.php
- TestThree.php
- TestTwo.php
- WClass.php
- XClass.php
- YClass.php
- ZClass.php
- Classes.php
- ClassName.php
- Enums.php
- Interfaces.php
- Traits.php
- Temp.php
- Temp.php
- ClassWithConstructorAndDestructor.php
- MockeryPHPUnitIntegrationTest.php
- PhpUnitConstraintExpectationTest.php
- TestListenerTest.php
- CallTypeHintPassTest.php
- ClassAttributesPassTest.php
- ClassNamePassTest.php
- ClassPassTest.php
- ConstantsPassTest.php
- InstanceMockPassTest.php
- InterfacePassTest.php
- MethodDefinitionPassTest.php
- DefinedTargetClassTest.php
- MockConfigurationBuilderTest.php
- EvalLoaderTest.php
- LoaderTestCase.php
- RequireLoaderTest.php
- HasKeyTest.php
- HasValueTest.php
- IsEqualTest.php
- IsSameTest.php
- MatcherDataProviderTrait.php
- SubsetTest.php
- AdhocTest.php
- AllowsExpectsSyntaxTest.php
- CallableSpyTest.php
- ContainerTest.php
- DefaultMatchersTest.php
- DemeterChainTest.php
- ExpectationTest.php
- GlobalHelpersTest.php
- HamcrestExpectationTest.php
- MagicMethodsTest.php
- MockClassWithFinalToStringTest.php
- MockClassWithIterableReturnTypeTest.php
- MockClassWithMethodOverloadingTest.php
- MockClassWithUnknownTypeHintTest.php
- MockConfigurationTest.php
- MockeryCanMockClassesWithSemiReservedWordsTest.php
- MockeryCanMockMultipleInterfacesWhichOverlapTest.php
- MockingAllLowerCasedMethodsTest.php
- MockingClassConstantsTest.php
- MockingMethodsWithIterableTypeHintsTest.php
- MockingMethodsWithMixedReturnTypeTest.php
- MockingMethodsWithNullableParametersTest.php
- MockingNullableMethodsTest.php
- MockingProtectedMethodsTest.php
- MockingStaticMethodsCalledObjectStyleTest.php
- MockingVariadicArgumentsTest.php
- MockTest.php
- NamedMockTest.php
- ProxyMockingTest.php
- ReflectorTest.php
- SpyTest.php
- TestCase1459Test.php
- TraitsTest.php
- MockClassWithFinalWakeupTest.php
- MockingOldStyleConstructorTest.php
- MockingVoidMethodsTest.php
- TestCase1328Test.php
- TestCase1404Test.php
- WithCustomFormatterExpectationTest.php
- WithFormatterExpectationTest.php
- TestCase1132Test.php
- TestCase1402Test.php
- MockingMethodsWithStaticReturnTypeTest.php
- MockWithClosureAsLastArgumentTest.php
- Php80LanguageFeaturesTest.php
- TestCase1414Test.php
- Php81LanguageFeaturesTest.php
- Php82LanguageFeaturesTest.php
- TestCase1317Test.php
- TestCase1439Test.php
- Php83LanguageFeaturesTest.php
- Php84LanguageFeaturesTest.php
- Php85LanguageFeaturesTest.php
- Php86LanguageFeaturesTest.php
- AbstractTestCase.php
- README.md
- Bootstrap.php
- phive
- phpdocumentor
- psalm
- .editorconfig
- .gitattributes
- .gitignore
- .phpstorm.meta.php
- .readthedocs.yml
- CHANGELOG.md
- composer.json
- composer.lock
- CONTRIBUTING.md
- COPYRIGHT.md
- e2e-test.sh
- ecs.php
- LICENSE
- Makefile
- phive.xml
- phpunit-10.5.xml.dist
- phpunit-11.5.xml.dist
- phpunit-12.5.xml.dist
- phpunit-13.3.xml.dist
- phpunit-9.6.xml.dist
- phpunit.xml.dist
- psalm-baseline.xml
- psalm.xml.dist
- README.md
- SECURITY.md
# Installation Guide
1. Get the code
git clone https://github.com/mockery/mockery
Downloads the entire project code from GitHub to your computer.
cd mockery
Moves into the project folder you just downloaded.
2. PHP (Composer)
Easy RecommendedPrerequisites
composer require --dev mockery/mockery
Type this command into your terminal and run it.
Run it with a built-in server like php -S localhost:8000, then open http://localhost:8000 in your browser.
Pulled directly from this repo's README.
3. Make
MediumPrerequisites
- Git Needed to download the project code from GitHub.
- Make Usually pre-installed on Linux/macOS. On Windows, install separately (e.g. via MSYS2 or WSL).
make
Compiles the code based on the generated build configuration to produce an executable.
If it finishes without errors, it worked. Try running the generated executable directly.
// repository documentation
Was this content helpful?
(0 ratings)
