Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@
"type": "path",
"url": "./packages/*"
}
]
],
"minimum-stability": "dev",
"prefer-stable": true
}
33 changes: 16 additions & 17 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/asset-tools/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@
"type": "path",
"url": "../*"
}
]
],
"minimum-stability": "dev",
"prefer-stable": true
}
4 changes: 3 additions & 1 deletion packages/autoloader/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
},
"extra": {
"class": "Automattic\\Jetpack\\Autoloader\\CustomAutoloaderPlugin"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
5 changes: 3 additions & 2 deletions packages/connection/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"description": "Everything needed to connect to the Jetpack infrastructure",
"type": "library",
"license": "GPL-2.0-or-later",
"version": "1.0.0",
"require": {
"automattic/jetpack-constants": "@dev",
"automattic/jetpack-options": "@dev"
Expand All @@ -28,5 +27,7 @@
"type": "path",
"url": "../*"
}
]
],
"minimum-stability": "dev",
"prefer-stable": true
}
4 changes: 3 additions & 1 deletion packages/constants/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@
"@composer install",
"./vendor/phpunit/phpunit/phpunit --colors=always"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
16 changes: 14 additions & 2 deletions packages/jitm/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
"license": "GPL-2.0-or-later",
"require": {
"automattic/jetpack-asset-tools": "@dev",
"automattic/jetpack-connection": "^1.0",
"automattic/jetpack-connection": "@dev",
"automattic/jetpack-logo": "@dev",
"automattic/jetpack-constants": "@dev"
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5",
"php-mock/php-mock": "^2.1"
},
"autoload": {
"psr-4": {
"Automattic\\Jetpack\\JITM\\": "src/"
Expand All @@ -19,5 +23,13 @@
"type": "path",
"url": "../*"
}
]
],
"scripts": {
"phpunit": [
"@composer install",
"./vendor/phpunit/phpunit/phpunit --colors=always"
]
},
"minimum-stability": "dev",
"prefer-stable": true
}
7 changes: 7 additions & 0 deletions packages/jitm/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<phpunit bootstrap="tests/php/bootstrap.php" backupGlobals="false" colors="true">
<testsuites>
<testsuite name="main">
<directory prefix="test" suffix=".php">tests/php</directory>
</testsuite>
</testsuites>
</phpunit>
3 changes: 3 additions & 0 deletions packages/jitm/tests/php/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require_once __DIR__ . '/../../vendor/autoload.php';
67 changes: 67 additions & 0 deletions packages/jitm/tests/php/test_Manager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

namespace Automattic\Jetpack\JITM;

use Automattic\Jetpack\JITM\Manager as Jetpack_JITM;
use phpmock\functions\FunctionProvider;
use phpmock\Mock;
use phpmock\MockBuilder;
use PHPUnit\Framework\TestCase;

class Test_Jetpack_JITM extends TestCase {
public function setUp() {
$builder = new MockBuilder();
$builder->setNamespace( __NAMESPACE__ )
->setName( 'add_action' )
->setFunction( function() {} );
$builder->build()->enable();
}

public function tearDown() {
Mock::disableAll();
}

public function test_jitm_disabled_by_filter() {
$this->mock_filters( array(
array( 'jetpack_just_in_time_msgs', false, false ),
) );

$this->assertFalse( Jetpack_JITM::init() );

$this->clear_mock_filters();
}

public function test_jitm_enabled_by_default() {
$this->mock_filters( array(
array( 'jetpack_just_in_time_msgs', false, true ),
) );

$this->assertTrue( ! ! Jetpack_JITM::init() );

$this->clear_mock_filters();
}

protected function mock_filters( $filters ) {
$this->mocked_filters = $filters;
$builder = new MockBuilder();
$builder->setNamespace( __NAMESPACE__ )
->setName( 'apply_filters' )
->setFunction(
function() {
$current_args = func_get_args();
foreach ( $this->mocked_filters as $filter ) {
if ( array_slice( $filter, 0, -1 ) === $current_args ) {
return array_pop( $filter );
}
}
}
);
$this->apply_filters_mock = $builder->build();
$this->apply_filters_mock->enable();
}

protected function clear_mock_filters() {
$this->apply_filters_mock->disable();
unset( $this->mocked_filters );
}
}
4 changes: 3 additions & 1 deletion packages/logo/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@
"@composer install",
"./vendor/phpunit/phpunit/phpunit --colors=always"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
4 changes: 3 additions & 1 deletion packages/options/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@
"type": "path",
"url": "../*"
}
]
],
"minimum-stability": "dev",
"prefer-stable": true
}
3 changes: 0 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@
<testsuite name="idc">
<file>tests/php/test_class.jetpack-idc.php</file>
</testsuite>
<testsuite name="jitm">
<file>tests/php/test_class.jetpack-jitm.php</file>
</testsuite>
<testsuite name="affiliate">
<file>tests/php/test_class.jetpack-affiliate.php</file>
</testsuite>
Expand Down
14 changes: 0 additions & 14 deletions tests/php/test_class.jetpack-jitm.php

This file was deleted.