├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ └── php.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── acme_src ├── ErrorConditions │ ├── AfterAllAttributeOnNotTestCaseOrTestSuite │ │ └── BadTestCase.php │ ├── AfterAllNonStaticMethod │ │ └── BadTestCase.php │ ├── AfterEachAttributeOnNotTestCaseOrTestSuite │ │ └── BadTestCase.php │ ├── BadNamespaceTest │ │ └── MyTestCase.php │ ├── BadNamespaceTestCaseAfterAll │ │ └── MyTestCase.php │ ├── BadNamespaceTestCaseAfterEach │ │ └── MyTestCase.php │ ├── BadNamespaceTestCaseBeforeAll │ │ └── MyTestCase.php │ ├── BadNamespaceTestCaseBeforeEach │ │ └── MyTestCase.php │ ├── BadNamespaceTestSuiteAfterAll │ │ └── MyTestSuite.php │ ├── BadNamespaceTestSuiteAfterEach │ │ └── MyTestSuite.php │ ├── BadNamespaceTestSuiteAfterEachTest │ │ └── MyTestSuite.php │ ├── BadNamespaceTestSuiteBeforeAll │ │ └── MyTestSuite.php │ ├── BadNamespaceTestSuiteBeforeEach │ │ └── MyTestSuite.php │ ├── BadNamespaceTestSuiteBeforeEachTest │ │ └── MyTestSuite.php │ ├── BeforeAllAttributeOnNotTestCaseOrTestSuite │ │ └── BadTestCase.php │ ├── BeforeAllNonStaticMethod │ │ └── BadTestCase.php │ ├── BeforeEachAttributeOnNotTestCaseOrTestSuite │ │ └── BadTestCase.php │ ├── NoTestsTestCase │ │ └── BadTestCase.php │ └── TestAttributeOnNotTestCase │ │ └── BadTestCase.php ├── ExplicitTestSuite │ ├── AfterAllTestSuiteHook │ │ ├── FirstTestCase.php │ │ ├── MyTestSuite.php │ │ └── SecondTestCase.php │ ├── AfterEachTestSuiteHook │ │ ├── FirstTestCase.php │ │ ├── MyTestSuite.php │ │ ├── SecondTestCase.php │ │ └── ThirdTestCase.php │ ├── AfterEachTestTestSuiteHook │ │ ├── FirstTestCase.php │ │ ├── MyTestSuite.php │ │ ├── SecondTestCase.php │ │ └── ThirdTestCase.php │ ├── AnnotatedDefaultTestSuite │ │ ├── MyTestCase.php │ │ └── MyTestSuite.php │ ├── BeforeAllTestSuiteHook │ │ ├── FirstTestCase.php │ │ ├── MyTestSuite.php │ │ └── SecondTestCase.php │ ├── BeforeEachTestSuiteHook │ │ ├── FirstTestCase.php │ │ ├── MyTestSuite.php │ │ ├── SecondTestCase.php │ │ └── ThirdTestCase.php │ ├── BeforeEachTestTestSuiteHook │ │ ├── FirstTestCase.php │ │ ├── MyTestSuite.php │ │ ├── SecondTestCase.php │ │ └── ThirdTestCase.php │ ├── ExceptionThrowingTestSuiteAfterAll │ │ ├── FirstTestCase.php │ │ └── MyTestSuite.php │ ├── ExceptionThrowingTestSuiteAfterEach │ │ ├── MyTestCase.php │ │ └── MyTestSuite.php │ ├── ExceptionThrowingTestSuiteAfterEachTest │ │ ├── MyTestCase.php │ │ └── MyTestSuite.php │ ├── ExceptionThrowingTestSuiteBeforeAll │ │ ├── FirstTestCase.php │ │ └── MyTestSuite.php │ ├── ExceptionThrowingTestSuiteBeforeEach │ │ ├── MyTestCase.php │ │ └── MyTestSuite.php │ ├── ExceptionThrowingTestSuiteBeforeEachTest │ │ ├── MyTestCase.php │ │ └── MyTestSuite.php │ ├── TestCaseAfterAllHasTestSuiteState │ │ ├── MyTestCase.php │ │ └── MyTestSuite.php │ ├── TestCaseBeforeAllHasTestSuiteState │ │ ├── MyTestCase.php │ │ └── MyTestSuite.php │ ├── TestCaseDefinedAndImplicitDefaultTestSuite │ │ ├── FirstTestCase.php │ │ ├── MyTestSuite.php │ │ └── SecondTestCase.php │ ├── TestCaseDefinesTestSuite │ │ ├── FirstTestCase.php │ │ ├── MyFirstTestSuite.php │ │ ├── MySecondTestSuite.php │ │ ├── SecondTestCase.php │ │ └── ThirdTestCase.php │ ├── TestSuiteDefinesNamespaceToAttach │ │ ├── HasExplicitTestSuite │ │ │ └── MyTestCase.php │ │ ├── HasImplicitTestSuite │ │ │ └── MyTestCase.php │ │ ├── MyTestCase.php │ │ └── MyTestSuite.php │ ├── TestSuiteDisabled │ │ ├── FirstTestCase.php │ │ ├── MyTestSuite.php │ │ └── SecondTestCase.php │ ├── TestSuiteDisabledCustomMessage │ │ ├── MyTestCase.php │ │ └── MyTestSuite.php │ ├── TestSuiteDisabledHookNotInvoked │ │ ├── MyTestCase.php │ │ └── MyTestSuite.php │ ├── TestSuiteHasTimeout │ │ ├── FirstTestCase.php │ │ ├── MyTestSuite.php │ │ └── SecondTestCase.php │ ├── TestSuiteHookPriority │ │ ├── MyTestCase.php │ │ └── MyTestSuite.php │ └── TestSuiteStateBeforeAll │ │ ├── FirstTestCase.php │ │ └── MyTestSuite.php └── ImplicitDefaultTestSuite │ ├── CustomAssertions │ └── MyTestCase.php │ ├── ExceptionThrowingAfterAll │ └── MyTestCase.php │ ├── ExceptionThrowingAfterEach │ └── MyTestCase.php │ ├── ExceptionThrowingBeforeAll │ └── MyTestCase.php │ ├── ExceptionThrowingBeforeEach │ └── MyTestCase.php │ ├── ExceptionThrowingTest │ ├── MyTestCase.php │ └── async-unit.json │ ├── ExceptionThrowingTestWithAfterEachHook │ └── MyTestCase.php │ ├── ExtendedTestCases │ ├── AbstractFourthTestCase.php │ ├── AbstractSecondTestCase.php │ ├── FifthTestCase.php │ ├── FirstTestCase.php │ └── ThirdTestCase.php │ ├── FailedAssertion │ └── MyTestCase.php │ ├── FailedNotAssertion │ └── MyTestCase.php │ ├── HandleNonPhpFiles │ ├── MyTestCase.php │ ├── something-else.xml │ └── something.json │ ├── HasAssertionPlugin │ ├── MyCustomAssertionPlugin.php │ ├── MyOtherCustomAssertionPlugin.php │ └── MyTestCase.php │ ├── HasDataProvider │ └── MyTestCase.php │ ├── HasNotTestCaseObject │ ├── MyTestCase.php │ └── NotTestCase.php │ ├── HasResultPrinterPlugin │ ├── MyResultPrinterPlugin.php │ └── MyTestCase.php │ ├── HasSingleAfterAllHook │ └── MyTestCase.php │ ├── HasSingleAfterEachHook │ └── MyTestCase.php │ ├── HasSingleBeforeAllHook │ └── MyTestCase.php │ ├── HasSingleBeforeEachHook │ └── MyTestCase.php │ ├── KitchenSink │ ├── FirstTestCase.php │ ├── FirstTestSuite.php │ ├── SecondBreakfast │ │ ├── BadTestCase.php │ │ └── FoodAndBeverageTestCase.php │ ├── SecondTestCase.php │ └── WhatAbout │ │ ├── BilboTestCase.php │ │ ├── FrodoTestCase.php │ │ ├── PotatoTestSuite.php │ │ └── SamwiseTestCase.php │ ├── MockeryTestNoAssertion │ └── MyTestCase.php │ ├── MultipleBeforeAllHooks │ ├── FirstTestCase.php │ └── SecondTestCase.php │ ├── MultipleTest │ └── MyTestCase.php │ ├── MultipleTestCase │ ├── BarTestCase.php │ ├── BazTestCase.php │ └── FooTestCase.php │ ├── MultipleTestsKnownDuration │ ├── FirstTestCase.php │ ├── SecondTestCase.php │ └── ThirdTestCase.php │ ├── NoAssertions │ └── MyTestCase.php │ ├── RecursiveTestLayout │ ├── TestOne.php │ └── Two │ │ ├── TestTwo.php │ │ └── Three │ │ ├── Four │ │ ├── Five │ │ │ └── TestFive.php │ │ └── TestFour.php │ │ └── TestThree.php │ ├── SingleMockTest │ └── MyTestCase.php │ ├── SingleTest │ ├── MyTestCase.php │ └── async-unit.json │ ├── SingleTestAsyncAssertion │ └── MyTestCase.php │ ├── SingleTestDisabled │ └── MyTestCase.php │ ├── TestCaseDisabled │ └── MyTestCase.php │ ├── TestCaseDisabledCustomMessage │ └── MyTestCase.php │ ├── TestCaseDisabledHookNotInvoked │ └── MyTestCase.php │ ├── TestCaseHasTimeout │ └── MyTestCase.php │ ├── TestCaseHooksPriority │ └── MyTestCase.php │ ├── TestDisabled │ └── MyTestCase.php │ ├── TestDisabledCustomMessage │ └── MyTestCase.php │ ├── TestDisabledEvents │ └── MyTestCase.php │ ├── TestDisabledHookNotInvoked │ └── MyTestCase.php │ ├── TestExpectsExceptionDoesNotThrow │ └── MyTestCase.php │ ├── TestExpectsExceptionMessage │ └── MyTestCase.php │ ├── TestExpectsExceptionOnly │ └── MyTestCase.php │ ├── TestExpectsExceptionWrongMessage │ └── MyTestCase.php │ ├── TestExpectsExceptionWrongType │ └── MyTestCase.php │ ├── TestExpectsNoAssertions │ └── MyTestCase.php │ ├── TestExpectsNoAssertionsAssertMade │ └── MyTestCase.php │ ├── TestExpectsNoAsyncAssertionsAssertMade │ └── MyTestCase.php │ ├── TestFailedExceptionThrowingTest │ └── MyTestCase.php │ ├── TestHasOutput │ └── MyTestCase.php │ ├── TestHasTimeout │ └── MyTestCase.php │ ├── TestKnownRunTime │ └── MyTestCase.php │ └── WithAsyncUnitConfig │ ├── async-unit.json │ └── tests │ ├── Bar │ └── FooTestCase.php │ └── Foo │ └── BarTestCase.php ├── bin └── asyncunit ├── cli_src ├── AsyncUnitConsoleApplication.php ├── Command │ ├── AbstractCommand.php │ ├── GenerateConfigurationCommand.php │ └── RunTestsCommand.php ├── Exception │ └── Exception.php └── TerminalResultPrinter.php ├── cli_test ├── Command │ ├── BaseCommandTest.php │ ├── GenerateConfigurationCommandTest.php │ └── RunTestsCommandTest.php └── Integration │ ├── error_test_output.phpt │ ├── helpers.php │ └── single_test_output.phpt ├── composer.json ├── composer.lock ├── examples ├── blog_introduction_src │ ├── ExampleFour │ │ └── MyTestCase.php │ ├── ExampleOne │ │ └── MyTestCase.php │ ├── ExampleThree │ │ └── MyTestCase.php │ └── ExampleTwo │ │ └── MyTestCase.php ├── custom_assertion_src │ ├── MyAssertion.php │ ├── MyAssertionPlugin.php │ └── TestCaseUsesMyAssertion.php └── simple_equals_src │ └── StringEqualsTest.php ├── framework_src ├── Assertion.php ├── Assertion │ ├── AbstractAssertion.php │ ├── AbstractAsyncAssertion.php │ ├── AssertArrayEquals.php │ ├── AssertCountEquals.php │ ├── AssertFloatEquals.php │ ├── AssertInstanceOf.php │ ├── AssertIntEquals.php │ ├── AssertIsEmpty.php │ ├── AssertIsFalse.php │ ├── AssertIsNull.php │ ├── AssertIsTrue.php │ ├── AssertStringEquals.php │ ├── AssertionMessage │ │ ├── BinaryOperandDetails.php │ │ ├── BinaryOperandSummary.php │ │ ├── CountEqualsMessage.php │ │ ├── EmptyUnaryOperandDetails.php │ │ ├── EmptyUnaryOperandSummary.php │ │ ├── FalseUnaryOperandDetails.php │ │ ├── FalseUnaryOperandSummary.php │ │ ├── InstanceOfMessage.php │ │ ├── NullUnaryOperandDetails.php │ │ ├── NullUnaryOperandSummary.php │ │ ├── TrueUnaryOperandDetails.php │ │ ├── TrueUnaryOperandSummary.php │ │ ├── UnaryOperandDetails.php │ │ └── UnaryOperandSummary.php │ ├── AssertionResultFactory.php │ ├── AsyncAssertArrayEquals.php │ ├── AsyncAssertCountEquals.php │ ├── AsyncAssertFloatEquals.php │ ├── AsyncAssertInstanceOf.php │ ├── AsyncAssertIntEquals.php │ ├── AsyncAssertIsEmpty.php │ ├── AsyncAssertIsFalse.php │ ├── AsyncAssertIsNull.php │ ├── AsyncAssertIsTrue.php │ └── AsyncAssertStringEquals.php ├── AssertionMessage.php ├── AssertionResult.php ├── AsyncAssertion.php ├── AsyncUnitApplication.php ├── AsyncUnitApplicationObjectGraph.php ├── AsyncUnitConfigurationValidator.php ├── AsyncUnitFrameworkRunner.php ├── Attribute │ ├── AfterAll.php │ ├── AfterEach.php │ ├── AfterEachTest.php │ ├── AttachToTestSuite.php │ ├── BeforeAll.php │ ├── BeforeEach.php │ ├── BeforeEachTest.php │ ├── DataProvider.php │ ├── DefaultTestSuite.php │ ├── Disabled.php │ ├── Prototype.php │ ├── PrototypeRequiresAttribute.php │ ├── Test.php │ └── Timeout.php ├── Configuration.php ├── ConfigurationFactory.php ├── ConfigurationValidationResults.php ├── ConfigurationValidator.php ├── Context │ ├── AssertionContext.php │ ├── AsyncAssertionContext.php │ ├── CustomAssertionContext.php │ ├── ExpectationContext.php │ ├── LastAssertionCalledTrait.php │ ├── SharedAssertionContextTrait.php │ └── TestExpector.php ├── CustomAssertionPlugin.php ├── Event │ ├── ProcessingFinishedEvent.php │ ├── ProcessingStartedEvent.php │ ├── TestCaseFinishedEvent.php │ ├── TestCaseStartedEvent.php │ ├── TestDisabledEvent.php │ ├── TestErroredEvent.php │ ├── TestFailedEvent.php │ ├── TestPassedEvent.php │ ├── TestProcessedEvent.php │ ├── TestSuiteFinishedEvent.php │ └── TestSuiteStartedEvent.php ├── Events.php ├── Exception │ ├── AssertionFailedException.php │ ├── Exception.php │ ├── InvalidArgumentException.php │ ├── InvalidConfigurationException.php │ ├── InvalidStateException.php │ ├── MockFailureException.php │ ├── TestCaseSetUpException.php │ ├── TestCaseTearDownException.php │ ├── TestCompilationException.php │ ├── TestDisabledException.php │ ├── TestErrorException.php │ ├── TestFailedException.php │ ├── TestOutputException.php │ ├── TestSetupException.php │ ├── TestSuiteSetUpException.php │ ├── TestSuiteTearDownException.php │ ├── TestTearDownException.php │ └── UnsupportedOperationException.php ├── HookType.php ├── ImplicitTestSuite.php ├── JsonConfigurationFactory.php ├── MockBridge.php ├── MockBridge │ ├── MockeryMockBridge.php │ └── ProphecyMockBridge.php ├── MockBridgeFactory.php ├── Model │ ├── CanBeDisabledTrait.php │ ├── CanHaveTimeoutTrait.php │ ├── HookAware.php │ ├── HookModel.php │ ├── MethodModelTrait.php │ ├── PluginModel.php │ ├── TestCaseModel.php │ ├── TestModel.php │ └── TestSuiteModel.php ├── NullRandomizer.php ├── Parser │ ├── AsyncUnitModelCollector.php │ ├── AsyncUnitModelNodeVisitor.php │ ├── AttributeGroupTraverser.php │ ├── Parser.php │ ├── ParserResult.php │ └── StaticAnalysisParser.php ├── Prototype │ ├── AfterEachPrototype.php │ ├── BeforeEachPrototype.php │ ├── DataProviderTestPrototype.php │ ├── TestCaseAfterAllPrototype.php │ ├── TestCaseBeforeAllPrototype.php │ ├── TestPrototype.php │ ├── TestSuiteAfterAllPrototype.php │ └── TestSuiteBeforeAllPrototype.php ├── Randomizer.php ├── ResultPrinterPlugin.php ├── ShuffleRandomizer.php ├── Statistics │ ├── AggregateSummary.php │ ├── ProcessedAggregateSummary.php │ ├── ProcessedSummaryBuilder.php │ ├── ProcessedTestCaseSummary.php │ ├── ProcessedTestSuiteSummary.php │ ├── SummaryCalculator.php │ ├── TestCaseSummary.php │ └── TestSuiteSummary.php ├── SupportedMockBridgeFactory.php ├── TestCase.php ├── TestResult.php ├── TestState.php ├── TestSuite.php └── TestSuiteRunner.php ├── framework_test ├── Assertion │ ├── AbstractAssertionTestCase.php │ ├── AbstractAsyncAssertionTestCase.php │ ├── AssertArrayEqualsTest.php │ ├── AssertCountEqualsTest.php │ ├── AssertFloatEqualsTest.php │ ├── AssertInstanceOfTest.php │ ├── AssertIntEqualsTest.php │ ├── AssertIsEmptyTest.php │ ├── AssertIsFalseTest.php │ ├── AssertIsNullTest.php │ ├── AssertIsTrueTest.php │ ├── AssertStringEqualsTest.php │ ├── AssertionMessage │ │ ├── BinaryOperandDetailsTest.php │ │ ├── BinaryOperandSummaryTest.php │ │ ├── CountEqualsMessageTest.php │ │ ├── EmptyUnaryOperandDetailsTest.php │ │ ├── EmptyUnaryOperandSummaryTest.php │ │ ├── FalseUnaryOperandDetailsTest.php │ │ ├── FalseUnaryOperandTest.php │ │ ├── InstanceOfSummaryTest.php │ │ ├── NullUnaryOperandDetailsTest.php │ │ ├── NullUnaryOperandTest.php │ │ ├── TrueUnaryOperandDetailsTest.php │ │ └── TrueUnaryOperandTest.php │ ├── AsyncAssertArrayEqualsTest.php │ ├── AsyncAssertCountEqualsTest.php │ ├── AsyncAssertFloatEqualsTest.php │ ├── AsyncAssertInstanceOfTest.php │ ├── AsyncAssertIntEqualsTest.php │ ├── AsyncAssertIsEmptyTest.php │ ├── AsyncAssertIsFalseTest.php │ ├── AsyncAssertIsNullTest.php │ ├── AsyncAssertIsTrueTest.php │ └── AsyncAssertStringEqualsTest.php ├── AsyncUnitApplicationTest.php ├── AsyncUnitAssertions.php ├── AsyncUnitConfigurationValidatorTest.php ├── AsyncUnitFrameworkRunnerTest.php ├── Constraint │ ├── TestCaseModelHasTestMethod.php │ ├── TestCaseModelHasTestMethodTest.php │ ├── TestSuiteModelHasTestCaseModel.php │ └── TestSuiteModelHasTestCaseModelTest.php ├── Context │ └── CustomAssertionContextTest.php ├── JsonConfigurationFactoryTest.php ├── MockBridge │ ├── MockeryMockBridgeTest.php │ └── ProphecyMockBridgeTest.php ├── Resources │ └── dummy_configs │ │ ├── bad_keys.json │ │ ├── empty_object.json │ │ ├── good_keys_bad_types.json │ │ ├── good_keys_but_extra.json │ │ ├── has_mock_bridge.json │ │ ├── has_plugins.json │ │ ├── minimally_valid.json │ │ ├── mock_bridge_empty_string.json │ │ ├── plugins_empty.json │ │ ├── plugins_empty_string.json │ │ ├── plugins_non_string.json │ │ ├── result_printer_empty.json │ │ ├── result_printer_null.json │ │ ├── test_dirs_empty.json │ │ ├── test_dirs_empty_string.json │ │ └── test_dirs_non_string.json ├── ShuffleRandomizerTest.php ├── StaticAnalysisParserTest.php ├── Statistics │ └── SummaryCalculatorTest.php ├── Stub │ ├── AssertNotTestCase.php │ ├── BarAssertionPlugin.php │ ├── CountableStub.php │ ├── CustomAssertionTestCase.php │ ├── FailingMockBridgeFactory.php │ ├── FailingMockBridgeStub.php │ ├── FailingTestCase.php │ ├── FooAssertionPlugin.php │ ├── MockAwareTestCase.php │ ├── MockBridgeStub.php │ └── TestConfiguration.php ├── TestCaseTest.php ├── TestSuiteErrorsTest.php ├── TestSuiteRunnerScaffolding.php ├── TestSuiteRunnerStatisticsTest.php ├── TestSuiteRunnerTest.php └── UsesAcmeSrc.php ├── phpunit.xml └── resources └── schema └── cli-config.json /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. ... 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Desktop (please complete the following information):** 24 | - OS: [e.g. Linux, macOS, etc] 25 | - PHP Version 26 | - Version [the tag or commit hash] 27 | 28 | **Additional context** 29 | Add any other context about the problem here. 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/php.yml: -------------------------------------------------------------------------------- 1 | name: 'Unit Tests' 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build-test: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v2 17 | - name: Composer 8 18 | uses: php-actions/composer@v5 19 | with: 20 | php_version: 8.2 21 | - name: PHP 8 tests 22 | uses: php-actions/phpunit@v2 23 | with: 24 | version: 9 25 | php_version: 8.2 26 | memory_limit: 1G 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | . 2 | .. 3 | build 4 | vendor 5 | .phpunit.cache 6 | .phpunit.result.cache -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | All Labrador packages adhere to the same [Code of Conduct] found in the [Labrador Governance repo]. 4 | 5 | [Code of Conduct]: https://github.com/labrador-kennel/governance/blob/master/CODE_OF_CONDUCT.md 6 | [Labrador Governance repo]: https://github.com/labrador-kennel/governance -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Please check out the [Contributing guide] at the [Labrador Governance repo] for more 4 | information on contributing source code to this repository. 5 | 6 | [Contributing guide]: https://github.com/labrador-kennel/governance/blob/master/CONTRIBUTING.md 7 | [Labrador Governance repo]: https://github.com/labrador-kennel/governance 8 | 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2021 Charles Sprayberry 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security 2 | 3 | All Labrador packages adhere to the same [Security Guidelines] found in the [Labrador Governance repo]. 4 | 5 | [Security Guidelines]: https://github.com/labrador-kennel/governance/blob/master/SECURITY.md 6 | [Labrador Governance repo]: https://github.com/labrador-kennel/governance 7 | -------------------------------------------------------------------------------- /acme_src/ErrorConditions/AfterAllAttributeOnNotTestCaseOrTestSuite/BadTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->intEquals(0, $this->testSuite()->getCounter()); 13 | } 14 | 15 | #[Test] 16 | public function ensureSuiteCounterAgain() : void { 17 | $this->assert()->intEquals(0, $this->testSuite()->getCounter()); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/AfterAllTestSuiteHook/MyTestSuite.php: -------------------------------------------------------------------------------- 1 | counter++; 17 | } 18 | 19 | public function getCounter() : int { 20 | return $this->counter; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/AfterAllTestSuiteHook/SecondTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->intEquals(0, $this->testSuite()->getCounter()); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/AfterEachTestSuiteHook/FirstTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->arrayEquals([], $this->testSuite()->getState()); 13 | } 14 | 15 | #[Test] 16 | public function testSomethingElse() : void { 17 | $this->assert()->arrayEquals([], $this->testSuite()->getState()); 18 | } 19 | 20 | #[Test] 21 | public function testItAgain() : void { 22 | $this->assert()->arrayEquals([], $this->testSuite()->getState()); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/AfterEachTestSuiteHook/MyTestSuite.php: -------------------------------------------------------------------------------- 1 | state[] = 'AsyncUnit'; 17 | } 18 | 19 | public function getState() : array { 20 | return $this->state; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/AfterEachTestSuiteHook/SecondTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->arrayEquals([], $this->testSuite()->getState()); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/AfterEachTestSuiteHook/ThirdTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->arrayEquals([], $this->testSuite()->getState()); 13 | } 14 | 15 | #[Test] 16 | public function testBar() : void { 17 | $this->assert()->arrayEquals([], $this->testSuite()->getState()); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/AfterEachTestTestSuiteHook/FirstTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->arrayEquals([], $this->testSuite()->getState()); 13 | } 14 | 15 | #[Test] 16 | public function testSomethingElse() : void { 17 | $this->assert()->arrayEquals([], $this->testSuite()->getState()); 18 | } 19 | 20 | #[Test] 21 | public function testItAgain() : void { 22 | $this->assert()->arrayEquals([], $this->testSuite()->getState()); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/AfterEachTestTestSuiteHook/MyTestSuite.php: -------------------------------------------------------------------------------- 1 | state[] = 'AsyncUnit'; 17 | } 18 | 19 | public function getState() : array { 20 | return $this->state; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/AfterEachTestTestSuiteHook/SecondTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->arrayEquals([], $this->testSuite()->getState()); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/AfterEachTestTestSuiteHook/ThirdTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->arrayEquals([], $this->testSuite()->getState()); 13 | } 14 | 15 | #[Test] 16 | public function testBar() : void { 17 | $this->assert()->arrayEquals([], $this->testSuite()->getState()); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/AnnotatedDefaultTestSuite/MyTestCase.php: -------------------------------------------------------------------------------- 1 | testSuiteName; 14 | } 15 | 16 | #[Test] 17 | public function ensureSomething() { 18 | $this->testSuiteName = $this->testSuite()->getName(); 19 | $this->assert()->stringEquals(MyTestSuite::class, $this->testSuiteName); 20 | } 21 | 22 | 23 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/AnnotatedDefaultTestSuite/MyTestSuite.php: -------------------------------------------------------------------------------- 1 | assert()->intEquals(1, $this->testSuite()->getCounter()); 13 | } 14 | 15 | #[Test] 16 | public function ensureSuiteCounterAgain() : void { 17 | $this->assert()->intEquals(1, $this->testSuite()->getCounter()); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/BeforeAllTestSuiteHook/MyTestSuite.php: -------------------------------------------------------------------------------- 1 | counter++; 17 | } 18 | 19 | public function getCounter() : int { 20 | return $this->counter; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/BeforeAllTestSuiteHook/SecondTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->intEquals(1, $this->testSuite()->getCounter()); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/BeforeEachTestSuiteHook/FirstTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('foo', 'foo'); 13 | } 14 | 15 | #[Test] 16 | public function testSomethingElse() : void { 17 | $this->assert()->stringEquals('bar', 'bar'); 18 | } 19 | 20 | /** 21 | * 22 | */ 23 | #[Test] 24 | public function testItAgain() : void { 25 | $this->assert()->stringEquals('baz', 'baz'); 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/BeforeEachTestSuiteHook/MyTestSuite.php: -------------------------------------------------------------------------------- 1 | state[] = 'AsyncUnit'; 17 | } 18 | 19 | public function getState() : array { 20 | return $this->state; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/BeforeEachTestSuiteHook/SecondTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->intEquals(1, 1); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/BeforeEachTestSuiteHook/ThirdTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->isNull(null); 13 | } 14 | 15 | #[Test] 16 | public function testBar() : void { 17 | $this->assert()->isTrue(true); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/BeforeEachTestTestSuiteHook/FirstTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->arrayEquals('foo', 'foo'); 13 | } 14 | 15 | #[Test] 16 | public function testSomethingElse() : void { 17 | $this->assert()->stringEquals('bar', 'bar'); 18 | } 19 | 20 | #[Test] 21 | public function testItAgain() : void { 22 | $this->assert()->stringEquals('baz', 'baz'); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/BeforeEachTestTestSuiteHook/MyTestSuite.php: -------------------------------------------------------------------------------- 1 | state[] = 'AsyncUnit'; 17 | } 18 | 19 | public function getState() : array { 20 | return $this->state; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/BeforeEachTestTestSuiteHook/SecondTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->intEquals(1, 1); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/BeforeEachTestTestSuiteHook/ThirdTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->isNull(null); 13 | } 14 | 15 | #[Test] 16 | public function testBar() : void { 17 | $this->assert()->isTrue(true); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/ExceptionThrowingTestSuiteAfterAll/FirstTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->isTrue(true); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/ExceptionThrowingTestSuiteAfterAll/MyTestSuite.php: -------------------------------------------------------------------------------- 1 | assert()->isTrue(true); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/ExceptionThrowingTestSuiteBeforeAll/MyTestSuite.php: -------------------------------------------------------------------------------- 1 | get('state'); 17 | } 18 | 19 | #[Test] 20 | public function checkState() { 21 | $this->assert()->isNull(self::$state); 22 | } 23 | 24 | public function getState() : ?string { 25 | return self::$state; 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/TestCaseAfterAllHasTestSuiteState/MyTestSuite.php: -------------------------------------------------------------------------------- 1 | set('state', 'AsyncUnit'); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/TestCaseBeforeAllHasTestSuiteState/MyTestCase.php: -------------------------------------------------------------------------------- 1 | get('state'); 17 | } 18 | 19 | #[Test] 20 | public function checkState() { 21 | $this->assert()->stringEquals('AsyncUnit', self::$state); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/TestCaseBeforeAllHasTestSuiteState/MyTestSuite.php: -------------------------------------------------------------------------------- 1 | set('state', 'AsyncUnit'); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/TestCaseDefinedAndImplicitDefaultTestSuite/FirstTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('AsyncUnit', 'AsyncUnit'); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/TestCaseDefinedAndImplicitDefaultTestSuite/MyTestSuite.php: -------------------------------------------------------------------------------- 1 | assert()->isFalse(false); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/TestCaseDefinesTestSuite/FirstTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->intEquals(42, 42); 15 | } 16 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/TestCaseDefinesTestSuite/MyFirstTestSuite.php: -------------------------------------------------------------------------------- 1 | asyncAssert()->isNull(new Success(null)); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/TestCaseDefinesTestSuite/ThirdTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('AsyncUnit', 'AsyncUnit'); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/TestSuiteDefinesNamespaceToAttach/HasExplicitTestSuite/MyTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->isFalse(false); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/TestSuiteDefinesNamespaceToAttach/HasImplicitTestSuite/MyTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->isTrue(true); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/TestSuiteDefinesNamespaceToAttach/MyTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('AsyncUnit', 'AsyncUnit'); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/TestSuiteDefinesNamespaceToAttach/MyTestSuite.php: -------------------------------------------------------------------------------- 1 | assert()->isTrue(true); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/TestSuiteStateBeforeAll/FirstTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('bar', $this->testSuite()->get('foo')); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ExplicitTestSuite/TestSuiteStateBeforeAll/MyTestSuite.php: -------------------------------------------------------------------------------- 1 | set('foo', 'bar'); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/CustomAssertions/MyTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->theCustomAssertion('foo', 'bar'); 14 | yield $this->asyncAssert()->theCustomAssertion('foo', new Success('bar')); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/ExceptionThrowingAfterAll/MyTestCase.php: -------------------------------------------------------------------------------- 1 | afterHookCalled = true; 21 | } 22 | 23 | public function getAfterHookCalled() { 24 | return $this->afterHookCalled; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/ExtendedTestCases/AbstractFourthTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->isNull(null); 12 | $this->assert()->isFalse(false); 13 | $this->assert()->isTrue(true); 14 | $this->assert()->stringEquals('AsyncUnit', 'AsyncUnit'); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/ExtendedTestCases/AbstractSecondTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->intEquals(42, 42); 15 | yield $this->asyncAssert()->isFalse(new Success(false)); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/ExtendedTestCases/FifthTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->isFalse(false); 12 | $this->assert()->not()->stringEquals('AsyncUnit', 'PHPUnit'); 13 | $this->assert()->intEquals(1, 1); 14 | $this->assert()->floatEquals(3.14, 3.14); 15 | $this->assert()->isTrue(false); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/ExtendedTestCases/FirstTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('foo', 'foo'); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/ExtendedTestCases/ThirdTestCase.php: -------------------------------------------------------------------------------- 1 | asyncAssert()->arrayEquals([1,2,3], new Success([1,2,3])); 13 | $this->assert()->stringEquals('bar', 'bar'); 14 | $this->assert()->isNull(null); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/FailedAssertion/MyTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('foo', 'bar'); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/FailedNotAssertion/MyTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->not()->stringEquals('foo', 'foo'); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/HandleNonPhpFiles/MyTestCase.php: -------------------------------------------------------------------------------- 1 | asyncAssert()->isNull(new Success(null)); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/HandleNonPhpFiles/something-else.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Something 4 | 5 | -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/HandleNonPhpFiles/something.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "bar" 3 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/HasAssertionPlugin/MyCustomAssertionPlugin.php: -------------------------------------------------------------------------------- 1 | registerAssertion('myOtherCustomAssertion', function() { 17 | return new AssertIsTrue(true); 18 | }); 19 | return new Success(); 20 | } 21 | 22 | public function __toString() { 23 | return ''; 24 | } 25 | 26 | public function count() { 27 | return 0; 28 | } 29 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/HasAssertionPlugin/MyTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->myOtherCustomAssertion(); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/HasDataProvider/MyTestCase.php: -------------------------------------------------------------------------------- 1 | counter++; 25 | $this->assert()->stringEquals($expected, $actual); 26 | } 27 | 28 | public function getCounter() : int { 29 | return $this->counter; 30 | } 31 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/HasNotTestCaseObject/MyTestCase.php: -------------------------------------------------------------------------------- 1 | on(Events::TEST_PROCESSED, function(TestProcessedEvent $event) use($output) { 15 | yield $output->write($event->getTarget()->getTestCase()::class . "\n"); 16 | yield $output->write($event->getTarget()->getTestMethod() . "\n"); 17 | }); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/HasResultPrinterPlugin/MyTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('foo', 'foo'); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/HasSingleAfterAllHook/MyTestCase.php: -------------------------------------------------------------------------------- 1 | objectData[] = 'ensureSomething'; 22 | } 23 | 24 | #[Test] 25 | public function ensureSomethingTwice() { 26 | $this->objectData[] = 'ensureSomethingTwice'; 27 | } 28 | 29 | public function getCombinedData() : array { 30 | return array_merge([], self::$classData, $this->objectData); 31 | } 32 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/HasSingleAfterEachHook/MyTestCase.php: -------------------------------------------------------------------------------- 1 | data[] = 'afterEach'; 16 | } 17 | 18 | #[Test] 19 | public function ensureSomething() { 20 | $this->data[] = 'ensureSomething'; 21 | } 22 | 23 | #[Test] 24 | public function ensureSomethingTwice() { 25 | $this->data[] = 'ensureSomethingTwice'; 26 | } 27 | 28 | public function getData() : array { 29 | return $this->data; 30 | } 31 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/HasSingleBeforeEachHook/MyTestCase.php: -------------------------------------------------------------------------------- 1 | data[] = 'beforeEach'; 17 | } 18 | 19 | #[Test] 20 | public function ensureSomething() { 21 | $this->data[] = 'ensureSomething'; 22 | } 23 | 24 | #[Test] 25 | public function ensureSomethingTwice() { 26 | $this->data[] = 'ensureSomethingTwice'; 27 | } 28 | 29 | public function getData() : array { 30 | return $this->data; 31 | } 32 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/KitchenSink/FirstTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->countEquals(3, [1, 2, 3]); 17 | } 18 | 19 | #[Test] 20 | public function testTwo() { 21 | yield $this->asyncAssert()->countEquals(4, new Success(['a', 'b', 'c', 'd'])); 22 | } 23 | 24 | #[Test] 25 | #[Disabled] 26 | public function disabledTest() { 27 | throw new \RuntimeException('We should not run this'); 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/KitchenSink/FirstTestSuite.php: -------------------------------------------------------------------------------- 1 | asyncAssert()->stringEquals($a, new Success($b)); 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/KitchenSink/SecondTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->instanceOf(TestCase::class, $this); 17 | yield $this->asyncAssert()->instanceOf(TestCase::class, new Success($this)); 18 | } 19 | 20 | #[Test] 21 | #[Disabled] 22 | public function checkTwoDisabled() { 23 | throw new \RuntimeException('We should not run this'); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/KitchenSink/WhatAbout/BilboTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('Frodo', $this->testSuite()->get('bestHobbit')); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/KitchenSink/WhatAbout/PotatoTestSuite.php: -------------------------------------------------------------------------------- 1 | set('bestHobbit', 'Samwise'); 13 | } 14 | 15 | 16 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/KitchenSink/WhatAbout/SamwiseTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('Samwise', $this->testSuite()->get('bestHobbit')); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/MockeryTestNoAssertion/MyTestCase.php: -------------------------------------------------------------------------------- 1 | mocks()->createMock(Application::class); 18 | 19 | $mock->expects()->start()->andReturn(new Success()); 20 | 21 | yield $mock->start(); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/MultipleBeforeAllHooks/FirstTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals(self::class, self::$state); 21 | } 22 | 23 | public function getState() : string { 24 | return self::$state; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/MultipleBeforeAllHooks/SecondTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals(self::class, self::$state); 21 | } 22 | 23 | public function getState() : string { 24 | return self::$state; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/MultipleTestCase/BarTestCase.php: -------------------------------------------------------------------------------- 1 | testInvoked = true; 19 | } 20 | 21 | public function getName() : string { 22 | return self::class; 23 | } 24 | 25 | public function getTestInvoked() : bool { 26 | return $this->testInvoked; 27 | } 28 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/MultipleTestCase/BazTestCase.php: -------------------------------------------------------------------------------- 1 | testInvoked = true; 15 | } 16 | 17 | public function getName() : string { 18 | return self::class; 19 | } 20 | 21 | public function getTestInvoked() : bool { 22 | return $this->testInvoked; 23 | } 24 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/MultipleTestCase/FooTestCase.php: -------------------------------------------------------------------------------- 1 | testCounter++; 21 | }); 22 | } 23 | 24 | #[Test] 25 | public function ensureSomethingTwice() { 26 | return call(function() { 27 | $this->testCounter++; 28 | }); 29 | } 30 | 31 | public function getTestCounter() { 32 | return $this->testCounter; 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/MultipleTestsKnownDuration/FirstTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->arrayEquals([1, 2, 3], [1, 2, 3]); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/MultipleTestsKnownDuration/SecondTestCase.php: -------------------------------------------------------------------------------- 1 | asyncAssert()->isEmpty(new Success([])); 18 | } 19 | 20 | #[Test] 21 | public function checkTwo() { 22 | yield new Delayed(100); 23 | $this->assert()->isTrue(true); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/MultipleTestsKnownDuration/ThirdTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->floatEquals(3.14, 3.14); 16 | } 17 | 18 | #[Test] 19 | public function checkTwo() { 20 | yield new Delayed(100); 21 | yield $this->asyncAssert()->stringEquals('AsyncUnit', new Success('AsyncUnit')); 22 | } 23 | 24 | #[Test] 25 | public function checkThree() { 26 | yield new Delayed(100); 27 | $this->assert()->countEquals(2, ['a', 0]); 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/NoAssertions/MyTestCase.php: -------------------------------------------------------------------------------- 1 | createdMock = $this->mocks()->createMock(Application::class); 16 | $this->assert()->not()->isNull($this->createdMock); 17 | } 18 | 19 | public function getCreatedMock() : ?object { 20 | return $this->createdMock; 21 | } 22 | 23 | 24 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/SingleTest/MyTestCase.php: -------------------------------------------------------------------------------- 1 | testInvoked = true; 19 | $this->assert()->stringEquals('foo', 'foo'); 20 | } 21 | 22 | public function getTestInvoked() : bool { 23 | return $this->testInvoked; 24 | } 25 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/SingleTest/async-unit.json: -------------------------------------------------------------------------------- 1 | { 2 | "testDirs": ["./acme_src/ImplicitDefaultTestSuite/SingleTest"], 3 | "resultPrinter": "Cspray\\Labrador\\AsyncUnitCli\\TerminalResultPrinter" 4 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/SingleTestAsyncAssertion/MyTestCase.php: -------------------------------------------------------------------------------- 1 | asyncAssert()->stringEquals('foo', new Success('foo')); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/SingleTestDisabled/MyTestCase.php: -------------------------------------------------------------------------------- 1 | data[] = '1'; 17 | } 18 | 19 | #[Test] 20 | public function skippedTwo() { 21 | $this->data[] = '2'; 22 | } 23 | 24 | #[Test] 25 | public function skippedThree() { 26 | $this->data[] = '3'; 27 | } 28 | 29 | public function getData() : array { 30 | return $this->data; 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/TestCaseDisabledCustomMessage/MyTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('AsyncUnit', 'AsyncUnit'); 14 | } 15 | 16 | #[Test] 17 | #[Disabled] 18 | public function skippedTest() { 19 | throw new \RuntimeException('We should not actually execute this function'); 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/TestDisabledCustomMessage/MyTestCase.php: -------------------------------------------------------------------------------- 1 | asyncAssert()->not()->floatEquals(3.14, new Success(3.14)); 15 | } 16 | 17 | #[Test] 18 | public function testIsTrue() { 19 | yield $this->asyncAssert()->isTrue(new Success(true)); 20 | } 21 | 22 | #[Test] 23 | #[Disabled] 24 | public function testIsDisabled() { 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/TestExpectsExceptionDoesNotThrow/MyTestCase.php: -------------------------------------------------------------------------------- 1 | expect()->exception(InvalidArgumentException::class); 14 | 15 | $this->assert()->isEmpty([]); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/TestExpectsExceptionMessage/MyTestCase.php: -------------------------------------------------------------------------------- 1 | expect()->exception(InvalidArgumentException::class); 14 | $this->expect()->exceptionMessage('This is the message that I expect'); 15 | 16 | throw new InvalidArgumentException('This is the message that I expect'); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/TestExpectsExceptionOnly/MyTestCase.php: -------------------------------------------------------------------------------- 1 | expect()->exception(Exception::class); 15 | 16 | throw new InvalidArgumentException('The message does not matter'); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/TestExpectsExceptionWrongMessage/MyTestCase.php: -------------------------------------------------------------------------------- 1 | expect()->exception(InvalidArgumentException::class); 14 | $this->expect()->exceptionMessage('This is the message that I expect'); 15 | 16 | throw new InvalidArgumentException('This is NOT the message that I expect'); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/TestExpectsExceptionWrongType/MyTestCase.php: -------------------------------------------------------------------------------- 1 | expect()->exception(InvalidArgumentException::class); 15 | 16 | throw new InvalidStateException(); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/TestExpectsNoAssertions/MyTestCase.php: -------------------------------------------------------------------------------- 1 | expect()->noAssertions(); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/TestExpectsNoAssertionsAssertMade/MyTestCase.php: -------------------------------------------------------------------------------- 1 | expect()->noAssertions(); 13 | $this->assert()->isNull(null); 14 | $this->assert()->isTrue(true); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/TestExpectsNoAsyncAssertionsAssertMade/MyTestCase.php: -------------------------------------------------------------------------------- 1 | expect()->noAssertions(); 14 | 15 | yield $this->asyncAssert()->isNull(new Success(null)); 16 | yield $this->asyncAssert()->isEmpty(new Success([])); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/TestFailedExceptionThrowingTest/MyTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('something', 'something'); 13 | echo __FUNCTION__; 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/TestHasTimeout/MyTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('a', 'a'); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/TestKnownRunTime/MyTestCase.php: -------------------------------------------------------------------------------- 1 | asyncAssert()->floatEquals(3.14, new Success(3.14)); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/WithAsyncUnitConfig/async-unit.json: -------------------------------------------------------------------------------- 1 | { 2 | "testDirs": ["tests"] 3 | } 4 | -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/WithAsyncUnitConfig/tests/Bar/FooTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->intEquals(1, 1); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /acme_src/ImplicitDefaultTestSuite/WithAsyncUnitConfig/tests/Foo/BarTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->not()->stringEquals('foo', 'bar'); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /bin/asyncunit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/php 2 | run(); 31 | -------------------------------------------------------------------------------- /cli_src/Command/AbstractCommand.php: -------------------------------------------------------------------------------- 1 | getCommandName()); 14 | } 15 | 16 | protected function confirm(InputInterface $input, OutputInterface $output, string $question, bool $default = false) : bool { 17 | stream_set_blocking(STDIN, true); 18 | $answerGuide = $default ? '(Y/n)' : '(y/N)'; 19 | $confirmationQuestion = new ConfirmationQuestion(sprintf("%s %s ", $question, $answerGuide), $default); 20 | $answer = $this->getHelper('question')->ask($input, $output, $confirmationQuestion); 21 | stream_set_blocking(STDIN, false); 22 | return $answer; 23 | } 24 | 25 | abstract protected function getCommandName() : string; 26 | 27 | } -------------------------------------------------------------------------------- /cli_src/Exception/Exception.php: -------------------------------------------------------------------------------- 1 | 12 | --EXPECTF-- 13 | AsyncUnit v%s - %s 14 | 15 | Runtime: PHP 8.%d.%d 16 | 17 | %sE%s 18 | 19 | Time: %d:%f, Memory: %d.%d MB 20 | 21 | There was 1 error: 22 | 23 | 1) Acme\DemoSuites\ImplicitDefaultTestSuite\ExceptionThrowingTest\MyTestCase::throwsException 24 | An unexpected exception of type "Exception" with code 0 and message "Test failure" was thrown from #[Test] Acme\DemoSuites\ImplicitDefaultTestSuite\ExceptionThrowingTest\MyTestCase::throwsException 25 | 26 | %a 27 | 28 | ERRORS 29 | Tests: 1, Errors: 1, Assertions: 0, Async Assertions: 0 30 | 31 | Status: 0 -------------------------------------------------------------------------------- /cli_test/Integration/helpers.php: -------------------------------------------------------------------------------- 1 | 12 | --EXPECTF-- 13 | AsyncUnit v%s - %s 14 | 15 | Runtime: PHP 8.%d.%d 16 | 17 | %s.%s 18 | 19 | Time: %d:%f, Memory: %d.%d MB 20 | 21 | OK! 22 | Tests: 1, Assertions: 1, Async Assertions: 0 23 | 24 | Status: 0 -------------------------------------------------------------------------------- /examples/blog_introduction_src/ExampleFour/MyTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('AsyncUnit', 'AsyncUnit'); 24 | } 25 | 26 | #[Test] 27 | public function checkAsyncIo() : Generator { 28 | yield $this->asyncAssert()->stringEquals('AsyncUnit', getAsyncString()); 29 | } 30 | } -------------------------------------------------------------------------------- /examples/blog_introduction_src/ExampleOne/MyTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('AsyncUnit', 'AsyncUnit'); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /examples/blog_introduction_src/ExampleTwo/MyTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('AsyncUnit', 'PHPUnit'); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /examples/custom_assertion_src/MyAssertion.php: -------------------------------------------------------------------------------- 1 | actual); 14 | return $assert->assert(); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /examples/custom_assertion_src/MyAssertionPlugin.php: -------------------------------------------------------------------------------- 1 | registerAssertion('isAsyncUnitString', fn($actual) => new MyAssertion($actual)); 15 | }); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /examples/custom_assertion_src/TestCaseUsesMyAssertion.php: -------------------------------------------------------------------------------- 1 | assert()->isAsyncUnitString('AsyncUnit'); 13 | } 14 | 15 | #[Test] 16 | public function ensurePhpUnitStringNotEquals() { 17 | $this->assert()->not()->isAsyncUnitString('PHPUnit'); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AbstractAssertion.php: -------------------------------------------------------------------------------- 1 | expected === $this->actual ? 'validAssertion' : 'invalidAssertion'; 15 | return AssertionResultFactory::$factoryMethod($this->getSummary(), $this->getDetails()); 16 | } 17 | 18 | abstract protected function getSummary() : AssertionMessage; 19 | 20 | abstract protected function getDetails() : AssertionMessage; 21 | 22 | protected function getExpected() : mixed { 23 | return $this->expected; 24 | } 25 | 26 | protected function getActual() : mixed { 27 | return $this->actual; 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AbstractAsyncAssertion.php: -------------------------------------------------------------------------------- 1 | $this->actual); 19 | $assertion = $this->getAssertion($actual); 20 | return $assertion->assert(); 21 | }); 22 | } 23 | 24 | abstract protected function getAssertion(mixed $resolvedActual) : Assertion; 25 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AssertArrayEquals.php: -------------------------------------------------------------------------------- 1 | getExpected(), $this->getActual()); 13 | } 14 | 15 | protected function getDetails() : AssertionMessage { 16 | return new BinaryOperandSummary($this->getExpected(), $this->getActual()); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AssertCountEquals.php: -------------------------------------------------------------------------------- 1 | actual) === $this->expected ? 'validAssertion' : 'invalidAssertion'; 16 | return AssertionResultFactory::$factoryMethod( 17 | $this->getSummary(), 18 | $this->getDetails() 19 | ); 20 | } 21 | 22 | private function getSummary() : AssertionMessage { 23 | return new Assertion\AssertionMessage\CountEqualsMessage($this->expected, $this->actual); 24 | } 25 | 26 | private function getDetails() : AssertionMessage { 27 | return new Assertion\AssertionMessage\CountEqualsMessage($this->expected, $this->actual); 28 | } 29 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AssertFloatEquals.php: -------------------------------------------------------------------------------- 1 | getExpected(), $this->getActual()); 12 | } 13 | 14 | protected function getDetails() : AssertionMessage { 15 | return new BinaryOperandSummary($this->getExpected(), $this->getActual()); 16 | } 17 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AssertIntEquals.php: -------------------------------------------------------------------------------- 1 | getExpected(), $this->getActual()); 13 | } 14 | 15 | protected function getDetails() : AssertionMessage { 16 | return new BinaryOperandSummary($this->getExpected(), $this->getActual()); 17 | } 18 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AssertIsEmpty.php: -------------------------------------------------------------------------------- 1 | actual) ? 'validAssertion' : 'invalidAssertion'; 14 | return AssertionResultFactory::$factoryMethod( 15 | new Assertion\AssertionMessage\EmptyUnaryOperandSummary($this->actual), 16 | new Assertion\AssertionMessage\EmptyUnaryOperandDetails($this->actual) 17 | ); 18 | } 19 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AssertIsFalse.php: -------------------------------------------------------------------------------- 1 | getActual()); 18 | } 19 | 20 | protected function getDetails() : AssertionMessage { 21 | return new FalseUnaryOperandDetails($this->getActual()); 22 | } 23 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AssertIsNull.php: -------------------------------------------------------------------------------- 1 | getActual()); 17 | } 18 | 19 | protected function getDetails() : AssertionMessage { 20 | return new NullUnaryOperandDetails($this->getActual()); 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AssertIsTrue.php: -------------------------------------------------------------------------------- 1 | getActual()); 17 | } 18 | 19 | protected function getDetails() : AssertionMessage { 20 | return new TrueUnaryOperandDetails($this->getActual()); 21 | } 22 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AssertStringEquals.php: -------------------------------------------------------------------------------- 1 | getExpected(), $this->getActual()); 13 | } 14 | 15 | protected function getDetails() : AssertionMessage { 16 | return new BinaryOperandDetails($this->getExpected(), $this->getActual()); 17 | } 18 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AssertionMessage/BinaryOperandDetails.php: -------------------------------------------------------------------------------- 1 | actual, true), 15 | var_export($this->expected, true) 16 | ); 17 | } 18 | 19 | public function toNotString() : string { 20 | return sprintf( 21 | 'comparing actual value %s does not equal %s', 22 | var_export($this->actual, true), 23 | var_export($this->expected, true) 24 | ); 25 | } 26 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AssertionMessage/BinaryOperandSummary.php: -------------------------------------------------------------------------------- 1 | expected)), 15 | strtolower(gettype($this->actual)) 16 | ); 17 | } 18 | 19 | public function toNotString() : string { 20 | return sprintf( 21 | 'asserting type "%s" does not equal type "%s"', 22 | strtolower(gettype($this->expected)), 23 | strtolower(gettype($this->actual)) 24 | ); 25 | } 26 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AssertionMessage/CountEqualsMessage.php: -------------------------------------------------------------------------------- 1 | actual) ? 'array' : $this->actual::class, 16 | count($this->actual), 17 | $this->expected 18 | ); 19 | } 20 | 21 | public function toNotString() : string { 22 | return sprintf( 23 | 'asserting %s with count of %d does not equal expected count of %d', 24 | is_array($this->actual) ? 'array': $this->actual::class, 25 | count($this->actual), 26 | $this->expected 27 | ); 28 | } 29 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AssertionMessage/EmptyUnaryOperandDetails.php: -------------------------------------------------------------------------------- 1 | actual::class, 18 | is_object($this->expected) ? get_class($this->expected) : $this->expected 19 | ); 20 | } 21 | 22 | public function toNotString() : string { 23 | return sprintf( 24 | 'asserting object with type "%s" is not an instanceof %s', 25 | $this->actual::class, 26 | is_object($this->expected) ? get_class($this->expected) : $this->expected 27 | ); 28 | } 29 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AssertionMessage/NullUnaryOperandDetails.php: -------------------------------------------------------------------------------- 1 | actual, true); 13 | if (is_null($this->actual)) { 14 | $details = 'null'; 15 | } 16 | return sprintf( 17 | 'comparing %s is %s', 18 | $details, 19 | $this->getExpectedDescriptor() 20 | ); 21 | } 22 | 23 | public function toNotString() : string { 24 | $details = var_export($this->actual, true); 25 | if (is_null($this->actual)) { 26 | $details = 'null'; 27 | } 28 | return sprintf( 29 | 'comparing %s is not %s', 30 | $details, 31 | $this->getExpectedDescriptor() 32 | ); 33 | } 34 | 35 | abstract protected function getExpectedDescriptor() : string; 36 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AssertionMessage/UnaryOperandSummary.php: -------------------------------------------------------------------------------- 1 | actual)), $this->getExpectedDescriptor()); 13 | } 14 | 15 | public function toNotString() : string { 16 | return sprintf('asserting type "%s" is not %s', strtolower(gettype($this->actual)), $this->getExpectedDescriptor()); 17 | } 18 | 19 | abstract protected function getExpectedDescriptor() : string; 20 | 21 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AsyncAssertArrayEquals.php: -------------------------------------------------------------------------------- 1 | expected, $resolvedActual); 19 | } 20 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AsyncAssertCountEquals.php: -------------------------------------------------------------------------------- 1 | expected, $resolvedActual); 18 | } 19 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AsyncAssertFloatEquals.php: -------------------------------------------------------------------------------- 1 | expected, $actual); 18 | } 19 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AsyncAssertInstanceOf.php: -------------------------------------------------------------------------------- 1 | expected, $resolvedActual); 26 | } 27 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AsyncAssertIntEquals.php: -------------------------------------------------------------------------------- 1 | expected, $actual); 18 | } 19 | } -------------------------------------------------------------------------------- /framework_src/Assertion/AsyncAssertIsEmpty.php: -------------------------------------------------------------------------------- 1 | expected, $resolvedActual); 20 | } 21 | } -------------------------------------------------------------------------------- /framework_src/AssertionMessage.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | public function make(string $path) : Promise; 16 | 17 | } -------------------------------------------------------------------------------- /framework_src/ConfigurationValidationResults.php: -------------------------------------------------------------------------------- 1 | validationErrors); 13 | } 14 | 15 | public function getValidationErrors() : array { 16 | return $this->validationErrors; 17 | } 18 | 19 | 20 | } -------------------------------------------------------------------------------- /framework_src/ConfigurationValidator.php: -------------------------------------------------------------------------------- 1 | lastAssertionFile = $file; 16 | } 17 | 18 | public function getLastAssertionFile() : ?string { 19 | return $this->lastAssertionFile; 20 | } 21 | 22 | public function setLastAssertionLine(int $line) : void { 23 | $this->lastAssertionLine = $line; 24 | } 25 | 26 | public function getLastAssertionLine() : int { 27 | return $this->lastAssertionLine; 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /framework_src/Context/TestExpector.php: -------------------------------------------------------------------------------- 1 | detailedMessage; 18 | } 19 | 20 | public function getAssertionFailureFile() : string { 21 | return $this->assertionFailureFile; 22 | } 23 | 24 | public function getAssertionFailureLine() : int { 25 | return $this->assertionFailureLine; 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /framework_src/Exception/Exception.php: -------------------------------------------------------------------------------- 1 | isDisabled; 14 | } 15 | 16 | public function markDisabled(string $disabledReason = null) : void { 17 | $this->disabledReason = $disabledReason; 18 | $this->isDisabled = true; 19 | } 20 | 21 | public function getDisabledReason() : ?string { 22 | return $this->disabledReason; 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /framework_src/Model/CanHaveTimeoutTrait.php: -------------------------------------------------------------------------------- 1 | timeout = $timeout; 11 | } 12 | 13 | public function getTimeout() : ?int { 14 | return $this->timeout; 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /framework_src/Model/HookAware.php: -------------------------------------------------------------------------------- 1 | hooks[$hookType->toString()] ?? []; 19 | } 20 | 21 | public function addHook(HookModel $hook) : void { 22 | if (!isset($this->hooks[$hook->getType()->toString()])) { 23 | $this->hooks[$hook->getType()->toString()] = []; 24 | } 25 | $this->hooks[$hook->getType()->toString()][] = $hook; 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /framework_src/Model/MethodModelTrait.php: -------------------------------------------------------------------------------- 1 | class; 14 | } 15 | 16 | public function getMethod() : string { 17 | return $this->method; 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /framework_src/Model/PluginModel.php: -------------------------------------------------------------------------------- 1 | pluginClass; 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /framework_src/Model/TestModel.php: -------------------------------------------------------------------------------- 1 | class = $class; 16 | return $new; 17 | } 18 | 19 | public function getDataProvider() : ?string { 20 | return $this->dataProvider; 21 | } 22 | 23 | public function setDataProvider(string $dataProvider) : void { 24 | $this->dataProvider = $dataProvider; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /framework_src/Model/TestSuiteModel.php: -------------------------------------------------------------------------------- 1 | class; 20 | } 21 | 22 | public function isDefaultTestSuite() : bool { 23 | return $this->isDefaultTestSuite; 24 | } 25 | 26 | /** 27 | * @return TestCaseModel[] 28 | */ 29 | public function getTestCaseModels() : array { 30 | return $this->testCaseModels; 31 | } 32 | 33 | public function addTestCaseModel(TestCaseModel $testCaseModel) : void { 34 | $this->testCaseModels[] = $testCaseModel; 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /framework_src/NullRandomizer.php: -------------------------------------------------------------------------------- 1 | attrs as $attribute) { 16 | if ($attribute->name->toString() === $attributeType) { 17 | return $attribute; 18 | } 19 | } 20 | } 21 | 22 | return null; 23 | } 24 | } -------------------------------------------------------------------------------- /framework_src/Parser/Parser.php: -------------------------------------------------------------------------------- 1 | 12 | */ 13 | public function parse(array|string $dirs) : Promise; 14 | 15 | } -------------------------------------------------------------------------------- /framework_src/Prototype/AfterEachPrototype.php: -------------------------------------------------------------------------------- 1 | injector = $injector; 13 | } 14 | 15 | public function make(string $mockBridgeClass): MockBridge { 16 | return $this->injector->make($mockBridgeClass); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /framework_src/TestState.php: -------------------------------------------------------------------------------- 1 | data[$key] = $value; 21 | } 22 | 23 | final public function get(string $key) : mixed { 24 | return $this->data[$key] ?? null; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /framework_test/Assertion/AssertIsNullTest.php: -------------------------------------------------------------------------------- 1 | assertThat($actual, $constraint); 15 | } 16 | 17 | public function assertTestMethodBelongsToTestCase(string $methodSignature, TestCaseModel $actual) { 18 | [$testClass, $method] = explode('::', $methodSignature); 19 | $constraint = new TestCaseModelHasTestMethod($testClass, $method); 20 | $this->assertThat($actual, $constraint); 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/bad_keys.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "bar", 3 | "bar": "baz" 4 | } -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/empty_object.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/good_keys_bad_types.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://labrador-kennel.io/dev/async-unit/schema/cli", 3 | "testDirs": "something", 4 | "plugins": "something" 5 | } -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/good_keys_but_extra.json: -------------------------------------------------------------------------------- 1 | { 2 | "testDirs": ["foo"], 3 | "plugins": [], 4 | "something": "else" 5 | } -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/has_mock_bridge.json: -------------------------------------------------------------------------------- 1 | { 2 | "testDirs": ["."], 3 | "resultPrinter": "Cspray\\Labrador\\AsyncUnitCli\\DefaultResultPrinter", 4 | "mockBridge": "Cspray\\Labrador\\AsyncUnit\\MockBridge\\MockeryMockBridge" 5 | } 6 | -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/has_plugins.json: -------------------------------------------------------------------------------- 1 | { 2 | "testDirs": ["."], 3 | "resultPrinter": "Cspray\\Labrador\\AsyncUnitCli\\DefaultResultPrinter", 4 | "plugins": ["FooBar"] 5 | } -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/minimally_valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "testDirs": ["."], 3 | "resultPrinter": "Cspray\\Labrador\\AsyncUnitCli\\TerminalResultPrinter", 4 | "mockBridge": "Cspray\\Labrador\\AsyncUnit\\Stub\\MockBridgeStub" 5 | } -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/mock_bridge_empty_string.json: -------------------------------------------------------------------------------- 1 | { 2 | "testDirs": ["."], 3 | "resultPrinter": "SomeClass", 4 | "mockBridge": "" 5 | } -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/plugins_empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "testDirs": ["foo"], 3 | "plugins": [] 4 | } -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/plugins_empty_string.json: -------------------------------------------------------------------------------- 1 | { 2 | "testDirs": ["foo"], 3 | "plugins": ["FooBar", ""] 4 | } -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/plugins_non_string.json: -------------------------------------------------------------------------------- 1 | { 2 | "testDirs": ["foo"], 3 | "plugins": [1, 3.4, []] 4 | } -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/result_printer_empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "testDirs": ["."], 3 | "resultPrinter": "" 4 | } -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/result_printer_null.json: -------------------------------------------------------------------------------- 1 | { 2 | "testDirs": ["."], 3 | "resultPrinter": null 4 | } -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/test_dirs_empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "testDirs": [], 3 | "plugins": [] 4 | } -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/test_dirs_empty_string.json: -------------------------------------------------------------------------------- 1 | { 2 | "testDirs": ["foo", ""], 3 | "plugins": [] 4 | } -------------------------------------------------------------------------------- /framework_test/Resources/dummy_configs/test_dirs_non_string.json: -------------------------------------------------------------------------------- 1 | { 2 | "testDirs": [1], 3 | "plugins": [] 4 | } -------------------------------------------------------------------------------- /framework_test/ShuffleRandomizerTest.php: -------------------------------------------------------------------------------- 1 | randomize(['d', 'b', 'c', 'a']); 14 | 15 | $this->assertEqualsCanonicalizing($expected, $actual); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /framework_test/Stub/AssertNotTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->not()->stringEquals('foo', 'bar'); 12 | } 13 | 14 | public function doFailingNotAssertions() { 15 | $this->assert()->not()->stringEquals('foo', 'foo'); 16 | } 17 | 18 | public function doBothAssertions() { 19 | $this->assert()->stringEquals('bar', 'bar'); 20 | $this->assert()->not()->stringEquals('foo', 'bar'); 21 | $this->assert()->stringEquals('foo', 'foo'); 22 | } 23 | 24 | public function doAsyncNotAssertion() { 25 | yield $this->asyncAssert()->not()->intEquals(1, new Success(2)); 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /framework_test/Stub/BarAssertionPlugin.php: -------------------------------------------------------------------------------- 1 | context = $customAssertionContext; 16 | return new Success(); 17 | } 18 | 19 | public function getCustomAssertionContext() : ?CustomAssertionContext { 20 | return $this->context; 21 | } 22 | } -------------------------------------------------------------------------------- /framework_test/Stub/CountableStub.php: -------------------------------------------------------------------------------- 1 | count = $count; 11 | } 12 | 13 | public function count() : int { 14 | return $this->count; 15 | } 16 | } -------------------------------------------------------------------------------- /framework_test/Stub/CustomAssertionTestCase.php: -------------------------------------------------------------------------------- 1 | assert()->myCustomAssertion(1, 2, 3); 11 | } 12 | 13 | public function doCustomAsyncAssertion() { 14 | yield $this->asyncAssert()->myCustomAssertion(1, 2, 3); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /framework_test/Stub/FailingMockBridgeFactory.php: -------------------------------------------------------------------------------- 1 | assert()->stringEquals('foo', 'bar'); 12 | } 13 | 14 | public function doAsyncFailure() { 15 | yield $this->asyncAssert()->stringEquals('foo', new Success('bar')); 16 | } 17 | 18 | public function doFailureWithCustomMessage() { 19 | $this->assert()->stringEquals('foo', 'bar', 'my custom message'); 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /framework_test/Stub/FooAssertionPlugin.php: -------------------------------------------------------------------------------- 1 | context = $customAssertionContext; 16 | return new Success(); 17 | } 18 | 19 | public function getCustomAssertionContext() : ?CustomAssertionContext { 20 | return $this->context; 21 | } 22 | } -------------------------------------------------------------------------------- /framework_test/Stub/MockAwareTestCase.php: -------------------------------------------------------------------------------- 1 | createdMock = $this->mocks()->createMock(LoggerInterface::class); 17 | $this->assert()->not()->isNull($this->createdMock); 18 | } 19 | 20 | public function getCreatedMock() : ?object { 21 | return $this->createdMock; 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /framework_test/Stub/MockBridgeStub.php: -------------------------------------------------------------------------------- 1 | calls[] = __FUNCTION__; 15 | } 16 | 17 | public function createMock(string $class): object { 18 | $this->calls[] = __FUNCTION__ . ' ' . $class; 19 | $object = new stdClass(); 20 | $object->class = $class; 21 | return $object; 22 | } 23 | 24 | public function getAssertionCount(): int { 25 | return count($this->calls); 26 | } 27 | 28 | public function finalize(): void { 29 | $this->calls[] = __FUNCTION__; 30 | } 31 | 32 | public function getCalls() : array { 33 | return $this->calls; 34 | } 35 | } -------------------------------------------------------------------------------- /framework_test/UsesAcmeSrc.php: -------------------------------------------------------------------------------- 1 | path('ImplicitDefaultTestSuite/' . $path); 13 | } 14 | 15 | private function explicitTestSuitePath(string $path) : string { 16 | return $this->path('ExplicitTestSuite/' . $path); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /resources/schema/cli-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "https://labrador-kennel.io/dev/async-unit/schema/cli-config.json", 4 | "title": "AsyncUnitCliConfig", 5 | "description": "Declares the format of a valid asyncunit.json file to run AsyncUnit tests.", 6 | "type": "object", 7 | "properties": { 8 | "testDirs": { 9 | "type": "array", 10 | "minItems": 1, 11 | "items": { 12 | "type": "string", 13 | "minLength": 1 14 | } 15 | }, 16 | "resultPrinter": { 17 | "type": "string", 18 | "minLength": 1 19 | }, 20 | "mockBridge": { 21 | "type": "string", 22 | "minLength": 1 23 | }, 24 | "plugins": { 25 | "type": "array", 26 | "minItems": 1, 27 | "items": { 28 | "type": "string", 29 | "minLength": 1 30 | } 31 | } 32 | }, 33 | "required": ["testDirs", "resultPrinter"], 34 | "additionalProperties": false 35 | } --------------------------------------------------------------------------------