There is a nice short introduction to twig on their homepage: http://twig.sensiolabs.org/. Basically you do not use php code in your templates, but the twig syntax (which is fast & easy to learn, no worries). Better rename your test.php into test.html.twig so it is clear it is intended to use as a twig template.
To pass variables to the view put them in an array and specify said array as the 3rd argument in your render method.
I would also recommend you take advantage of the {% extends "layout.html" %} syntax and similar very powerfull features of twig. You’ll find some examples on the webpage from twig too.