Commit graph

34 commits

Author SHA1 Message Date
f0f93912ee 5c: Add test for isPublishable
Using a data provider, multiple arguments can be passed into the test,
such as different combinations of created dates and expected results.

This test also requires mocking the `Time` object as it’s now a
dependency of the article wrapper. The `getCreatedTime` method on the
article also needs to be set to return a specific value.
2020-03-25 12:31:28 +00:00
b98d181a58 5c: Add isPublishable method to article wrapper
Add the `isPublishable()` method to the article wrapper. This contains
all of the logic that is used to determine if an article in publishable
or not, and returns a boolean.
2020-03-25 12:31:28 +00:00
3ecca5ad0c 5b: Throw an Exception is a non-article is wrapped
Within the article wrapper, let’s check that the node is an article,
otherwise thrown the Exception as expected.
2020-03-25 12:31:28 +00:00
76172f4667 5b: Add a test for which nodes are wrappable
If we attempt to wrap a node which is not an article, we expect an
Exception to be thrown. As one currently isn’t, the test will fail.
2020-03-25 12:31:28 +00:00
7823e56b09 5a: Add return values for methods
Provide response values for the `id()` and `bundle()` methods so that we
can call them and use the returned values within the assertions.
2020-03-25 12:31:28 +00:00
fd9f9e7e48 5a: Create a mock article
As this is a unit test, we don’t have access to a database or the
service container, so we will need to use a mock.

This is enough to pass the `instanceOf` assertion, but the others are
failing as those methods are returning `null`.
2020-03-25 12:31:28 +00:00
8d309299ea 5a: Create the ArticleWrapper class
Add the contents for the article wrapper class.

This fails as there’s no article to wrap yet within the test.
2020-03-25 12:31:28 +00:00
13a58fa434 5a: The article wrapper can return an article
Add a test to ensure that an `ArticleWrapper` can be used to decorate an
article node, and that the original article can be retrieved again.
2020-03-25 12:31:28 +00:00
f9be233bc0 4j: Update the sort order
Before returning the articles from the `getAll()` method, sort them
based on their created date.
2020-03-25 12:31:28 +00:00
87fb45dcbb 4j: Add a test for the article ordering
Add a test to ensure that the articles are returned from the article
repository based on their created date, with the newest articles
returned first.

The articles are created with defined created dates and created in a
specific order to ensure that the test doesn’t pass by default.
2020-03-25 12:31:28 +00:00
92ca064737 4i: Update getAll() method
Ensure that only published articles are returned from the `getAll()`
method on the article repository.
2020-03-25 12:31:28 +00:00
02c732b60b 4i: Ensure published articles are returned
Add a test to ensure that only published articles are returned from the
article repository.

Currently there is no filter on the published status, so too many nodes
are returned.
2020-03-25 12:31:28 +00:00
76a19ff21b 4i: Ensure only articles are returned
Update the `getAll()` method on the article repository to only return
article nodes.
2020-03-25 12:31:28 +00:00
e79a63476e 4h: Add page nodes to break the test
Also create a number of page (not article) nodes within the test to
ensure that these are excluded. Currently they are returned so too many
nodes are returned.

This is causing a failure as the expected count value is no longer being
returned.
2020-03-25 12:31:28 +00:00
55035b236b 4g: Install node_access table
Ensure that the `node_access` table is created within the test.
2020-03-25 12:31:28 +00:00
e3c57ea103 4g: Install filter config
Install the configuration from the filter module, so that there are
filters created and to avoid the `id() on bool` error.

This fails are there is a missing database table.
2020-03-25 12:31:28 +00:00
145b2d8e94 4g: Create some article nodes
Create some article nodes within the test so that there are some nodes
to return from the article repository.

This fails due to an error from the filter module.
2020-03-25 12:31:28 +00:00
f492921c8d 4f: Enable the node module
Enable the node module within the test.

This returns as 0 articles are returned, but 3 are expected in the
assertion.
2020-03-25 12:31:28 +00:00
016512bf1b 4f: Enable autowiring
Enable autowiring so that the entity type manager is injected into the
ArticleRepository service.

This fails because the 'node' entity type doesn’t exist.
2020-03-25 12:31:28 +00:00
dcace271a2 4f: Build up the getAll() method
Inject the entity type manager service into the ArticleRepository, and
use it to load and return all nodes.

This fails as not enough arguments are passed to the article repository
service from the container.
2020-03-25 12:31:28 +00:00
8adcf2d8f6 4e: Add the getAll() method
Add the `getAll()` method to the ArticleRepository, ensuring that it
returns an array.

This returns as 0 articles are returned, but 3 are expected in the
assertion.
2020-03-25 12:31:28 +00:00
54b306844f 4d: Add the ArticleRepository
Create the `ArticleRepository` class and add it as a service.

This fails as there is no `getAll()` method on the class.
2020-03-25 12:31:28 +00:00
0c518d3d37 4a: Ensure that only articles are returned
Start adding a kernel test that retrieves article nodes from an
`ArticleRepository` and ensures that only articles are returned.

This fails due to a non-existent service.
2020-03-25 12:31:28 +00:00
23287fc0fd 3e: Add page text
Replace the empty render array with one that returns the expected text.
2020-03-25 12:31:28 +00:00
165f159073 3e: Add more assertions
Add more assertions to ensure that the correct page title is returned as
well as some text on the page.

This fails as the expected test is not returned.
2020-03-25 12:31:28 +00:00
e8bfcb353b 3d: Add BlogPageController
Add the BlogPageController that is referenced within
`my_module.routing.yml`.

We will need to return a render array, but for now let’s return an empty
array.

The test now passes as we are getting the expected response code.
2020-03-25 12:31:28 +00:00
5fe37b439b 3c: Enable the node module
Enable the node module within the test to add the `access content`
permission.

This fails, and returns a 500 response code rather than the expected 200
response code.
2020-03-25 12:31:28 +00:00
749ec4f829 3b: Add blog page route
Add a `my_module.routing.yml` file that adds the missing route for
`/blog`.

This fails, and returns a 403 response code rather than the expected 200
response code.
2020-03-25 12:31:28 +00:00
aabc1aac1b 3a: Add blog page functional test
Add the new `BlogPageTest` functional test to ensure that anonymous
users can access the `/blog` page.

This fails, and returns a 404 response code rather than the expected 200
response code.
2020-03-25 12:31:28 +00:00
1941bdf9ba 2b: Admin page access for admin users
Ensure that users with the `access administration pages` permission can
access the site’s administration pages.
2020-03-25 12:31:28 +00:00
1f6a90624f 2a: Admin page access for anonymous users
Ensure that anonymous users cannot access the site’s administration
pages.
2020-03-25 12:31:28 +00:00
300c572080 1d: Add first functional test
Ensure that anonymous users can view the site’s front page.
2020-03-25 12:31:28 +00:00
b3cddb036b 1b: Add my_module.info.yml
Add the my_module.info.yml file so that the module can be enabled.
2020-03-25 12:31:28 +00:00
5adc4f6a10 init 2020-03-25 12:31:28 +00:00