コード例 #1
0
 public function __construct()
 {
     // the exceptions that our library throws
     $ourExceptions = ['BadAssurance::newFromInputParameter' => [BadAssurance::class, 'newFromInputParameter'], 'BadAssurance::newFromVar' => [BadAssurance::class, 'newFromVar'], 'BadAssuranceArgs::newFromInputParameter' => [BadAssuranceArgs::class, 'newFromInputParameter'], 'BadAssuranceArgs::newFromVar' => [BadAssuranceArgs::class, 'newFromVar'], 'BadAssurancesList::newFromInputParameter' => [BadAssurancesList::class, 'newFromInputParameter'], 'BadAssurancesList::newFromVar' => [BadAssurancesList::class, 'newFromVar'], 'EmptyAssurancesList::newFromInputParameter' => [EmptyAssurancesList::class, 'newFromInputParameter'], 'EmptyAssurancesList::newFromVar' => [EmptyAssurancesList::class, 'newFromVar'], 'BadCallable::newFromInputParameter' => [BadCallable::class, 'newFromInputParameter'], 'BadCallable::newFromVar' => [BadCallable::class, 'newFromVar'], 'BadCheck::newFromInputParameter' => [BadCheck::class, 'newFromInputParameter'], 'BadCheck::newFromVar' => [BadCheck::class, 'newFromVar'], 'BadCheckArgs::newFromInputParameter' => [BadCheckArgs::class, 'newFromInputParameter'], 'BadCheckArgs::newFromVar' => [BadCheckArgs::class, 'newFromVar'], 'BadChecksList::newFromInputParameter' => [BadChecksList::class, 'newFromInputParameter'], 'BadChecksList::newFromVar' => [BadChecksList::class, 'newFromVar'], 'EmptyChecksList::newFromInputParameter' => [EmptyChecksList::class, 'newFromInputParameter'], 'EmptyChecksList::newFromVar' => [EmptyChecksList::class, 'newFromVar'], 'BadRequirement::newFromInputParameter' => [BadRequirement::class, 'newFromInputParameter'], 'BadRequirement::newFromVar' => [BadRequirement::class, 'newFromVar'], 'BadRequirementArgs::newFromInputParameter' => [BadRequirementArgs::class, 'newFromInputParameter'], 'BadRequirementArgs::newFromVar' => [BadRequirementArgs::class, 'newFromVar'], 'BadRequirements::newFromInputParameter' => [BadRequirements::class, 'newFromInputParameter'], 'BadRequirements::newFromVar' => [BadRequirements::class, 'newFromVar'], 'EmptyRequirementsList::newFromInputParameter' => [EmptyRequirementsList::class, 'newFromInputParameter'], 'EmptyRequirementsList::newFromVar' => [EmptyRequirementsList::class, 'newFromVar'], 'UnreachableCodeExecuted::newAlert' => [UnreachableCodeExecuted::class, 'newAlert'], 'UnsupportedType::newFromInputParameter' => [UnsupportedType::class, 'newFromInputParameter'], 'UnsupportedType::newFromVar' => [UnsupportedType::class, 'newFromVar'], 'UnsupportedValue::newFromInputParameter' => [UnsupportedValue::class, 'newFromInputParameter'], 'UnsupportedValue::newFromVar' => [UnsupportedValue::class, 'newFromVar']];
     // build it
     parent::__construct($ourExceptions);
 }
コード例 #2
0
 public function __construct()
 {
     // the exceptions that our library throws
     $ourExceptions = ['ContractFailed::newFromVar' => [ContractFailed::class, 'newFromVar']];
     // build it
     parent::__construct($ourExceptions);
 }
コード例 #3
0
 public function __construct()
 {
     // all of the exceptions that our library can create, and the means
     // to create them
     $ourExceptions = ['ContainerIsReadOnly::newFromInputParameter' => [ContainerIsReadOnly::class, 'newFromInputParameter'], 'ContainerIsReadOnly::newFromVar' => [ContainerIsReadOnly::class, 'newFromVar'], 'NoSuchFactory::newFromInputParameter' => [NoSuchFactory::class, 'newFromInputParameter'], 'NoSuchFactory::newFromVar' => [NoSuchFactory::class, 'newFromVar'], 'NotAFactory::newFromInputParameter' => [NotAFactory::class, 'newFromInputParameter'], 'NotAFactory::newFromVar' => [NotAFactory::class, 'newFromVar'], 'NotAListOfFactories::newFromInputParameter' => [NotAListOfFactories::class, 'newFromInputParameter'], 'NotAListOfFactories::newFromVar' => [NotAListOfFactories::class, 'newFromVar']];
     // special case - we have to pass $this into our parent constructor
     // to prevent it attempting to create a new instance of this class :)
     parent::__construct($ourExceptions, $this);
 }
 /**
  * @covers ::apply
  * @covers ::to
  */
 public function test_does_not_throw_exception_when_container_is_read_write()
 {
     // ----------------------------------------------------------------
     // setup your test
     $container = new FactoryListContainer(["hello" => [ContainerIsReadOnly::class, 'newFromVar']]);
     $container->setReadWrite();
     // ----------------------------------------------------------------
     // perform the change
     RequireWriteableContainer::apply()->to($container);
     // ----------------------------------------------------------------
     // test the results
     $this->assertTrue($container->isReadWrite());
 }
コード例 #5
0
 /**
  * @covers ::__construct
  * @covers ::setReadWrite
  * @covers ::isReadOnly
  * @covers ::isReadWrite
  * @covers ::requireReadWrite
  */
 public function testCanPutIntoReadWriteMode()
 {
     // ----------------------------------------------------------------
     // setup your test
     $factories = ['dummy' => new FactoryListContainerTest_Builder()];
     $unit = new FactoryListContainer($factories);
     // ----------------------------------------------------------------
     // perform the change
     $unit->setReadWrite();
     // ----------------------------------------------------------------
     // test the results
     $this->assertFalse($unit->isReadOnly());
     $this->assertTrue($unit->isReadWrite());
 }