X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Ftypogrify%2Ftests%2Ftypogrify.class.test;fp=web%2Fmodules%2Fcontrib%2Ftypogrify%2Ftests%2Ftypogrify.class.test;h=56fb8ff9a883d845177a1e6e6d7714a895bf2fc7;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/typogrify/tests/typogrify.class.test b/web/modules/contrib/typogrify/tests/typogrify.class.test new file mode 100644 index 000000000..56fb8ff9a --- /dev/null +++ b/web/modules/contrib/typogrify/tests/typogrify.class.test @@ -0,0 +1,128 @@ + t('typogrify.class basic tests'), + 'description' => t('Testing all methods on the Typogrify class and their interaction.'), + 'group' => t('Typogrify'), + ); + } + + /** + * Implements setUp(). + */ + function setUp() { + parent::setUp('typogrify'); + } + + /** + * Tests ampersand-wrapping. + */ + function testAmpersandWrapping() { + $before = 'John & Robert.'; + $after = 'John & Robert.'; + $this->assertEqual(Typogrify::amp($before), $after, + t('Basic ampersand wrapping')); + + $before = 'P&T'; + $after = 'P&T'; + $this->assertEqual(Typogrify::amp($before), $after, + t("Don't mess with ampersands in words")); + + $before = 'advanced robotics & computing...'; + $after = 'advanced robotics & computing...'; + $this->assertEqual(Typogrify::amp($before), $after, + t("One space as HTML entitiy.")); + + $before = 'advanced robotics & computing...'; + $after = 'advanced robotics & computing...'; + $this->assertEqual(Typogrify::amp($before), $after, + t("Ampersand as HTML entitiy.")); + + $before = 'advanced robotics & computing...'; + $after = 'advanced robotics & computing...'; + $this->assertEqual(Typogrify::amp($before), $after, + t("Both spaces and ampersand as HTML entities.")); + + $before = 'P&T had many clients, of which DD&T & Cronhammar, Kronhammer & Hjort were the largest'; + $after = 'P&T had many clients, of which DD&T & Cronhammar, Kronhammer & Hjort were the largest'; + $this->assertEqual(Typogrify::amp($before), $after, + t("Both spaces and ampersand as HTML entities.")); + + } + + /** + * Widont test. + */ + function testWidont() { + $before = 'A very simple test'; + $after = 'A very simple test'; + $this->assertEqual(Typogrify::widont($before), $after, + t('Basic widont. Once sentance, no HTML.')); + + // Single word items shouldn't be changed. + $before = 'Test'; + $after = 'Test'; + $this->assertEqual(Typogrify::widont($before), $after, + t('Single word test #1')); + + $before = ' Test'; + $after = ' Test'; + $this->assertEqual(Typogrify::widont($before), $after, + t('Single word test #2')); + + $before = '