def test_gen_all_members(self): data = ['Foo', 'Bar'] member_def = Renderer.gen_all_members(data) expected = ''' /** @var Foo */ private $foo; /** @var Bar */ private $bar; ''' self.assertEqual(expected, member_def)
def test_gen_constructor(self): data = ['Foo', 'Bar'] params = Renderer.gen_constructor_statement(data) expected = ''' public function __construct( Foo $foo, Bar $bar ) { $this->foo = $foo; $this->bar = $bar; } ''' self.assertEqual(expected, params)
#!/usr/bin/python # Copyright (C) 2011 by Ondrej Martinak <*****@*****.**> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. from generator.renderer import Renderer print "Content-Type: text/html; charset=utf-8\n\n" ren = Renderer("Ondrej Martinak's web", "bub.css") ren.render()
def test_gen_member_statement(self): data = 'Foo' member_def = Renderer.gen_member_statement(data) expected = " /** @var Foo */\n private $foo;\n" self.assertEqual(expected, member_def)
def test_gen_constructor_all_assignments(self): data = ['Foo', 'Bar'] params = Renderer._gen_constructor_all_assignments(data) expected = " $this->foo = $foo;\n $this->bar = $bar;" self.assertEqual(expected, params)
def test_gen_constructor_assignment(self): data = 'Foo' param_def = Renderer._gen_constructor_assignment(data) expected = " $this->foo = $foo;" self.assertEqual(expected, param_def)
def test_gen_constructor_param(self): data = ['Foo', 'Bar'] params = Renderer._gen_constructor_all_params(data) expected = " Foo $foo,\n Bar $bar" self.assertEqual(expected, params)
def test_gen_constructor_param(self): data = 'Foo' param_def = Renderer._gen_constructor_param(data) expected = " Foo $Foo" self.assertEqual(expected, param_def)