Remove the feeds module
This commit is contained in:
parent
acfd1cca8d
commit
0c98be96eb
851 changed files with 840 additions and 10348 deletions
|
@ -87,14 +87,5 @@
|
|||
"processed": "\n <p>In unit tests, and sometimes in kernel tests, you need to mock the dependencies you aren't testing, but you can over-mock and only be testing the mocks and not the code you want to test.<\/p>\n\n<p>Here's an example (thanks, ChatGPT, for the code).<\/p>\n\n<h2 id=\"the-class-to-be-tested-myclass.php\">The Class to be tested (MyClass.php)<\/h2>\n\n<pre><code class=\"language-php\"><?php\n\nclass MyClass {\n\n public function __construct(\n private DependencyInterface $dependency\n ) {\n }\n\n public function doSomething() {\n $result = $this->dependency->performAction();\n\n return \"Result: \" . $result;\n }\n}\n<\/code><\/pre>\n\n<h2 id=\"dependency-interface-dependencyinterface.php\">Dependency Interface (DependencyInterface.php)<\/h2>\n\n<pre><code class=\"language-php\"><?php\n\ninterface DependencyInterface {\n\n public function performAction();\n\n}\n<\/code><\/pre>\n\n<h2 id=\"a-test-class-that-ends-up-testing-mocks-myclasstest.php\">A test class that ends up testing mocks (MyClassTest.php)<\/h2>\n\n<pre><code class=\"language-php\"><?php\n\nuse PHPUnit\\Framework\\TestCase;\n\nclass MyClassTest extends TestCase {\n\n public function testDoSomething() {\n \/\/ Creating a mock of the DependencyInterface.\n $dependencyMock = $this->createMock(DependencyInterface::class);\n\n \/\/ Setting up the mock to return a specific value.\n $dependencyMock->expects($this->once())\n ->method('performAction')\n ->willReturn('Mocked result');\n\n \/\/ Creating an instance of MyClass with the mock.\n $myClass = new MyClass($dependencyMock);\n\n \/\/ Calling the method to be tested.\n $result = $myClass->doSomething();\n\n \/\/ Asserting that the result matches the expected value.\n $this->assertEquals('Result: Mocked result', $result);\n }\n\n}\n<\/code><\/pre>\n\n<h2 id=\"here%27s-the-thing\">Here's the thing<\/h2>\n\n<p>In this example, the test creates a mock for the <code>DependencyInterface<\/code> and sets up an expectation that the performAction method will be called once, returning a specific value.<\/p>\n\n<p>The test then calls the <code>doSomething<\/code> method on <code>MyClass<\/code> and asserts that the result is as expected.<\/p>\n\n<p>The issue with this test is that it's not testing the actual behaviour of <code>MyClass<\/code>.<\/p>\n\n<p>It's only testing that the mock is configured correctly.<\/p>\n\n<p>If the real implementation of <code>MyClass<\/code> has a bug, this test won't catch it.<\/p>\n\n ",
|
||||
"summary": null
|
||||
}
|
||||
],
|
||||
"feeds_item": [
|
||||
{
|
||||
"imported": "1970-01-01T00:32:50+00:00",
|
||||
"guid": null,
|
||||
"hash": "db65f35f5c7767e34b717942905448f4",
|
||||
"target_type": "feeds_feed",
|
||||
"target_uuid": "90c85284-7ca8-4074-9178-97ff8384fe76"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue