Closed (fixed)
Project:
Translation Management Tool
Version:
8.x-1.x-dev
Component:
Core
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Jan 2021 at 03:15 UTC
Updated:
16 Feb 2021 at 09:09 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
johnchqueI added some simple tests that should check this. :)
Comment #4
johnchqueUpdating the tests. :)
Comment #6
berdirYou don't want to throw an exception if the key is not set. As you can see, there are a lot of tests that use different structures. Only do that if a very specific string is set but also don't cause a php notice if that key isn't set. So a combined isset && specific value.
Comment #7
berdirAnd that value should IMHO be a proper structure, meaning an actual translation in a #translation key like other examples. You can use a self-explaining string like 'Invalid translation that will cause an exception' or something like that.
Comment #8
johnchqueHa, I was debugging my test so I negated the check to see if it was working fine but I forgot to revert, my bad. :)
This time should be better. :)
Tests passing locally.
Comment #9
berdirLets also assert that a message was created with state error that contains the error.
we have some examples that do that in the test,
\Drupal\Tests\tmgmt\Kernel\PluginsTest::testBasicWorkflow
I also think that this isn't the right place for this test. This is testing the tmgmt_content source, but we're not doing that here, we're testing the core functionality of tmgmt, so it should go in the main module. \Drupal\Tests\tmgmt\Kernel\CrudTest for example.
Maybe this as message:
"Failed to automatically accept translation, error: @error."
Also, add the message on the job item, don't go through the job ($this->addMessage()) so that it is automatically referencing the affected job item. The message wi ll be displayed in the job and job item messages then.
Comment #10
johnchqueMoving the tests and adding some assertions. I actually want to see if this is working here. I get some strange error when enabling the node type to be translated.
Comment #12
berdiryou're not installing the node schema.
But you don't need a node.
You're using a test source, that has absolutely nothing to do with nodes. just remove all node related code.
item type and id are just arbitrary strings, see \Drupal\tmgmt_test\Plugin\tmgmt\Source\TestSource::getData().
It just returns a fixed, predefined structure (unless you set something else in state). So you can just do $job->addItem('test_source', 'test', 1); or whatever.
And then for the translation, use the same dummy => deep_nesting structure for your translation, it's strange if you add translation data for something completely different.
Sorry, missed this before.
Comment #13
johnchqueAlright! This should work. I was making this more complicated for no reason. :)
Comment #14
berdiryou're still setting the translation here for the title, should update that to that dummy/deep nesting thing, so you set a translation for something actually exist. this doesn't fail, but maybe at some point we will validate it.
Comment #15
johnchqueAlright, sorry I missed that.
Comment #16
johnchqueOh I made a mistake here. BTW right now I am checking the message of the job item I hope that is alright. :)
Comment #18
berdirChanged it to assert the generated message with removed placeholders so we can assert this part works as well.