/var/www/vhosts/ihelp.ro/httpdocs/vendor/mirko-pagliai/php-tools/tests/TestCase
NameSizeModeActions
Event/-0755rm
TestSuite/-0755rm
ArrayFunctionsTest.php55940644editdlrm
BodyParserTest.php30920644editdlrm
DebugFunctionsTest.php9840644editdlrm
DeprecationFunctionsTest.php12160644editdlrm
EntityTest.php60000644editdlrm
ExceptionistTest.php130230644editdlrm
FilesystemTest.php138220644editdlrm
GlobalFunctionsTest.php59530644editdlrm
NetworkFunctionsTest.php66100644editdlrm
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/mirko-pagliai/php-tools/tests/TestCase/EntityTest.php (6000B)
Entity = new EntityExample(['code' => 200]); } /** * Test for `__debugInfo()` method * @uses \Tools\Entity::__debugInfo() * @test */ public function testDebugInfo(): void { ob_start(); $expectedLine = __LINE__ + 1; debug($this->Entity); $dump = ob_get_clean() ?: ''; $this->assertStringContainsString(EntityExample::class, $dump); $this->skipIf(IS_WIN); $this->assertStringContainsString(__FILE__ . ' (line ' . $expectedLine . ')', $dump); $this->assertStringContainsString('########## DEBUG ##########', $dump); $this->assertStringContainsString('App\EntityExample {', $dump); } /** * Test for `has()` method * @uses \Tools\Entity::has() * @test */ public function testHas(): void { $this->assertTrue($this->Entity->has('code')); $this->assertFalse($this->Entity->has('noExisting')); //`has()` method with empty, `null` and `false` values returns `true` $this->assertTrue($this->Entity->set('keyWithEmptyValue', '')->has('keyWithEmptyValue')); $this->assertTrue($this->Entity->set('keyWithFalse', false)->has('keyWithFalse')); } /** * Test for `hasValue()` method * @uses \Tools\Entity::hasValue() * @test */ public function testHasValue(): void { $this->assertTrue($this->Entity->hasValue('code')); $this->assertFalse($this->Entity->hasValue('noExisting')); //`hasValue()` method with empty, `null` and `false` values return `false` $this->assertFalse($this->Entity->set('keyWithEmptyValue', '')->hasValue('keyWithEmptyValue')); $this->assertFalse($this->Entity->set('keyWithFalse', false)->hasValue('keyWithFalse')); } /** * Test for `__get()` and `get()` methods * @uses \Tools\Entity::__get() * @uses \Tools\Entity::get() * @test * @noinspection PhpUndefinedFieldInspection */ public function testGet(): void { $this->assertSame(200, $this->Entity->code); $this->assertSame(200, $this->Entity->get('code')); $this->assertNull($this->Entity->noExisting); $this->assertNull($this->Entity->get('noExisting')); $this->assertSame('default', $this->Entity->get('noExisting', 'default')); } /** * Test for `isEmpty()` method * @uses \Tools\Entity::isEmpty() * @test */ public function testIsEmpty(): void { $this->assertFalse($this->Entity->isEmpty('code')); $this->assertTrue($this->Entity->isEmpty('noExisting')); //`isEmpty()` method with empty, `null` and `false` values return `true` $this->assertTrue($this->Entity->set('keyWithEmptyValue', '')->isEmpty('keyWithEmptyValue')); $this->assertTrue($this->Entity->set('keyWithFalse', false)->isEmpty('keyWithFalse')); } /** * Test for `set()` method * @uses \Tools\Entity::set() * @test */ public function testSet(): void { $result = $this->Entity->set('newKey', 'newValue'); $this->assertInstanceOf(Entity::class, $result); $this->assertSame('newValue', $this->Entity->get('newKey')); $this->Entity->set(['alfa' => 'first', 'beta' => 'second']); $this->assertSame('first', $this->Entity->get('alfa')); $this->assertSame('second', $this->Entity->get('beta')); $this->assertSame('', $this->Entity->set('keyWithEmptyValue', '')->get('keyWithEmptyValue')); } /** * Test for `toArray()` method * @uses \Tools\Entity::toArray() * @test */ public function testToArray(): void { $expected = ['code' => 200, 'newKey' => 'newValue']; $result = $this->Entity->set('newKey', 'newValue')->toArray(); $this->assertSame($expected, $result); $expected += ['subEntity' => ['subKey' => 'subValue']]; $subEntity = new EntityExample(['subKey' => 'subValue']); $result = $this->Entity->set(compact('subEntity'))->toArray(); $this->assertSame($expected, $result); } /** * Test for the `ArrayAccess` interface methods * @uses \Tools\Entity::offsetExists() * @uses \Tools\Entity::offsetGet() * @uses \Tools\Entity::offsetSet() * @uses \Tools\Entity::offsetUnset() * @test */ public function testArrayAccess(): void { $this->Entity['newKey'] = 'a key'; $this->assertTrue(isset($this->Entity['newKey'])); $this->assertSame('a key', $this->Entity['newKey']); unset($this->Entity['newKey']); $this->assertFalse(isset($this->Entity['newKey'])); } }