Compare commits
No commits in common. "master" and "1.0.4" have entirely different histories.
13 changed files with 141 additions and 272 deletions
1
.coveralls.yml
Normal file
1
.coveralls.yml
Normal file
|
@ -0,0 +1 @@
|
|||
service_name: travis-ci
|
29
.github/workflows/test.yml
vendored
29
.github/workflows/test.yml
vendored
|
@ -1,29 +0,0 @@
|
|||
name: Test
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
test:
|
||||
name: Test PHP ${{ matrix.php-version }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
php-version: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-version }}
|
||||
- name: PHP Version
|
||||
run: php --version
|
||||
- name: Composer Version
|
||||
run: composer --version
|
||||
- name: Install Dependencies
|
||||
run: COMPOSER_MEMORY_LIMIT=-1 composer install
|
||||
- name: Run Tests
|
||||
run: vendor/bin/phpunit --coverage-clover ./coverage.xml
|
||||
- name: Upload Coverage
|
||||
if: ${{ matrix.php-version == '8.1' }}
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
file: ./coverage.xml
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,4 +0,0 @@
|
|||
composer.lock
|
||||
composer.phar
|
||||
.phpunit.result.cache
|
||||
/vendor/
|
40
.travis.yml
Normal file
40
.travis.yml
Normal file
|
@ -0,0 +1,40 @@
|
|||
language: php
|
||||
dist: bionic
|
||||
sudo: required
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.3
|
||||
dist: precise
|
||||
- php: 5.4
|
||||
dist: trusty
|
||||
- php: 5.5
|
||||
dist: trusty
|
||||
- php: 5.6
|
||||
dist: trusty
|
||||
- php: 7.0
|
||||
dist: xenial
|
||||
env: PHPUNIT=5.7
|
||||
- php: 7.1
|
||||
- php: 7.2
|
||||
- php: 7.3
|
||||
|
||||
install:
|
||||
- composer install
|
||||
- if [[ $PHPUNIT == 5.7 ]]; then composer require "phpunit/phpunit:5.7"; fi
|
||||
|
||||
before_script:
|
||||
- mkdir -p build/logs
|
||||
- cd tests
|
||||
|
||||
script:
|
||||
- |
|
||||
if [[ $PHPUNIT == 5.7 ]]; then
|
||||
../vendor/bin/phpunit --colors --coverage-clover ../build/logs/clover.xml .
|
||||
else
|
||||
phpunit --colors --coverage-clover ../build/logs/clover.xml .
|
||||
fi
|
||||
|
||||
after_success:
|
||||
- cd ..
|
||||
- php vendor/bin/coveralls --config .coveralls.yml -v
|
|
@ -1 +0,0 @@
|
|||
github: joshtronic
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2022 Josh Sherman
|
||||
Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019 Josh Sherman
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
12
README.md
12
README.md
|
@ -1,13 +1,13 @@
|
|||
# php-loremipsum
|
||||
|
||||
[](https://github.com/joshtronic/php-loremipsum/blob/master/LICENSE)
|
||||

|
||||
[](https://github.com/joshtronic/php-loremipsum/actions)
|
||||
[](https://codecov.io/gh/joshtronic/php-loremipsum)
|
||||
[](https://packagist.org/packages/joshtronic/php-loremipsum)
|
||||
[](https://travis-ci.org/joshtronic/php-loremipsum)
|
||||
[](https://coveralls.io/github/joshtronic/php-loremipsum?branch=master)
|
||||
[](https://packagist.org/packages/joshtronic/php-loremipsum)
|
||||
|
||||
Lorem ipsum generator in PHP without dependencies. Compatible with PHP 5.3+.
|
||||
|
||||
[](https://www.patreon.com/joshtronic)
|
||||
|
||||
## Installation
|
||||
|
||||
The preferred installation method is via `composer`. First add the following to
|
||||
|
@ -105,7 +105,7 @@ Suggestions and bug reports are always welcome, but karma points are earned for
|
|||
pull requests.
|
||||
|
||||
Unit tests are required for all contributions. You can run the test suite from
|
||||
the project's root directory simply by running `phpunit`.
|
||||
the `tests` directory simply by running `phpunit .`
|
||||
|
||||
## Credits
|
||||
|
||||
|
|
20
codecov.yml
20
codecov.yml
|
@ -1,20 +0,0 @@
|
|||
codecov:
|
||||
require_ci_to_pass: yes
|
||||
|
||||
coverage:
|
||||
precision: 2
|
||||
round: down
|
||||
range: "70...100"
|
||||
|
||||
parsers:
|
||||
gcov:
|
||||
branch_detection:
|
||||
conditional: yes
|
||||
loop: yes
|
||||
method: no
|
||||
macro: no
|
||||
|
||||
comment:
|
||||
layout: "reach,diff,flags,tree"
|
||||
behavior: default
|
||||
require_changes: no
|
|
@ -1,34 +1,31 @@
|
|||
{
|
||||
"name": "joshtronic/php-loremipsum",
|
||||
"description": "Lorem ipsum generator in PHP without dependencies",
|
||||
"version": "2.1.0",
|
||||
"version": "1.0.4",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"lorem",
|
||||
"ipsum",
|
||||
"generator"
|
||||
"lorem",
|
||||
"ipsum",
|
||||
"generator"
|
||||
],
|
||||
"homepage": "https://github.com/joshtronic/php-loremipsum",
|
||||
"license": "MIT",
|
||||
"authors": [{
|
||||
"name": "Josh Sherman",
|
||||
"email": "hello@joshtronic.com",
|
||||
"homepage": "https://joshtronic.com"
|
||||
}],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Josh Sherman",
|
||||
"email": "hello@joshtronic.com",
|
||||
"homepage": "https://joshtronic.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.36 || ^9.0"
|
||||
"satooshi/php-coveralls": "~1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"joshtronic\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"joshtronic\\Tests\\": "tests/"
|
||||
}
|
||||
"psr-4": {
|
||||
"joshtronic\\": "src/"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
14
phpstan.neon
14
phpstan.neon
|
@ -1,14 +0,0 @@
|
|||
parameters:
|
||||
|
||||
paths:
|
||||
- src
|
||||
|
||||
# The level 8 is the highest level
|
||||
level: max
|
||||
|
||||
excludePaths:
|
||||
- ./*/*/FileToBeExcluded.php
|
||||
|
||||
checkMissingIterableValueType: true
|
||||
|
||||
#editorUrl: 'vscode://file/%%file%%:%%line%%'
|
24
phpunit.xml
24
phpunit.xml
|
@ -1,24 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
failOnRisky="true"
|
||||
stopOnError="true"
|
||||
stopOnFailure="true"
|
||||
stopOnIncomplete="true"
|
||||
verbose="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Lorem Ipsum">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist addUncoveredFilesFromWhitelist="true">
|
||||
<directory>./src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
|
@ -9,7 +9,7 @@
|
|||
* Redistribution of these files must retain the above copyright notice.
|
||||
*
|
||||
* @author Josh Sherman <hello@joshtronic.com>
|
||||
* @copyright Copyright 2014-2022 Josh Sherman
|
||||
* @copyright Copyright 2014, 2015, 2016, 2017, 2018, 2019 Josh Sherman
|
||||
* @license http://www.opensource.org/licenses/mit-license.html
|
||||
* @link https://github.com/joshtronic/php-loremipsum
|
||||
*/
|
||||
|
@ -24,7 +24,7 @@ class LoremIpsum
|
|||
* Whether or not we should be starting the string with "Lorem ipsum..."
|
||||
*
|
||||
* @access private
|
||||
* @var mixed
|
||||
* @var boolean
|
||||
*/
|
||||
private $first = true;
|
||||
|
||||
|
@ -35,9 +35,9 @@ class LoremIpsum
|
|||
* a complete list exists and if so, where to get it.
|
||||
*
|
||||
* @access private
|
||||
* @var array<string>
|
||||
* @var array
|
||||
*/
|
||||
private $words = array(
|
||||
public $words = array(
|
||||
// Lorem ipsum...
|
||||
'lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit',
|
||||
|
||||
|
@ -83,7 +83,7 @@ class LoremIpsum
|
|||
*/
|
||||
public function word($tags = false)
|
||||
{
|
||||
return strval($this->words(1, $tags));
|
||||
return $this->words(1, $tags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,7 +94,7 @@ class LoremIpsum
|
|||
* @access public
|
||||
* @param integer $count how many words to generate
|
||||
* @param mixed $tags string or array of HTML tags to wrap output with
|
||||
* @return mixed generated lorem ipsum words
|
||||
* @return array generated lorem ipsum words
|
||||
*/
|
||||
public function wordsArray($count = 1, $tags = false)
|
||||
{
|
||||
|
@ -114,7 +114,6 @@ class LoremIpsum
|
|||
*/
|
||||
public function words($count = 1, $tags = false, $array = false)
|
||||
{
|
||||
$count = (int) $count;
|
||||
$words = array();
|
||||
$word_count = 0;
|
||||
|
||||
|
@ -152,7 +151,7 @@ class LoremIpsum
|
|||
*/
|
||||
public function sentence($tags = false)
|
||||
{
|
||||
return strval($this->sentences(1, $tags));
|
||||
return $this->sentences(1, $tags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,7 +162,7 @@ class LoremIpsum
|
|||
* @access public
|
||||
* @param integer $count how many sentences to generate
|
||||
* @param mixed $tags string or array of HTML tags to wrap output with
|
||||
* @return mixed generated lorem ipsum sentences
|
||||
* @return array generated lorem ipsum sentences
|
||||
*/
|
||||
public function sentencesArray($count = 1, $tags = false)
|
||||
{
|
||||
|
@ -205,7 +204,7 @@ class LoremIpsum
|
|||
*/
|
||||
public function paragraph($tags = false)
|
||||
{
|
||||
return strval($this->paragraphs(1, $tags));
|
||||
return $this->paragraphs(1, $tags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -216,18 +215,15 @@ class LoremIpsum
|
|||
* @access public
|
||||
* @param integer $count how many paragraphs to generate
|
||||
* @param mixed $tags string or array of HTML tags to wrap output with
|
||||
* @return array<string> generated lorem ipsum paragraphs
|
||||
* @return array generated lorem ipsum paragraphs
|
||||
*/
|
||||
public function paragraphsArray($count = 1, $tags = false)
|
||||
{
|
||||
// The $array parameter set to true means an array is returned.
|
||||
// Return type is mixed, we should probably cast to array.
|
||||
// @phpstan-ignore-next-line
|
||||
return $this->paragraphs($count, $tags, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Paragraphs
|
||||
* Paragraphss
|
||||
*
|
||||
* Generates paragraphs of lorem ipsum.
|
||||
*
|
||||
|
@ -242,13 +238,10 @@ class LoremIpsum
|
|||
$paragraphs = array();
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$paragraphs[] = strval($this->sentences($this->gauss(5.8, 1.93)));
|
||||
$paragraphs[] = $this->sentences($this->gauss(5.8, 1.93));
|
||||
}
|
||||
|
||||
if ($array) {
|
||||
return $this->output($paragraphs, $tags, $array, "\n\n");
|
||||
}
|
||||
return strval($this->output($paragraphs, $tags, false, "\n\n"));
|
||||
return $this->output($paragraphs, $tags, $array, "\n\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,7 +255,7 @@ class LoremIpsum
|
|||
* @access private
|
||||
* @param double $mean average value
|
||||
* @param double $std_dev stadnard deviation
|
||||
* @return int calculated distribution
|
||||
* @return double calculated distribution
|
||||
*/
|
||||
private function gauss($mean, $std_dev)
|
||||
{
|
||||
|
@ -270,7 +263,7 @@ class LoremIpsum
|
|||
$y = mt_rand() / mt_getrandmax();
|
||||
$z = sqrt(-2 * log($x)) * cos(2 * pi() * $y);
|
||||
|
||||
return intval($z * $std_dev + $mean);
|
||||
return $z * $std_dev + $mean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -280,7 +273,6 @@ class LoremIpsum
|
|||
* the first time we are generating the text.
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
private function shuffle()
|
||||
{
|
||||
|
@ -306,18 +298,18 @@ class LoremIpsum
|
|||
* first word of the sentence.
|
||||
*
|
||||
* @access private
|
||||
* @param array<string> $sentences the sentences we would like to punctuate
|
||||
* @return void
|
||||
* @param array $sentences the sentences we would like to punctuate
|
||||
*/
|
||||
private function punctuate(&$sentences)
|
||||
{
|
||||
foreach ($sentences as $key => $sentence) {
|
||||
$words = count($sentence);
|
||||
|
||||
// Only worry about commas on sentences longer than 4 words
|
||||
if ($words > 4) {
|
||||
$mean = log($words, 6);
|
||||
$std_dev = $mean / 6;
|
||||
$commas = $this->gauss($mean, $std_dev);
|
||||
$commas = round($this->gauss($mean, $std_dev));
|
||||
|
||||
for ($i = 1; $i <= $commas; $i++) {
|
||||
$word = round($i * $words / ($commas + 1));
|
||||
|
@ -341,7 +333,7 @@ class LoremIpsum
|
|||
* into a string or not.
|
||||
*
|
||||
* @access private
|
||||
* @param array<string> $strings an array of generated strings
|
||||
* @param array $strings an array of generated strings
|
||||
* @param mixed $tags string or array of HTML tags to wrap output with
|
||||
* @param boolean $array whether an array or a string should be returned
|
||||
* @param string $delimiter the string to use when calling implode()
|
||||
|
@ -359,13 +351,11 @@ class LoremIpsum
|
|||
|
||||
foreach ($strings as $key => $string) {
|
||||
foreach ($tags as $tag) {
|
||||
if (is_string($tag)) {
|
||||
// Detects / applies back reference
|
||||
if ($tag[0] == '<') {
|
||||
$string = str_replace('$1', $string, $tag);
|
||||
} else {
|
||||
$string = sprintf('<%1$s>%2$s</%1$s>', $tag, $string);
|
||||
}
|
||||
// Detects / applies back reference
|
||||
if ($tag[0] == '<') {
|
||||
$string = str_replace('$1', $string, $tag);
|
||||
} else {
|
||||
$string = sprintf('<%1$s>%2$s</%1$s>', $tag, $string);
|
||||
}
|
||||
|
||||
$strings[$key] = $string;
|
||||
|
@ -380,3 +370,4 @@ class LoremIpsum
|
|||
return $strings;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,198 +1,130 @@
|
|||
<?php
|
||||
namespace joshtronic\Tests;
|
||||
use joshtronic\LoremIpsum;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LoremIpsumTest extends TestCase
|
||||
require_once '../src/LoremIpsum.php';
|
||||
|
||||
if (
|
||||
!class_exists('\PHPUnit_Framework_TestCase')
|
||||
&& class_exists('\PHPUnit\Framework\TestCase')
|
||||
) {
|
||||
class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
|
||||
}
|
||||
|
||||
class LoremIpsumTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @doesNotPerformAssertions
|
||||
*/
|
||||
public function testAssertRegExp() {
|
||||
if (version_compare(PHP_VERSION, '7.3.0', '>=')) {
|
||||
return 'assertMatchesRegularExpression';
|
||||
}
|
||||
private $lipsum;
|
||||
|
||||
return 'assertRegExp';
|
||||
public function setUp()
|
||||
{
|
||||
$this->lipsum = new joshtronic\LoremIpsum();
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAssertRegExp
|
||||
*/
|
||||
public function testWord($assertRegExp)
|
||||
public function testWord()
|
||||
{
|
||||
$lipsum = new LoremIpsum();
|
||||
$this->$assertRegExp('/^[a-z]+$/i', $lipsum->word());
|
||||
$this->assertRegExp('/^[a-z]+$/i', $this->lipsum->word());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAssertRegExp
|
||||
*/
|
||||
public function testWords($assertRegExp)
|
||||
public function testWords()
|
||||
{
|
||||
$lipsum = new LoremIpsum();
|
||||
$this->$assertRegExp(
|
||||
$this->assertRegExp(
|
||||
'/^[a-z]+ [a-z]+ [a-z]+$/i',
|
||||
$lipsum->words(3)
|
||||
$this->lipsum->words(3)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAssertRegExp
|
||||
*/
|
||||
public function testWordsArray($assertRegExp)
|
||||
public function testWordsArray()
|
||||
{
|
||||
$lipsum = new LoremIpsum();
|
||||
$words = $lipsum->wordsArray(3);
|
||||
$words = $this->lipsum->wordsArray(3);
|
||||
$this->assertTrue(is_array($words));
|
||||
$this->assertCount(3, $words);
|
||||
|
||||
foreach ($words as $word) {
|
||||
$this->$assertRegExp('/^[a-z]+$/i', $word);
|
||||
$this->assertRegExp('/^[a-z]+$/i', $word);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAssertRegExp
|
||||
*/
|
||||
public function testWordsExceedingVocab($assertRegExp)
|
||||
public function testWordsExceedingVocab()
|
||||
{
|
||||
$lipsum = new LoremIpsum();
|
||||
$this->assertCount(500, $lipsum->wordsArray(500));
|
||||
$this->assertCount(500, $this->lipsum->wordsArray(500));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAssertRegExp
|
||||
*/
|
||||
public function testSentence($assertRegExp)
|
||||
public function testSentence()
|
||||
{
|
||||
$lipsum = new LoremIpsum();
|
||||
$this->$assertRegExp('/^[a-z, ]+\.$/i', $lipsum->sentence());
|
||||
$this->assertRegExp('/^[a-z, ]+\.$/i', $this->lipsum->sentence());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAssertRegExp
|
||||
*/
|
||||
public function testSentences($assertRegExp)
|
||||
public function testSentences()
|
||||
{
|
||||
$lipsum = new LoremIpsum();
|
||||
$this->$assertRegExp(
|
||||
'/^[a-z, ]+\. [a-z, ]+\. [a-z, ]+\.$/i',
|
||||
$lipsum->sentences(3)
|
||||
);
|
||||
$this->assertRegExp('/^[a-z, ]+\. [a-z, ]+\. [a-z, ]+\.$/i', $this->lipsum->sentences(3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAssertRegExp
|
||||
*/
|
||||
public function testSentencesArray($assertRegExp)
|
||||
public function testSentencesArray()
|
||||
{
|
||||
$lipsum = new LoremIpsum();
|
||||
$sentences = $lipsum->sentencesArray(3);
|
||||
$sentences = $this->lipsum->sentencesArray(3);
|
||||
$this->assertTrue(is_array($sentences));
|
||||
$this->assertCount(3, $sentences);
|
||||
|
||||
foreach ($sentences as $sentence) {
|
||||
$this->$assertRegExp('/^[a-z, ]+\.$/i', $sentence);
|
||||
$this->assertRegExp('/^[a-z, ]+\.$/i', $sentence);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAssertRegExp
|
||||
*/
|
||||
public function testParagraph($assertRegExp)
|
||||
public function testParagraph()
|
||||
{
|
||||
$lipsum = new LoremIpsum();
|
||||
$this->$assertRegExp('/^([a-z, ]+\.)+$/i', $lipsum->paragraph());
|
||||
$this->assertRegExp('/^([a-z, ]+\.)+$/i', $this->lipsum->paragraph());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAssertRegExp
|
||||
*/
|
||||
public function testParagraphs($assertRegExp)
|
||||
public function testParagraphs()
|
||||
{
|
||||
$lipsum = new LoremIpsum();
|
||||
$this->$assertRegExp(
|
||||
$this->assertRegExp(
|
||||
'/^([a-z, ]+\.)+\n\n([a-z, ]+\.)+\n\n([a-z, ]+\.)+$/i',
|
||||
$lipsum->paragraphs(3)
|
||||
$this->lipsum->paragraphs(3)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAssertRegExp
|
||||
*/
|
||||
public function testParagraphsArray($assertRegExp)
|
||||
public function testParagraphsArray()
|
||||
{
|
||||
$lipsum = new LoremIpsum();
|
||||
$paragraphs = $lipsum->paragraphsArray(3);
|
||||
$paragraphs = $this->lipsum->paragraphsArray(3);
|
||||
$this->assertTrue(is_array($paragraphs));
|
||||
$this->assertCount(3, $paragraphs);
|
||||
|
||||
foreach ($paragraphs as $paragraph) {
|
||||
$this->$assertRegExp('/^([a-z, ]+\.)+$/i', $paragraph);
|
||||
$this->assertRegExp('/^([a-z, ]+\.)+$/i', $paragraph);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAssertRegExp
|
||||
*/
|
||||
public function testMarkupString($assertRegExp)
|
||||
public function testMarkupString()
|
||||
{
|
||||
$lipsum = new LoremIpsum();
|
||||
$this->$assertRegExp(
|
||||
$this->assertRegExp(
|
||||
'/^<li>[a-z]+<\/li>$/i',
|
||||
$lipsum->word('li')
|
||||
$this->lipsum->word('li')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAssertRegExp
|
||||
*/
|
||||
public function testMarkupArray($assertRegExp)
|
||||
public function testMarkupArray()
|
||||
{
|
||||
$lipsum = new LoremIpsum();
|
||||
$this->$assertRegExp(
|
||||
$this->assertRegExp(
|
||||
'/^<div><p>[a-z]+<\/p><\/div>$/i',
|
||||
$lipsum->word(array('div', 'p'))
|
||||
$this->lipsum->word(array('div', 'p'))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAssertRegExp
|
||||
*/
|
||||
public function testMarkupBackReference($assertRegExp)
|
||||
public function testMarkupBackReference()
|
||||
{
|
||||
$lipsum = new LoremIpsum();
|
||||
$this->$assertRegExp(
|
||||
$this->assertRegExp(
|
||||
'/^<li><a href="[a-z]+">[a-z]+<\/a><\/li>$/i',
|
||||
$lipsum->word('<li><a href="$1">$1</a></li>')
|
||||
$this->lipsum->word('<li><a href="$1">$1</a></li>')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAssertRegExp
|
||||
*/
|
||||
public function testMarkupArrayReturn($assertRegExp)
|
||||
public function testMarkupArrayReturn()
|
||||
{
|
||||
$lipsum = new LoremIpsum();
|
||||
$words = $lipsum->wordsArray(3, 'li');
|
||||
$words = $this->lipsum->wordsArray(3, 'li');
|
||||
$this->assertTrue(is_array($words));
|
||||
$this->assertCount(3, $words);
|
||||
|
||||
foreach ($words as $word) {
|
||||
$this->$assertRegExp('/^<li>[a-z]+<\/li>$/i', $word);
|
||||
$this->assertRegExp('/^<li>[a-z]+<\/li>$/i', $word);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAssertRegExp
|
||||
*/
|
||||
public function testSkipNonStringTag($assertRegExp)
|
||||
{
|
||||
$lipsum = new LoremIpsum();
|
||||
$this->$assertRegExp('/^[a-z]+$/i', $lipsum->word(123));
|
||||
$this->$assertRegExp('/^[a-z]+$/i', $lipsum->word(array(1, 2, 3)));
|
||||
$this->$assertRegExp('/^[a-z]+$/i', $lipsum->word(true));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue