Compare commits
No commits in common. "4bb53fbdf74c92a5ee140bd52303329098e0a70c" and "039fd102ae5eb88fd0c37ab9547d6d2aa3b598fb" have entirely different histories.
4bb53fbdf7
...
039fd102ae
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^10"
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -51,7 +51,6 @@ class StringBuilder {
|
|||
* @return void
|
||||
*/
|
||||
public function __construct(bool $unique=false) {
|
||||
$this->unique = $unique;
|
||||
$this->parts = [];
|
||||
$this->vars = [];
|
||||
}
|
||||
|
@ -177,9 +176,6 @@ class StringBuilder {
|
|||
*/
|
||||
public function setParts(array $parts=[]) : StringBuilder {
|
||||
$this->parts = $parts;
|
||||
if($this->unique) {
|
||||
$this->parts = array_unique($this->parts);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\AppBundle;
|
||||
|
||||
include_once(__DIR__.'/../vendor/autoload.php');
|
||||
require_once(__DIR__.'/../src/class.StringBuilder.php');
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class StringBuilderTest extends TestCase {
|
||||
|
||||
public function testSettingVariable() {
|
||||
$sb = new \NAE\String\StringBuilder();
|
||||
$sb->setVar("t1", "test1")->setVar("t2", "test2");
|
||||
$this->assertEquals($sb->getVars(), ["t1" => "test1", "t2" => "test2"]);
|
||||
}
|
||||
|
||||
public function testAppendString() {
|
||||
$sb = new \NAE\String\StringBuilder();
|
||||
$sb->append("test1")->append("test2");
|
||||
$this->assertEquals($sb->getParts(), ["test1", "test2"]);
|
||||
}
|
||||
|
||||
public function testJoinString() {
|
||||
$sb = new \NAE\String\StringBuilder();
|
||||
$sb->append("test1")->append("test2");
|
||||
$sb->setSeperator(";");
|
||||
$this->assertEquals($sb->join(), "test1;test2");
|
||||
}
|
||||
|
||||
public function testJoinUniqueString() {
|
||||
$sb = new \NAE\String\StringBuilder();
|
||||
$sb->append("test1")->append("test2")->append("test1");
|
||||
$sb->setSeperator(";");
|
||||
$this->assertEquals($sb->joinUnique(), "test1;test2");
|
||||
}
|
||||
|
||||
public function testContainsPart() {
|
||||
$sb = new \NAE\String\StringBuilder();
|
||||
$sb->append("test1")->append("test2");
|
||||
$this->assertTrue($sb->contains("test1"));
|
||||
$this->assertTrue($sb->contains("test2"));
|
||||
$this->assertFalse($sb->contains("test3"));
|
||||
}
|
||||
|
||||
public function testJoinInitUniqueString() {
|
||||
$sb = new \NAE\String\StringBuilder(true);
|
||||
$sb->append("test1")->append("test2")->append("test1");
|
||||
$sb->setSeperator(";");
|
||||
$this->assertEquals($sb->join(), "test1;test2");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue