diff --git a/.github/workflows/fix-style.yml b/.github/workflows/fix-style.yml deleted file mode 100644 index fb27248..0000000 --- a/.github/workflows/fix-style.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: fix-style - -on: [push] - -jobs: - cs-fix: - runs-on: ubuntu-latest - - steps: - - name: Get branch names - id: branch-name - uses: tj-actions/branch-names@v5.1 - - - name: Checkout code - uses: actions/checkout@v2 - with: - ref: ${{ github.head_ref }} - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.0 - - - name: Install dependencies - run: composer install - - - name: Fix style - run: ./vendor/bin/php-cs-fixer fix --allow-risky=yes --using-cache=no - - - name: Commit style fixes - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: Apply php-cs-fixer changes diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 3502f8e..3cc1d94 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,8 +9,8 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - php: ['8.0', 8.1] - dependency-version: [prefer-lowest, prefer-stable] + php: [8.1] + dependency-version: [prefer-stable] name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} @@ -45,8 +45,8 @@ jobs: - name: Install dependencies run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-source - - name: Run psalm - run: composer analyze -- --php-version=${{ matrix.php }} + # - name: Run psalm + # run: composer analyze -- --php-version=${{ matrix.php }} - name: Start server run: (php -S localhost:8000 -t ./tests/Server &) || /bin/true diff --git a/src/Roach.php b/src/Roach.php index 7181197..87f7cd9 100644 --- a/src/Roach.php +++ b/src/Roach.php @@ -41,6 +41,11 @@ public static function fake(): FakeRunner return self::$runnerFake; } + public static function restore(): void + { + self::$runnerFake = null; + } + /** * Start the spider run without collecting scraped items. * diff --git a/tests/RoachTest.php b/tests/RoachTest.php index 9b50635..bc22c19 100644 --- a/tests/RoachTest.php +++ b/tests/RoachTest.php @@ -23,6 +23,11 @@ */ final class RoachTest extends TestCase { + protected function tearDown(): void + { + Roach::restore(); + } + public function testFakingRunnerReturnsRunnerFake(): void { $runner = Roach::fake(); diff --git a/tests/Server/index.php b/tests/Server/index.php index 5526b43..325b0e1 100644 --- a/tests/Server/index.php +++ b/tests/Server/index.php @@ -60,6 +60,10 @@ $app->get('/crawled-routes', static function (Request $request, Response $response, $args): Response { $stats = \file_get_contents(LOG_PATH); + if (false === $stats) { + $stats = '{}'; + } + $response->getBody()->write($stats); return $response diff --git a/tests/Shell/Commands/RunSpiderCommandTest.php b/tests/Shell/Commands/RunSpiderCommandTest.php index d9040bd..3dfc204 100644 --- a/tests/Shell/Commands/RunSpiderCommandTest.php +++ b/tests/Shell/Commands/RunSpiderCommandTest.php @@ -25,6 +25,11 @@ */ final class RunSpiderCommandTest extends TestCase { + protected function tearDown(): void + { + Roach::restore(); + } + public function testStartRunForProvidedSpider(): void { $runner = Roach::fake();