KamranAhmed\Smasher\PathTest::testCanCreateItemsAndGetDetails PHP Method

testCanCreateItemsAndGetDetails() public method

public testCanCreateItemsAndGetDetails ( $toCreate, $detail )
    public function testCanCreateItemsAndGetDetails($toCreate, $detail)
    {
        $path = new Path($toCreate);
        $path->createItem($detail);
        // Check if file was created
        $this->assertFileExists($toCreate);
        $detail = $path->getDetail();
        // Check if the detail has everything that we need
        $this->assertArrayHasKey('@name', $detail);
        $this->assertArrayHasKey('@path', $detail);
        $this->assertArrayHasKey('@type', $detail);
        $this->assertArrayHasKey('@size', $detail);
        $this->assertArrayHasKey('@mode', $detail);
        $this->assertArrayHasKey('@owner', $detail);
        $this->assertArrayHasKey('@last_modified', $detail);
        $this->assertArrayHasKey('@group', $detail);
        // Verifying the get methods
        $this->assertEquals($detail['@name'], $path->getName());
        $this->assertEquals($detail['@type'], $path->getType());
        $this->assertInternalType('int', $path->getSize());
        $this->assertRegexp('/\\d{4}/', $path->getMode());
        $this->assertInternalType('array', $path->getOwner());
        $this->assertInternalType('string', $path->getLastModified());
        $this->assertInternalType('array', $path->getGroup());
        $this->assertNotEmpty('string', $path->getRealPath());
        $type = $path->getType();
        if ($type === 'file') {
            $content = $path->getFileContent();
            $this->assertEquals($detail['@content'], $content);
        }
        if ($type == 'dir') {
            rmdir($toCreate);
        } elseif ($type == 'file' || $type == 'link') {
            unlink($toCreate);
        }
    }