Prophecy is a PHP object mocking framework for creating test doubles (stubs, mocks, spies) in unit testing. It enables developers to define prophecies about future object interactions, specifying expected behavior through promises and verifying those expectations with predictions. The framework is designed to be framework-agnostic, integrating with tools like PHPUnit and PhpSpec. The architecture centers around a Prophet service that creates object prophecies. These prophecies utilize a doubler system to generate test double classes on-the-fly, applying patches for special cases (such as handling Throwable or Traversable objects). Argument matching is handled through a flexible token system, enabling precise control over which method invocations match a prophecy. Behavior and expectations are separated into promises (defining what the double should do) and predictions (defining what is expected to occur), promoting clear and maintainable test code. Notable for its robust handling of modern PHP features, Prophecy supports union types, intersection types, nullable types, readonly classes, and the never type. Its extensible design, particularly the strategy-based argument token system and the patchable class generation, demonstrates strong software engineering practices. The framework emphasizes lazy initialization and caching of generated doubles to optimize performance, making it suitable for extensive test suites.
OCMockito is an Objective-C mocking library modeled after Mockito for Java. It provides mock objects, stubbing, and verification for unit tests. The library is built as a framework or static library, targeting iOS, macOS, tvOS, watchOS, and visionOS. Its architecture is modular: Core (public API), Mocking (NSProxy-based mock classes), Stubbing (invocation containers and answer objects), Verifying (invocation checkers and verification modes), Invocation (invocation matcher, call stack analysis, printing), and Helpers (chain-of-responsibility for argument getters and return value setters). The primary entry point is the OCMockito.h header, which exposes macros like mock(), given(), verify(), etc. Dependencies include OCHamcrest for matchers and failure reporting, and XCTest for test integration. The codebase demonstrates solid software engineering with extensive unit tests (XCTest), though there are minor maintenance concerns such as duplicated public headers, hardcoded paths in examples, and reliance on global singleton swizzling state that may cause cross-test contamination. Overall, it is a well-maintained and widely used testing library.
Pegomock is a mocking framework for the Go programming language that generates mock implementations of interfaces for testing purposes. It provides a DSL inspired by Mockito for defining mock behavior and verifying interactions. The project consists of a core library for creating and verifying mocks in tests, a CLI tool for generating mock code from interfaces, and a watch mode that automatically regenerates mocks when interfaces change. The architecture follows a modular design with separate components for the DSL, mock generation, and CLI functionality.