Changeset 653 for trunk/tests


Ignore:
Timestamp:
Nov 28, 2018 1:40:13 AM (5 years ago)
Author:
anonymous
Message:

Update fancyTxt()

Location:
trunk/tests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/EmailTest.php

    r622 r653  
    9999        $this->Email->setString('This is a {TEST}');
    100100        $this->Email->replace(array(
    101             'test' => '– you guessed it – a test!'
     101            'test' => '– you guessed it – a test! Sent from ' . __FILE__
    102102        ));
    103103        $result   = $this->Email->send();
  • trunk/tests/UtilitiesTest.php

    r545 r653  
    3535    function setUp()
    3636    {
    37         define('_CLI', true);
     37        // define('_CLI', true);
    3838        require dirname(__FILE__) . '/_config.inc.php';
    3939        require_once '../lib/Utilities.inc.php';
     
    255255    }
    256256
     257    function test_fancyTxt()
     258    {
     259        $strings = [
     260            'Due to the <a href="https://en.wikipedia.org/wiki/Camp_Fire_(2018)">fires in "Paradise," CA</a> it\'s a bad day.' => '• Due to the <a href="https://en.wikipedia.org/wiki/Camp_Fire_(2018)">fires in “Paradise,” CA</a> it’s a bad day.',
     261            'Simply--"\'check back\' later"--in 6\'3"...' => '• Simply – “‘check back’ later” – in 6\'3"
',
     262            '"Double "double \'single\'""--?' => '• "Double “double ‘single’”" – ?',
     263            '<a href="javascript:openPopup(\'/foo/bar.php\')">Click here</a>....' => '• <a href="javascript:openPopup(\'/foo/bar.php\')">Click here</a>....',
     264            'If you have any questions please <a href="/contact/">contact the ants\' mailboxes</a>.' => '• If you have any questions please <a href="/contact/">contact the ants’ mailboxes</a>.',
     265            'This URL: "http://䟋子.卷筒纞/?x=y&1=2#asdf"' => '• This URL: “http://䟋子.卷筒纞/?x=y&1=2#asdf”',
     266            // '\'...\' and "..."' => '• ‘
’ and “
”', // FIXME: this one doesn't work.
     267            '\'1...\' and "2..."' => '• ‘1
’ and “2
”',
     268            '\'One\'s self...\' and "Twosome"' => '• ‘One’s self
’ and “Twosome”',
     269            '"\'Well,\' said I, \'the gentleman at No. 4.\'"' => '• “‘Well,’ said I, ‘the gentleman at No. 4.’”',
     270            '"...an office in Leadenhall Street--and--"
     271"O\'Reilly\'s office?"
     272"What!" he roared.
     273"Yes, to-day."* She stood smiling.'
     274=>
     275'• “
an office in Leadenhall Street – and – ”
     276“O’Reilly’s office?”
     277“What!” he roared.
     278“Yes, to-day.”* She stood smiling.',
     279        ];
     280        foreach ($strings as $input => $expected) {
     281            $result = fancyTxt($input, ['/^/', '/^·/'], ['· ', '•']);
     282            $this->assertEquals($expected, $result, sprintf('Failed with input: %s', $input));
     283        }
     284    }
    257285}
  • trunk/tests/run_tests.sh

    r622 r653  
    77#  export DB_USER="test"
    88#  export DB_PASS="..."
     9
     10# Run an individual test like this:
     11# ./tests/run_tests.sh /Users/q/src/codebase/trunk/tests/UtilitiesTest.php
    912
    1013function err {
     
    3841# Config options go in phpunit.xml
    3942# phpunit --tap | grep -v '^ok '
    40 ../vendor/phpunit/phpunit/composer/bin/phpunit --stderr || err "\nSomething went wrong (code $?). If there is no output above, check the php_error_log";
     43../vendor/phpunit/phpunit/composer/bin/phpunit --stderr "$@" || err "\nSomething went wrong (code $?). If there is no output above, check the php_error_log";
    4144
Note: See TracChangeset for help on using the changeset viewer.