Make WordPress Core

Ticket #23625: 23625-tests.diff

File 23625-tests.diff, 12.2 KB (added by wonderboymusic, 12 years ago)
  • tests/post-formats.php

     
     1<?php
     2/**
     3 * test wp-includes/post-formats.php
     4 *
     5 * @group post-formats
     6 */
     7class Tests_Post_Formats extends WP_UnitTestCase {
     8        /**
     9         * @ticket 23625
     10         */
     11        function test_get_content_chat() {
     12                $data =<<<DATA
     13Scott: Hey.
     14Nacin: Go away.
     15DATA;
     16
     17                $stanzas = get_content_chat( $data );
     18                $expected = array(
     19                        array(
     20                                array(
     21                                        'time' => '',
     22                                        'author' => 'Scott',
     23                                        'message' => 'Hey.'
     24                                ),
     25                                array(
     26                                        'time' => '',
     27                                        'author' => 'Nacin',
     28                                        'message' => 'Go away.'
     29                                )
     30                        )
     31                );
     32                $this->assertEquals( $stanzas, $expected );
     33
     34                $data =<<<DATA
     35Scott: Hey.
     36Nacin: Go away.
     37
     38Nacin is mean to me.
     39DATA;
     40
     41                $stanzas = get_content_chat( $data );
     42                $this->assertEquals( $stanzas, $expected );
     43
     44                $data =<<<DATA
     45Scott: Hey.
     46I have a question.
     47Nacin: Go away.
     48DATA;
     49
     50                $stanzas = get_content_chat( $data );
     51                $expected = array(
     52                        array(
     53                                array(
     54                                        'time' => '',
     55                                        'author' => 'Scott',
     56                                        'message' => 'Hey. I have a question.'
     57                                ),
     58                                array(
     59                                        'time' => '',
     60                                        'author' => 'Nacin',
     61                                        'message' => 'Go away.'
     62                                )
     63                        )
     64                );
     65
     66                $data =<<<DATA
     67Scott: Hey.
     68I have a question: what is your favorite color?
     69Nacin: Go away.
     70DATA;
     71
     72                $stanzas = get_content_chat( $data );
     73                $expected = array(
     74                        array(
     75                                array(
     76                                        'time' => '',
     77                                        'author' => 'Scott',
     78                                        'message' => 'Hey. I have a question: what is your favorite color?'
     79                                ),
     80                                array(
     81                                        'time' => '',
     82                                        'author' => 'Nacin',
     83                                        'message' => 'Go away.'
     84                                )
     85                        )
     86                );
     87                $this->assertEquals( $stanzas, $expected );
     88
     89                $data =<<<DATA
     90Scott: Hey.
     91I have a question: will you read this http://www.justinbieber.com ?
     92Nacin: Go away.
     93
     94Nacin hates Justin Bieber.
     95DATA;
     96
     97                $stanzas = get_content_chat( $data );
     98                $expected = array(
     99                        array(
     100                                array(
     101                                        'time' => '',
     102                                        'author' => 'Scott',
     103                                        'message' => 'Hey. I have a question: will you read this <a href="http://www.justinbieber.com" rel="nofollow">http://www.justinbieber.com</a> ?'
     104                                ),
     105                                array(
     106                                        'time' => '',
     107                                        'author' => 'Nacin',
     108                                        'message' => 'Go away.'
     109                                )
     110                        )
     111                );
     112                $this->assertEquals( $stanzas, $expected );
     113
     114                $data =<<<DATA
     115Scott: Hey.
     116I have a question: what is your favorite color?
     117Nacin: Go away.
     118
     119Nacin hates color.
     120DATA;
     121
     122                $stanzas = get_content_chat( $data );
     123                $expected = array(
     124                        array(
     125                                array(
     126                                        'time' => '',
     127                                        'author' => 'Scott',
     128                                        'message' => 'Hey. I have a question: what is your favorite color?'
     129                                ),
     130                                array(
     131                                        'time' => '',
     132                                        'author' => 'Nacin',
     133                                        'message' => 'Go away.'
     134                                )
     135                        )
     136                );
     137                $this->assertEquals( $stanzas, $expected );
     138
     139                $data =<<<DATA
     140Scott: Hey.
     141Nacin: Go away.
     142
     143Helen: Hey.
     144Nacin: Go away.
     145DATA;
     146
     147                $stanzas = get_content_chat( $data );
     148                $expected = array(
     149                        array(
     150                                array(
     151                                        'time' => '',
     152                                        'author' => 'Scott',
     153                                        'message' => 'Hey.'
     154                                ),
     155                                array(
     156                                        'time' => '',
     157                                        'author' => 'Nacin',
     158                                        'message' => 'Go away.'
     159                                )
     160
     161                        ),
     162                        array(
     163                                array(
     164                                        'time' => '',
     165                                        'author' => 'Helen',
     166                                        'message' => 'Hey.'
     167                                ),
     168                                array(
     169                                        'time' => '',
     170                                        'author' => 'Nacin',
     171                                        'message' => 'Go away.'
     172                                )
     173                        )
     174                );
     175                $this->assertEquals( $stanzas, $expected );
     176
     177                $data =<<<DATA
     178
     179Scott: Hey.
     180Nacin: Go away.
     181
     182Helen: Hey.
     183Nacin: Go away.
     184
     185Nacin appears busy today.
     186DATA;
     187
     188                $stanzas = get_content_chat( $data );
     189                $this->assertEquals( $stanzas, $expected );
     190
     191                $data =<<<DATA
     192Scott: Hey.
     193I have a question: what is your favorite color?
     194Nacin: Go away.
     195
     196Helen: Hey.
     197I have a question: what is your favorite pizza topping?
     198Nacin: Go away.
     199DATA;
     200
     201                $stanzas = get_content_chat( $data );
     202                $expected = array(
     203                        array(
     204                                array(
     205                                        'time' => '',
     206                                        'author' => 'Scott',
     207                                        'message' => 'Hey. I have a question: what is your favorite color?'
     208                                ),
     209                                array(
     210                                        'time' => '',
     211                                        'author' => 'Nacin',
     212                                        'message' => 'Go away.'
     213                                )
     214                        ),
     215                        array(
     216                                array(
     217                                        'time' => '',
     218                                        'author' => 'Helen',
     219                                        'message' =>  'Hey. I have a question: what is your favorite pizza topping?'
     220                                ),
     221                                array(
     222                                        'time' => '',
     223                                        'author' => 'Nacin',
     224                                        'message' => 'Go away.'
     225                                )
     226                        )
     227                );
     228                $this->assertEquals( $stanzas, $expected );
     229
     230                $data =<<<DATA
     231Scott: Hey.
     232I have a question: what is your favorite color?
     233Nacin: Go away.
     234
     235Helen: Hey.
     236I have a question: what is your favorite pizza topping?
     237Nacin: Go away.
     238
     239Nacin hates color and pizza.
     240DATA;
     241
     242                $stanzas = get_content_chat( $data );
     243                $this->assertEquals( $stanzas, $expected );
     244
     245                $data =<<<DATA
     246[3/7/13 11:19:33 AM] Helen Hou-Sandi: I like Apples.
     247[3/7/13 11:29:31 AM] Scott Taylor: word
     248DATA;
     249
     250                $expected = array(
     251                        array(
     252                                array(
     253                                        'time' => '[3/7/13 11:19:33 AM]',
     254                                        'author' => 'Helen Hou-Sandi',
     255                                        'message' => 'I like Apples.'
     256                                ),
     257                                array(
     258                                        'time' => '[3/7/13 11:29:31 AM]',
     259                                        'author' => 'Scott Taylor',
     260                                        'message' => 'word'
     261                                ),
     262                        )
     263                );
     264
     265                $stanzas = get_content_chat( $data );
     266                $this->assertEquals( $stanzas, $expected );
     267
     268                $data =<<<DATA
     269[3/5/13 2:30:09 PM] Scott Taylor: https://github.com/johndyer/mediaelement
     270[3/5/13 2:30:15 PM] Scott Taylor: MIT
     271[3/5/13 2:31:13 PM] Andrew Nacin: https://github.com/johndyer/mediaelement/issues?labels=Wordpress
     272DATA;
     273
     274                $expected = array(
     275                        array(
     276                                array(
     277                                        'time' => '[3/5/13 2:30:09 PM]',
     278                                        'author' => 'Scott Taylor',
     279                                        'message' => '<a href="https://github.com/johndyer/mediaelement" rel="nofollow">https://github.com/johndyer/mediaelement</a>'
     280                                ),
     281                                array(
     282                                        'time' => '[3/5/13 2:30:15 PM]',
     283                                        'author' => 'Scott Taylor',
     284                                        'message' => 'MIT'
     285                                ),
     286                                array(
     287                                        'time' => '[3/5/13 2:31:13 PM]',
     288                                        'author' => 'Andrew Nacin',
     289                                        'message' => '<a href="https://github.com/johndyer/mediaelement/issues?labels=Wordpress" rel="nofollow">https://github.com/johndyer/mediaelement/issues?labels=Wordpress</a>'
     290                                ),
     291                        )
     292                );
     293
     294                $stanzas = get_content_chat( $data );
     295                $this->assertEquals( $stanzas, $expected );
     296
     297                $data =<<<DATA
     298<rmccue> Hi!
     299<nacin> You suck.
     300DATA;
     301                $expected = array(
     302                        array(
     303                                array(
     304                                        'time' => '',
     305                                        'author' => 'rmccue',
     306                                        'message' => 'Hi!'
     307                                ),
     308                                array(
     309                                        'time' => '',
     310                                        'author' => 'nacin',
     311                                        'message' => 'You suck.'
     312                                ),
     313                        )
     314                );
     315                $stanzas = get_content_chat( $data );
     316                $this->assertEquals( $stanzas, $expected );
     317
     318                $data =<<<DATA
     319<rmccue> Hi!
     320<nacin> You suck.
     321
     322<rmccue> Hi!
     323<nacin> You suck.
     324DATA;
     325                $expected = array(
     326                        array(
     327                                array(
     328                                        'time' => '',
     329                                        'author' => 'rmccue',
     330                                        'message' => 'Hi!'
     331                                ),
     332                                array(
     333                                        'time' => '',
     334                                        'author' => 'nacin',
     335                                        'message' => 'You suck.'
     336                                ),
     337                        ),
     338                        array(
     339                                array(
     340                                        'time' => '',
     341                                        'author' => 'rmccue',
     342                                        'message' => 'Hi!'
     343                                ),
     344                                array(
     345                                        'time' => '',
     346                                        'author' => 'nacin',
     347                                        'message' => 'You suck.'
     348                                ),
     349                        )
     350                );
     351                $stanzas = get_content_chat( $data );
     352                $this->assertEquals( $stanzas, $expected );
     353
     354                $data =<<<DATA
     355[08:15:04] <rmccue> Hi!
     356[08:15:16] <nacin> You suck.
     357
     358[08:15:04] <rmccue> Hi!
     359[08:15:16] <nacin> You suck.
     360DATA;
     361
     362                $expected = array(
     363                        array(
     364                                array(
     365                                        'time' => '[08:15:04]',
     366                                        'author' => 'rmccue',
     367                                        'message' => 'Hi!'
     368                                ),
     369                                array(
     370                                        'time' => '[08:15:16]',
     371                                        'author' => 'nacin',
     372                                        'message' => 'You suck.'
     373                                ),
     374                        ),
     375                        array(
     376                                array(
     377                                        'time' => '[08:15:04]',
     378                                        'author' => 'rmccue',
     379                                        'message' => 'Hi!'
     380                                ),
     381                                array(
     382                                        'time' => '[08:15:16]',
     383                                        'author' => 'nacin',
     384                                        'message' => 'You suck.'
     385                                ),
     386                        )
     387                );
     388                $stanzas = get_content_chat( $data );
     389                $this->assertEquals( $stanzas, $expected );
     390
     391                $data =<<<DATA
     392<gmorrison> just a sec
     393<gmorrison> ok
     394<gmorrison> changing uploads to 777 let it create the folder for that
     395<gmorrison> so yes it can
     396* daveluke has quit (Quit: daveluke)
     397* robmiller (~robmiller@141.0.147.143) has joined #wordpress
     398<snowfox_ben> here is my code https://gist.github.com/benschaaf/91179440d1996b48e382
     399DATA;
     400                $expected = array(
     401                        array(
     402                                array(
     403                                        'time' => '',
     404                                        'author' => 'gmorrison',
     405                                        'message' => 'just a sec'
     406                                ),
     407                                array(
     408                                        'time' => '',
     409                                        'author' => 'gmorrison',
     410                                        'message' => 'ok'
     411                                ),
     412                                array(
     413                                        'time' => '',
     414                                        'author' => 'gmorrison',
     415                                        'message' => 'changing uploads to 777 let it create the folder for that'
     416                                ),
     417                                array(
     418                                        'time' => '',
     419                                        'author' => 'gmorrison',
     420                                        'message' => 'so yes it can * daveluke has quit (Quit: daveluke) * robmiller (~robmiller@141.0.147.143) has joined #wordpress'
     421                                ),
     422                                array(
     423                                        'time' => '',
     424                                        'author' => 'snowfox_ben',
     425                                        'message' => 'here is my code <a href="https://gist.github.com/benschaaf/91179440d1996b48e382" rel="nofollow">https://gist.github.com/benschaaf/91179440d1996b48e382</a>'
     426                                ),
     427                        )
     428                );
     429
     430                $stanzas = get_content_chat( $data );
     431                $this->assertEquals( $stanzas, $expected );
     432
     433                $data = <<<DATA
     434Nigel Tufnel: The numbers all go to eleven. Look, right across the board, eleven, eleven, eleven and…
     435
     436Marti DiBergi: Oh, I see. And most amps go up to ten?
     437
     438Nigel Tufnel: Exactly.
     439
     440Marti DiBergi: Does that mean it’s louder? Is it any louder?
     441
     442Nigel Tufnel: Well, it’s one louder, isn’t it? It’s not ten. You see, most blokes, you know, will be playing at ten. You’re on ten here, all the way up, all the way up, all the way up, you’re on ten on your guitar. Where can you go from there? Where?
     443
     444Marti DiBergi: I don’t know.
     445
     446Nigel Tufnel: Nowhere. Exactly. What we do is, if we need that extra push over the cliff, you know what we do?
     447
     448Marti DiBergi: Put it up to eleven.
     449
     450Nigel Tufnel: Eleven. Exactly. One louder.
     451
     452Marti DiBergi: Why don’t you just make ten louder and make ten be the top number and make that a little louder?
     453
     454Nigel Tufnel: These go to eleven.
     455DATA;
     456
     457                $expected = array(
     458                        array(
     459                                array(
     460                                        'time' => '',
     461                                        'author' => 'Nigel Tufnel',
     462                                        'message' => 'The numbers all go to eleven. Look, right across the board, eleven, eleven, eleven and…'
     463                                )
     464                        ),
     465                        array(
     466                                array(
     467                                        'time' => '',
     468                                        'author' => 'Marti DiBergi',
     469                                        'message' => 'Oh, I see. And most amps go up to ten?'
     470                                )
     471                        ),
     472                        array(
     473                                array(
     474                                        'time' => '',
     475                                        'author' => 'Nigel Tufnel',
     476                                        'message' => 'Exactly.'
     477                                )
     478                        ),
     479                        array(
     480                                array(
     481                                        'time' => '',
     482                                        'author' => 'Marti DiBergi',
     483                                        'message' => 'Does that mean it’s louder? Is it any louder?'
     484                                )
     485                        ),
     486                        array(
     487                                array(
     488                                        'time' => '',
     489                                        'author' => 'Nigel Tufnel',
     490                                        'message' => 'Well, it’s one louder, isn’t it? It’s not ten. You see, most blokes, you know, will be playing at ten. You’re on ten here, all the way up, all the way up, all the way up, you’re on ten on your guitar. Where can you go from there? Where?'
     491                                )
     492                        ),
     493                        array(
     494                                array(
     495                                        'time' => '',
     496                                        'author' => 'Marti DiBergi',
     497                                        'message' => 'I don’t know.'
     498                                )
     499                        ),
     500                        array(
     501                                array(
     502                                        'time' => '',
     503                                        'author' => 'Nigel Tufnel',
     504                                        'message' => 'Nowhere. Exactly. What we do is, if we need that extra push over the cliff, you know what we do?'
     505                                )
     506                        ),
     507                        array(
     508                                array(
     509                                        'time' => '',
     510                                        'author' => 'Marti DiBergi',
     511                                        'message' => 'Put it up to eleven.'
     512                                )
     513                        ),
     514                        array(
     515                                array(
     516                                        'time' => '',
     517                                        'author' => 'Nigel Tufnel',
     518                                        'message' => 'Eleven. Exactly. One louder.'
     519                                )
     520                        ),
     521                        array(
     522                                array(
     523                                        'time' => '',
     524                                        'author' => 'Marti DiBergi',
     525                                        'message' => 'Why don’t you just make ten louder and make ten be the top number and make that a little louder?'
     526                                )
     527                        ),
     528                        array(
     529                                array(
     530                                        'time' => '',
     531                                        'author' => 'Nigel Tufnel',
     532                                        'message' => 'These go to eleven.'
     533                                )
     534                        ),
     535                );
     536                $stanzas = get_content_chat( $data );
     537                $this->assertEquals( $stanzas, $expected );
     538        }
     539}
     540 No newline at end of file