PHP Classes

File: test/FetchTest.php

Recommend this page to a friend!
  Classes of Scott Arciszewski  >  Certainty  >  test/FetchTest.php  >  Download  
File: test/FetchTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Certainty
Manage SSL certificate authority file used by PHP
Author: By
Last change:
Date: 3 years ago
Size: 1,594 bytes
 

Contents

Class file image Download
<?php
namespace ParagonIE\Certainty\Tests;


use
ParagonIE\Certainty\Bundle;
use
ParagonIE\Certainty\Fetch;
use
PHPUnit\Framework\TestCase;

class
FetchTest extends TestCase
{
   
/** @var string */
   
protected $root;

    public function
setUp()
    {
       
$this->root = __DIR__ . '/static/';
    }

   
/**
     * @covers Fetch
     */
   
public function testEmptyDir()
    {
        try {
            (new
Fetch($this->root . 'empty-dir'))->getAllBundles();
           
$this->fail('Expected an exception.');
        } catch (\
Exception $ex) {
           
$this->assertSame(
               
'ca-certs.json not found in data directory.',
               
$ex->getMessage()
            );
        }
    }

   
/**
     * @covers Fetch
     */
   
public function testEmptyJson()
    {
       
$this->assertSame(
            [],
            (new
Fetch($this->root . 'data-empty'))->getAllBundles()
        );
    }

   
/**
     * @covers Fetch
     */
   
public function testInvalid()
    {
        try {
            (new
Fetch($this->root . 'data-invalid'))->getLatestBundle();
           
$this->fail('Expected an exception.');
        } catch (\
Exception $ex) {
           
$this->assertSame(
               
'No valid bundles were found in the data directory.',
               
$ex->getMessage()
            );
        }
    }

   
/**
     *
     */
   
public function testLiveDataDir()
    {
       
$this->assertInstanceOf(
           
Bundle::class,
            (new
Fetch())->getLatestBundle(),
           
'The live data directory has no valid signatures.'
       
);
    }
}

For more information send a message to info at phpclasses dot org.