Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC Document creating fixtures in custom DB tables #484

Conversation

GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli commented Mar 20, 2024

Description

Documents how to create fixtures for tables that aren't backed by a DataObject class.

Issues

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no TODO comments, unrelated rewording/restructuring, or arbitrary changes)
    • Small amounts of additional changes are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • The changes follow our writing style guide
  • Code examples follow our coding conventions
  • CI is green

Comment on lines -196 to +199
## Fixtures for namespaced classes

You will need to use fully qualified class names in your YAML fixture files. In the above examples, they belong to the global namespace so there is nothing requires, but if you have a deeper DataObject, or it has a relationship to models that are part of the framework for example, you will need to include their namespaces:

```yml
App\Test\Player:
john:
Name: join
App\Test\Team:
crusaders:
Name: Crusaders
Origin: Canterbury
Players: =>App\Test\Player.john
```

> [!WARNING]
> If your tests are failing and your database has table names that follow the fully qualified class names, you've probably forgotten to implement `private static $table_name = 'Player';` on your namespaced class. See [DataObject](api:SilverStripe\ORM\DataObject) for an example.

## Defining many_many_extraFields
## Defining `many_many_extraFields`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated refactoring - but I noticed that this is actually outdated. All the above examples use namespaced classes.
I've moved the warning up above.

@emteknetnz emteknetnz merged commit 395fa14 into silverstripe:5 Apr 1, 2024
3 checks passed
@emteknetnz emteknetnz deleted the pulls/5/fixtures-in-custom-tables branch April 1, 2024 22:28
emteknetnz pushed a commit to creative-commoners/developer-docs that referenced this pull request May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants