From 9fe897fd77566f12cb4cba4a169129e841044e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Bustamante?= Date: Mon, 8 Oct 2018 06:16:33 -0300 Subject: [PATCH] Set the scope indentifier when creating the scope (#38) (#39) --- src/Fractal.php | 2 +- tests/ScopeTest.php | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/ScopeTest.php diff --git a/src/Fractal.php b/src/Fractal.php index 2fd3320..cacdf14 100644 --- a/src/Fractal.php +++ b/src/Fractal.php @@ -405,7 +405,7 @@ public function createData() $this->manager->parseFieldsets($this->fieldsets); } - return $this->manager->createData($this->getResource()); + return $this->manager->createData($this->getResource(), $this->resourceName); } /** diff --git a/tests/ScopeTest.php b/tests/ScopeTest.php new file mode 100644 index 0000000..0d80bd2 --- /dev/null +++ b/tests/ScopeTest.php @@ -0,0 +1,17 @@ +fractal + ->collection($this->testBooks, new TestTransformer(), 'books') + ->parseIncludes('characters') + ->createData(); + + $this->assertEquals('books', $scope->getIdentifier()); + } +}