Commit 7c26d3d7 authored by Claudio Ludovico Panetta's avatar Claudio Ludovico Panetta 馃嚭馃嚫

Add tests for v1 馃帀

parent b33898bc
......@@ -20,4 +20,7 @@
<directory>src/</directory>
</whitelist>
</filter>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
</php>
</phpunit>
......@@ -27,7 +27,7 @@ final class Slugify
/**
* @var array
*/
protected $basket = [];
public $basket = [];
/**
* Slugify constructor.
......
......@@ -6,20 +6,8 @@ namespace Ludo237\Slugify\Tests;
* HelpersTest
* @package Ludo237\Slugify\Tests
*/
final class HelpersTest extends \Orchestra\Testbench\TestCase
final class HelpersTest extends TestCase
{
protected function getPackageProviders($app)
{
return [\Ludo237\Slugify\SlugifyServiceProvider::class];
}
protected function getPackageAliases($app)
{
return [
"Slugify" => \Ludo237\Slugify\Facades\Slugify::class
];
}
/** @test */
public function it_generates_a_random_slug()
{
......@@ -32,11 +20,4 @@ final class HelpersTest extends \Orchestra\Testbench\TestCase
$this->assertCount(3, $this->explode(slugify()));
$this->assertCount(4, $this->explode(slugify(4)));
}
private function explode(string $string) : array
{
$string = preg_replace('/(?<!^)([A-Z])/', '-\\1', $string);
return explode("-", $string);
}
}
\ No newline at end of file
<?php
namespace Ludo237\Slugify\Tests;
use Ludo237\Slugify\Slugify;
/**
* SlugifyTest
* @package Ludo237\Slugify\Tests
*/
final class SlugifyTest extends TestCase
{
/** @var Ludo237\Slugify\Slugify */
private $mock;
public function setUp()
{
parent::setUp();
$this->mock = app("slugify");
}
/** @test */
public function it_has_an_empty_basket_when_starts()
{
$this->assertInternalType("array", $this->mock->basket);
$this->assertEquals(0, count($this->mock->basket));
}
/** @test */
public function it_generates_a_random_slug()
{
$this->assertNotNull($this->mock->slugify());
}
/** @test */
public function slugify_accepts_a_length_as_variable()
{
$this->assertCount(3, $this->explode($this->mock->slugify()));
$this->assertCount(4, $this->explode($this->mock->slugify(4)));
}
}
\ No newline at end of file
<?php
namespace Ludo237\Slugify\Tests;
/**
* TestCase
* @package Ludo237\Slugify\Tests
*/
abstract class TestCase extends \Orchestra\Testbench\TestCase
{
protected function getPackageProviders($app)
{
return [\Ludo237\Slugify\SlugifyServiceProvider::class];
}
protected function getPackageAliases($app)
{
return [
"Slugify" => \Ludo237\Slugify\Facades\Slugify::class
];
}
protected function explode(string $string) : array
{
$string = preg_replace('/(?<!^)([A-Z])/', '-\\1', $string);
return explode("-", $string);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment