Make WordPress Core

Ticket #23625: 23625-tests.2.diff

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

    diff --git tests/post/formats.php tests/post/formats.php
    index 3b14076..669c59c 100644
    class Tests_Post_Formats extends WP_UnitTestCase { 
    9393                // Dummy post id
    9494                $this->assertFalse( has_post_format( 'aside', 12345 ) );
    9595        }
     96
     97        /**
     98         * @ticket 23625
     99         */
     100        function test_get_content_chat() {
     101                $data =<<<DATA
     102Scott: Hey.
     103Nacin: Go away.
     104DATA;
     105
     106                $stanzas = get_content_chat( $data );
     107                $expected = array(
     108                        array(
     109                                array(
     110                                        'time' => '',
     111                                        'author' => 'Scott',
     112                                        'message' => 'Hey.'
     113                                ),
     114                                array(
     115                                        'time' => '',
     116                                        'author' => 'Nacin',
     117                                        'message' => 'Go away.'
     118                                )
     119                        )
     120                );
     121                $this->assertEquals( $stanzas, $expected );
     122
     123                $data =<<<DATA
     124Scott: Hey.
     125Nacin: Go away.
     126
     127Nacin is mean to me.
     128DATA;
     129
     130                $stanzas = get_content_chat( $data );
     131                $this->assertEquals( $stanzas, $expected );
     132
     133                $data =<<<DATA
     134Scott: Hey.
     135I have a question.
     136Nacin: Go away.
     137DATA;
     138
     139                $stanzas = get_content_chat( $data );
     140                $expected = array(
     141                        array(
     142                                array(
     143                                        'time' => '',
     144                                        'author' => 'Scott',
     145                                        'message' => 'Hey. I have a question.'
     146                                ),
     147                                array(
     148                                        'time' => '',
     149                                        'author' => 'Nacin',
     150                                        'message' => 'Go away.'
     151                                )
     152                        )
     153                );
     154
     155                $data =<<<DATA
     156Scott: Hey.
     157I have a question: what is your favorite color?
     158Nacin: Go away.
     159DATA;
     160
     161                $stanzas = get_content_chat( $data );
     162                $expected = array(
     163                        array(
     164                                array(
     165                                        'time' => '',
     166                                        'author' => 'Scott',
     167                                        'message' => 'Hey. I have a question: what is your favorite color?'
     168                                ),
     169                                array(
     170                                        'time' => '',
     171                                        'author' => 'Nacin',
     172                                        'message' => 'Go away.'
     173                                )
     174                        )
     175                );
     176                $this->assertEquals( $stanzas, $expected );
     177
     178                $data =<<<DATA
     179Scott: Hey.
     180I have a question: will you read this http://www.justinbieber.com ?
     181Nacin: Go away.
     182
     183Nacin hates Justin Bieber.
     184DATA;
     185
     186                $stanzas = get_content_chat( $data );
     187                $expected = array(
     188                        array(
     189                                array(
     190                                        'time' => '',
     191                                        'author' => 'Scott',
     192                                        'message' => 'Hey. I have a question: will you read this <a href="http://www.justinbieber.com" rel="nofollow">http://www.justinbieber.com</a> ?'
     193                                ),
     194                                array(
     195                                        'time' => '',
     196                                        'author' => 'Nacin',
     197                                        'message' => 'Go away.'
     198                                )
     199                        )
     200                );
     201                $this->assertEquals( $stanzas, $expected );
     202
     203                $data =<<<DATA
     204Scott: Hey.
     205I have a question: what is your favorite color?
     206Nacin: Go away.
     207
     208Nacin hates color.
     209DATA;
     210
     211                $stanzas = get_content_chat( $data );
     212                $expected = array(
     213                        array(
     214                                array(
     215                                        'time' => '',
     216                                        'author' => 'Scott',
     217                                        'message' => 'Hey. I have a question: what is your favorite color?'
     218                                ),
     219                                array(
     220                                        'time' => '',
     221                                        'author' => 'Nacin',
     222                                        'message' => 'Go away.'
     223                                )
     224                        )
     225                );
     226                $this->assertEquals( $stanzas, $expected );
     227
     228                $data =<<<DATA
     229Scott: Hey.
     230Nacin: Go away.
     231
     232Helen: Hey.
     233Nacin: Go away.
     234DATA;
     235
     236                $stanzas = get_content_chat( $data );
     237                $expected = array(
     238                        array(
     239                                array(
     240                                        'time' => '',
     241                                        'author' => 'Scott',
     242                                        'message' => 'Hey.'
     243                                ),
     244                                array(
     245                                        'time' => '',
     246                                        'author' => 'Nacin',
     247                                        'message' => 'Go away.'
     248                                )
     249
     250                        ),
     251                        array(
     252                                array(
     253                                        'time' => '',
     254                                        'author' => 'Helen',
     255                                        'message' => 'Hey.'
     256                                ),
     257                                array(
     258                                        'time' => '',
     259                                        'author' => 'Nacin',
     260                                        'message' => 'Go away.'
     261                                )
     262                        )
     263                );
     264                $this->assertEquals( $stanzas, $expected );
     265
     266                $data =<<<DATA
     267
     268Scott: Hey.
     269Nacin: Go away.
     270
     271Helen: Hey.
     272Nacin: Go away.
     273
     274Nacin appears busy today.
     275DATA;
     276
     277                $stanzas = get_content_chat( $data );
     278                $this->assertEquals( $stanzas, $expected );
     279
     280                $data =<<<DATA
     281Scott: Hey.
     282I have a question: what is your favorite color?
     283Nacin: Go away.
     284
     285Helen: Hey.
     286I have a question: what is your favorite pizza topping?
     287Nacin: Go away.
     288DATA;
     289
     290                $stanzas = get_content_chat( $data );
     291                $expected = array(
     292                        array(
     293                                array(
     294                                        'time' => '',
     295                                        'author' => 'Scott',
     296                                        'message' => 'Hey. I have a question: what is your favorite color?'
     297                                ),
     298                                array(
     299                                        'time' => '',
     300                                        'author' => 'Nacin',
     301                                        'message' => 'Go away.'
     302                                )
     303                        ),
     304                        array(
     305                                array(
     306                                        'time' => '',
     307                                        'author' => 'Helen',
     308                                        'message' =>  'Hey. I have a question: what is your favorite pizza topping?'
     309                                ),
     310                                array(
     311                                        'time' => '',
     312                                        'author' => 'Nacin',
     313                                        'message' => 'Go away.'
     314                                )
     315                        )
     316                );
     317                $this->assertEquals( $stanzas, $expected );
     318
     319                $data =<<<DATA
     320Scott: Hey.
     321I have a question: what is your favorite color?
     322Nacin: Go away.
     323
     324Helen: Hey.
     325I have a question: what is your favorite pizza topping?
     326Nacin: Go away.
     327
     328Nacin hates color and pizza.
     329DATA;
     330
     331                $stanzas = get_content_chat( $data );
     332                $this->assertEquals( $stanzas, $expected );
     333
     334                $data =<<<DATA
     335[3/7/13 11:19:33 AM] Helen Hou-Sandi: I like Apples.
     336[3/7/13 11:29:31 AM] Scott Taylor: word
     337DATA;
     338
     339                $expected = array(
     340                        array(
     341                                array(
     342                                        'time' => '[3/7/13 11:19:33 AM]',
     343                                        'author' => 'Helen Hou-Sandi',
     344                                        'message' => 'I like Apples.'
     345                                ),
     346                                array(
     347                                        'time' => '[3/7/13 11:29:31 AM]',
     348                                        'author' => 'Scott Taylor',
     349                                        'message' => 'word'
     350                                ),
     351                        )
     352                );
     353
     354                $stanzas = get_content_chat( $data );
     355                $this->assertEquals( $stanzas, $expected );
     356
     357                $data =<<<DATA
     358[3/5/13 2:30:09 PM] Scott Taylor: https://github.com/johndyer/mediaelement
     359[3/5/13 2:30:15 PM] Scott Taylor: MIT
     360[3/5/13 2:31:13 PM] Andrew Nacin: https://github.com/johndyer/mediaelement/issues?labels=Wordpress
     361DATA;
     362
     363                $expected = array(
     364                        array(
     365                                array(
     366                                        'time' => '[3/5/13 2:30:09 PM]',
     367                                        'author' => 'Scott Taylor',
     368                                        'message' => '<a href="https://github.com/johndyer/mediaelement" rel="nofollow">https://github.com/johndyer/mediaelement</a>'
     369                                ),
     370                                array(
     371                                        'time' => '[3/5/13 2:30:15 PM]',
     372                                        'author' => 'Scott Taylor',
     373                                        'message' => 'MIT'
     374                                ),
     375                                array(
     376                                        'time' => '[3/5/13 2:31:13 PM]',
     377                                        'author' => 'Andrew Nacin',
     378                                        'message' => '<a href="https://github.com/johndyer/mediaelement/issues?labels=Wordpress" rel="nofollow">https://github.com/johndyer/mediaelement/issues?labels=Wordpress</a>'
     379                                ),
     380                        )
     381                );
     382
     383                $stanzas = get_content_chat( $data );
     384                $this->assertEquals( $stanzas, $expected );
     385
     386                $data = <<<DATA
     387Nigel Tufnel: The numbers all go to eleven. Look, right across the board, eleven, eleven, eleven and…
     388
     389Marti DiBergi: Oh, I see. And most amps go up to ten?
     390
     391Nigel Tufnel: Exactly.
     392
     393Marti DiBergi: Does that mean it’s louder? Is it any louder?
     394
     395Nigel 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?
     396
     397Marti DiBergi: I don’t know.
     398
     399Nigel Tufnel: Nowhere. Exactly. What we do is, if we need that extra push over the cliff, you know what we do?
     400
     401Marti DiBergi: Put it up to eleven.
     402
     403Nigel Tufnel: Eleven. Exactly. One louder.
     404
     405Marti DiBergi: Why don’t you just make ten louder and make ten be the top number and make that a little louder?
     406
     407Nigel Tufnel: These go to eleven.
     408DATA;
     409
     410                $expected = array(
     411                        array(
     412                                array(
     413                                        'time' => '',
     414                                        'author' => 'Nigel Tufnel',
     415                                        'message' => 'The numbers all go to eleven. Look, right across the board, eleven, eleven, eleven and…'
     416                                )
     417                        ),
     418                        array(
     419                                array(
     420                                        'time' => '',
     421                                        'author' => 'Marti DiBergi',
     422                                        'message' => 'Oh, I see. And most amps go up to ten?'
     423                                )
     424                        ),
     425                        array(
     426                                array(
     427                                        'time' => '',
     428                                        'author' => 'Nigel Tufnel',
     429                                        'message' => 'Exactly.'
     430                                )
     431                        ),
     432                        array(
     433                                array(
     434                                        'time' => '',
     435                                        'author' => 'Marti DiBergi',
     436                                        'message' => 'Does that mean it’s louder? Is it any louder?'
     437                                )
     438                        ),
     439                        array(
     440                                array(
     441                                        'time' => '',
     442                                        'author' => 'Nigel Tufnel',
     443                                        '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?'
     444                                )
     445                        ),
     446                        array(
     447                                array(
     448                                        'time' => '',
     449                                        'author' => 'Marti DiBergi',
     450                                        'message' => 'I don’t know.'
     451                                )
     452                        ),
     453                        array(
     454                                array(
     455                                        'time' => '',
     456                                        'author' => 'Nigel Tufnel',
     457                                        'message' => 'Nowhere. Exactly. What we do is, if we need that extra push over the cliff, you know what we do?'
     458                                )
     459                        ),
     460                        array(
     461                                array(
     462                                        'time' => '',
     463                                        'author' => 'Marti DiBergi',
     464                                        'message' => 'Put it up to eleven.'
     465                                )
     466                        ),
     467                        array(
     468                                array(
     469                                        'time' => '',
     470                                        'author' => 'Nigel Tufnel',
     471                                        'message' => 'Eleven. Exactly. One louder.'
     472                                )
     473                        ),
     474                        array(
     475                                array(
     476                                        'time' => '',
     477                                        'author' => 'Marti DiBergi',
     478                                        'message' => 'Why don’t you just make ten louder and make ten be the top number and make that a little louder?'
     479                                )
     480                        ),
     481                        array(
     482                                array(
     483                                        'time' => '',
     484                                        'author' => 'Nigel Tufnel',
     485                                        'message' => 'These go to eleven.'
     486                                )
     487                        ),
     488                );
     489                $stanzas = get_content_chat( $data );
     490                $this->assertEquals( $stanzas, $expected );
     491        }
    96492}
     493 No newline at end of file