Inheritance: use trait ScriptFUSION\StaticClass
Ejemplo n.º 1
0
 public function testDuplicateKeys()
 {
     /** @var Flatten $flatten */
     $flatten = (new Flatten(null))->setMapper(MockFactory::mockMapper(['foo' => 'foo', ['bar' => 'bar', ['bar' => 'baz']]]));
     self::assertSame(['foo' => 'foo', 'bar' => 'baz'], $flatten([]));
     $flatten->setMapper(MockFactory::mockMapper(['foo' => 'foo', ['foo' => 'bar']]));
     self::assertSame(['foo' => 'bar'], $flatten([]));
 }
Ejemplo n.º 2
0
 /**
  * Tests that a clone of the provider's options are passed to ProviderResource::fetch().
  */
 public function testFetchWithOptions()
 {
     $this->setOptions($options = \Mockery::mock(EncapsulatedOptions::class));
     $this->provider->fetch(MockFactory::mockResource($this->provider)->shouldReceive('fetch')->with($this->connector, \Mockery::on(function (EncapsulatedOptions $argument) use($options) {
         self::assertNotSame($options, $argument);
         return get_class($options) === get_class($argument);
     }))->getMock());
 }
Ejemplo n.º 3
0
 public function testNonArray()
 {
     $filter = new Filter(null);
     $filter->setMapper(MockFactory::mockMapper(null));
     self::assertNull($filter([]));
     $filter->setMapper(MockFactory::mockMapper((object) ['foo' => 'bar']));
     self::assertNull($filter([]));
 }
Ejemplo n.º 4
0
 public function testApplyCacheAdvice()
 {
     $this->porter->registerProvider($provider = \Mockery::mock(implode(',', [Provider::class, CacheToggle::class]))->shouldReceive('fetch')->andReturn(new \EmptyIterator())->shouldReceive('disableCache')->once()->shouldReceive('enableCache')->once()->getMock());
     $this->porter->import($specification = new ImportSpecification(MockFactory::mockResource($provider)));
     $this->porter->import($specification->setCacheAdvice(CacheAdvice::SHOULD_CACHE()));
 }
Ejemplo n.º 5
0
 public function testScalar()
 {
     $this->toList->setMapper(MockFactory::mockMapper('foo'));
     $this->toList(['foo']);
 }
Ejemplo n.º 6
0
 public function test()
 {
     /** @var Walk $walk */
     $walk = (new Walk(null, 'foo->bar'))->setMapper(MockFactory::mockMapper(['foo' => ['bar' => 'baz']]));
     self::assertSame('baz', $walk([]));
 }
Ejemplo n.º 7
0
 private function createSubImport($specification = null)
 {
     $this->subImport = $subImport = new SubImport($specification ?: MockFactory::mockImportSpecification());
     $subImport->setPorter($this->porter = \Mockery::mock(Porter::class)->shouldReceive('import')->andReturn(new \EmptyIterator())->byDefault()->getMock());
 }
Ejemplo n.º 8
0
 public function test()
 {
     $type = new Type(DataType::INTEGER(), \Mockery::mock(Strategy::class));
     $type->setMapper(MockFactory::mockMapper('123'));
     self::assertSame(123, $type([]));
 }
Ejemplo n.º 9
0
 public function testNullResult()
 {
     $takeFirst = new TakeFirst(null);
     $takeFirst->setMapper(MockFactory::mockMapper(null));
     self::assertNull($takeFirst([]));
 }
Ejemplo n.º 10
0
 public function testNull()
 {
     /** @var Collection $collection */
     $collection = (new Collection(null, null))->setMapper(MockFactory::mockMapper(null));
     self::assertNull($collection([]));
 }
Ejemplo n.º 11
0
 public function test()
 {
     /** @var Unique $unique */
     $unique = (new Unique(null))->setMapper(MockFactory::mockMapper(['foo' => 'bar', 'baz' => 'bar']));
     self::assertSame(['foo' => 'bar'], $unique([]));
 }