Skip to content

Commit

Permalink
Sets the permissions to 755 by default (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Aug 6, 2018
1 parent ea3939e commit 274dba3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ permissions:

```json
{
"chmod": "0755"
"chmod": "0700"
}
```

Expand Down
2 changes: 0 additions & 2 deletions box.json.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"chmod": "0755",

"banner": [
"This file is part of the box project.",
"",
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ private static function retrieveFileMode(stdClass $raw): ?int
return intval($raw->chmod, 8);
}

return null;
return intval(0755, 8);
}

private static function retrieveMainScriptPath(stdClass $raw, string $basePath, ?array $decodedJsonContents): ?string
Expand Down
16 changes: 8 additions & 8 deletions tests/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,29 +530,29 @@ public function test_the_compression_algorithm_cannot_be_an_invalid_algorithm($c
}
}

public function test_no_file_mode_is_configured_by_default(): void
public function test_a_file_mode_is_configured_by_default(): void
{
$this->assertNull($this->config->getFileMode());
$this->assertNull($this->getNoFileConfig()->getFileMode());
$this->assertSame(493, $this->config->getFileMode());
$this->assertSame(493, $this->getNoFileConfig()->getFileMode());
}

public function test_configure_file_mode(): void
{
// Octal value provided
$this->setConfig([
'files' => [self::DEFAULT_FILE],
'chmod' => '0755',
'chmod' => '0644',
]);

$this->assertSame(0755, $this->config->getFileMode());
$this->assertSame(420, $this->config->getFileMode());

// Decimal value provided
$this->setConfig([
'files' => [self::DEFAULT_FILE],
'chmod' => '755',
'chmod' => '0644',
]);

$this->assertSame(0755, $this->config->getFileMode());
$this->assertSame(420, $this->config->getFileMode());
}

public function test_a_main_script_path_is_configured_by_default(): void
Expand Down Expand Up @@ -1593,7 +1593,7 @@ public function test_it_can_be_created_with_only_default_values(): void
new MapFile($this->tmp, []),
$this->config->getFileMapper()
);
$this->assertNull($this->config->getFileMode());
$this->assertSame(493, $this->config->getFileMode());
$this->assertSame([], $this->config->getFiles());
$this->assertSame('', $this->config->getMainScriptContents());
$this->assertSame($this->tmp.'/index.php', $this->config->getMainScriptPath());
Expand Down
15 changes: 13 additions & 2 deletions tests/Console/Command/CompileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function test_it_can_build_a_PHAR_file(): void
[
'alias' => 'alias-test.phar',
'banner' => 'custom banner',
'chmod' => '0755',
'chmod' => '0700',
'compactors' => [Php::class],
'directories' => ['a'],
'files' => ['test.php'],
Expand Down Expand Up @@ -166,7 +166,7 @@ public function test_it_can_build_a_PHAR_file(): void
? No compression
? Signing using a private key
Private key passphrase:
? Setting file permissions to 0755
? Setting file permissions to 0700
* Done.
// PHAR: 45 files (100B)
Expand Down Expand Up @@ -375,6 +375,7 @@ public function test_it_can_build_a_PHAR_without_any_configuration(): void
? Dumping the Composer autoloader
? Removing the Composer dump artefacts
? No compression
? Setting file permissions to 0755
* Done.
// PHAR: 49 files (100B)
Expand Down Expand Up @@ -1726,6 +1727,7 @@ public function test_it_can_build_a_PHAR_overwriting_an_existing_one_in_verbose_
? Skipping dumping the Composer autoloader
? Removing the Composer dump artefacts
? No compression
? Setting file permissions to 0755
* Done.
// PHAR: 1 file (100B)
Expand Down Expand Up @@ -1977,6 +1979,7 @@ public function test_it_can_build_a_PHAR_with_a_custom_banner(): void
? Skipping dumping the Composer autoloader
? Removing the Composer dump artefacts
? No compression
? Setting file permissions to 0755
* Done.
// PHAR: 1 file (100B)
Expand Down Expand Up @@ -2036,6 +2039,7 @@ public function test_it_can_build_a_PHAR_with_a_stub_file(): void
? Skipping dumping the Composer autoloader
? Removing the Composer dump artefacts
? No compression
? Setting file permissions to 0755
* Done.
// PHAR: 1 file (100B)
Expand Down Expand Up @@ -2100,6 +2104,7 @@ public function test_it_can_build_a_PHAR_with_the_default_stub_file(): void
? Skipping dumping the Composer autoloader
? Removing the Composer dump artefacts
? No compression
? Setting file permissions to 0755
* Done.
// PHAR: 2 files (100B)
Expand Down Expand Up @@ -2164,6 +2169,7 @@ public function test_it_can_build_a_PHAR_without_a_main_script(): void
? Skipping dumping the Composer autoloader
? Removing the Composer dump artefacts
? No compression
? Setting file permissions to 0755
* Done.
// PHAR: 1 file (100B)
Expand Down Expand Up @@ -2233,6 +2239,7 @@ public function test_it_can_build_an_empty_PHAR(): void
? Skipping dumping the Composer autoloader
? Removing the Composer dump artefacts
? No compression
? Setting file permissions to 0755
* Done.
// PHAR: 1 file (100B)
Expand Down Expand Up @@ -2306,6 +2313,7 @@ public function test_it_can_build_a_PHAR_with_compressed_code(): void
? Removing the Composer dump artefacts
? Compressing with the algorithm "GZ"
> Warning: the extension "zlib" will now be required to execute the PHAR
? Setting file permissions to 0755
* Done.
// PHAR: 1 file (100B)
Expand Down Expand Up @@ -2375,6 +2383,7 @@ public function test_it_can_build_a_PHAR_in_a_non_existent_directory(): void
? Skipping dumping the Composer autoloader
? Removing the Composer dump artefacts
? No compression
? Setting file permissions to 0755
* Done.
// PHAR: 1 file (100B)
Expand Down Expand Up @@ -2522,6 +2531,7 @@ public function test_it_can_build_a_PHAR_file_without_a_shebang_line(): void
? Removing the Composer dump artefacts
? Compressing with the algorithm "GZ"
> Warning: the extension "zlib" will now be required to execute the PHAR
? Setting file permissions to 0755
* Done.
// PHAR: 1 file (100B)
Expand Down Expand Up @@ -2599,6 +2609,7 @@ public function test_it_can_build_a_PHAR_with_an_output_which_does_not_have_a_PH
? Skipping dumping the Composer autoloader
? Removing the Composer dump artefacts
? No compression
? Setting file permissions to 0755
* Done.
// PHAR: 1 file (100B)
Expand Down

2 comments on commit 274dba3

@KEINOS
Copy link

@KEINOS KEINOS commented on 274dba3 Aug 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.0.0-RC.0 !!! 🎉 Congratulations!!!

@theofidry
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Please sign in to comment.