Skip to content

Commit

Permalink
* start making messages more robust and important. This will allow us…
Browse files Browse the repository at this point in the history
… to run the tests in PHPUnit or any testing library without having to change the tests.

I could really use a hand if anyone wants to transform the Messages.php file to individual classes. If you do want to get involved, don't worry much about the name of the test. You can name it Test1, Test2, List1, List2. That's fine. Use as many directories as subdirectories as you want. The application will know what to do.
  • Loading branch information
joshuaadickerson committed Dec 10, 2015
1 parent cbcf7e2 commit 83640cf
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Messages.php
@@ -1,6 +1,6 @@
<?php
/**
* The test messags.
* The test messages.
* Generally, they go from less to more complex.
*
* This should result in the same messages for every call. So don't put any randomization in this.
Expand Down Expand Up @@ -220,6 +220,9 @@ public function action_index()
'www.ñchan.org',
'http://www.ñchan.org',

// https://github.com/SimpleMachines/SMF2.1/issues/3106
'[list][li]Test[/li][li]More[code]Some COde[/code][/li][/list]',

// Long messages (put last so I don't have to see them) These usually take too long to run
// A really long message but without bbc
//str_repeat('hello world', 1000),
Expand Down
24 changes: 24 additions & 0 deletions Messages/DoesNotContainBBC/EmptyString.php
@@ -0,0 +1,24 @@
<?php

class EmptyString implements MessageInterface
{
public static function name()
{
return 'Empty string';
}

public static function input()
{
return '';
}

public static function stored()
{
return '';
}

public static function output()
{
return '';
}
}
26 changes: 26 additions & 0 deletions Messages/DoesNotContainBBC/VeryLong.php
@@ -0,0 +1,26 @@
<?php

class VeryLong implements MessageInterface
{
private static $string = 'This is a div with multiple classes and no ID. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec volutpat tellus vulputate dui venenatis quis euismod turpis pellentesque. Suspendisse [sit] amet ipsum eu odio sagittis ultrices at non sapien. Quisque viverra feugiat purus, eu mollis felis condimentum id. In luctus faucibus felis eget viverra. Vivamus et velit orci. In in tellus mauris, at fermentum diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed a magna nunc, vel tempor magna. Nam dictum, arcu in pretium varius, libero enim hendrerit nisl, et commodo enim sapien eu augue.';

public static function name()
{
return 'Very long string with no BBC';
}

public static function input()
{
return str_repeat(self::$string, 5);
}

public static function stored()
{
return str_repeat(self::$string, 5);
}

public static function output()
{
return str_repeat(self::$string, 5);
}
}
24 changes: 24 additions & 0 deletions Messages/Lists/SimpleList.php
@@ -0,0 +1,24 @@
<?php

class SimpleList implements MessageInterface
{
public static function name()
{
return 'Simple List';
}

public static function input()
{
return '[list][li]short list[/li][/list]';
}

public static function stored()
{
return '[list][li]short list[/li][/list]';
}

public static function output()
{
return '<ul class="bbc_list"><li>simple</li><li>list</li></ul>';
}
}
24 changes: 24 additions & 0 deletions Messages/Lists/SimpleListWithType.php
@@ -0,0 +1,24 @@
<?php

class SimpleListWithType implements MessageInterface
{
public static function name()
{
return 'Simple List With Type';
}

public static function input()
{
return '[list][li]short list[/li][/list]';
}

public static function stored()
{
return '[list][li]short list[/li][/list]';
}

public static function output()
{
return '<ul class="bbc_list" style="list-style-type: decimal;"><li>simple</li><li>list</li></ul>';
}
}
35 changes: 35 additions & 0 deletions Messages/MessageInterface.php
@@ -0,0 +1,35 @@
<?php

interface MessageInterface
{
/**
* What the user inputs.
* Used as input for the preparser
*
* @return string
*/
public static function input();

/**
* What is stored in the database
* Used to check if the preparser works
* Also used as input for the parser
*
* @return string
*/
public static function stored();

/**
* What is displayed to the user
* Used to check if the parser works
*
* @return string
*/
public static function output();

/**
* Get a human readable name of this message
* @return string
*/
public static function name();
}
24 changes: 24 additions & 0 deletions Messages/SimpleBBC/Bold.php
@@ -0,0 +1,24 @@
<?php

class Bold implements MessageInterface
{
public static function name()
{
return 'Basic bold';
}

public static function input()
{
return '[b]Bold[/b]';
}

public static function stored()
{
return '[b]Bold[/b]';
}

public static function output()
{
return '<b>Bold</b>';
}
}

0 comments on commit 83640cf

Please sign in to comment.