From a7fb72c4cabfa643d0f4d0579b442fef9ceb62d0 Mon Sep 17 00:00:00 2001 From: Brandon Date: Tue, 26 Mar 2024 08:37:38 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Update=20tests=20to=20reflect=20out?= =?UTF-8?q?put=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Unit/WordPressTest.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/Unit/WordPressTest.php b/tests/Unit/WordPressTest.php index c68c120..0b347d0 100644 --- a/tests/Unit/WordPressTest.php +++ b/tests/Unit/WordPressTest.php @@ -24,7 +24,7 @@ $compiled = $this->compile($directive); - expect($compiled)->toBe("put('p', is_a(1, 'WP_Post') ? (1)->ID : 1); ?>put('ignore_sticky_posts', true) ->put('posts_per_page', -1) ->put('post__in', collect(1) ->map(function (\$post) { return is_a(\$post, 'WP_Post') ? \$post->ID : \$post; })->all()) ->put('orderby', 'post__in'); ?>isNotEmpty() ? new WP_Query(\$posts->all()) : 1; ?>have_posts()) : \$__currentLoopData = range(1, \$query->post_count); \$__env->addLoop(\$__currentLoopData); while (\$query->have_posts()) : \$__env->incrementLoopIndices(); \$loop = \$__env->getLastLoop(); \$query->the_post(); ?>"); + expect($compiled)->toBe("put('p', is_a(1, 'WP_Post') ? (1)->ID : 1); ?>put('ignore_sticky_posts', true)->put('posts_per_page', -1)->put('post__in', collect(1)->map(fn (\$post) => is_a(\$post, 'WP_Post') ? \$post->ID : \$post)->all())->put('orderby', 'post__in');?>isNotEmpty() ? new WP_Query(\$posts->all()) : 1; ?>have_posts()) : \$__currentLoopData = range(1, \$query->post_count); \$__env->addLoop(\$__currentLoopData); while (\$query->have_posts()) : \$__env->incrementLoopIndices(); \$loop = \$__env->getLastLoop(); \$query->the_post(); ?>"); }); it('compiles correctly with post object', function () { @@ -32,7 +32,7 @@ $compiled = $this->compile($directive); - expect($compiled)->toBe("put('p', is_a(get_post(1), 'WP_Post') ? (get_post(1))->ID : get_post(1)); ?>put('ignore_sticky_posts', true) ->put('posts_per_page', -1) ->put('post__in', collect(get_post(1)) ->map(function (\$post) { return is_a(\$post, 'WP_Post') ? \$post->ID : \$post; })->all()) ->put('orderby', 'post__in'); ?>isNotEmpty() ? new WP_Query(\$posts->all()) : get_post(1); ?>have_posts()) : \$__currentLoopData = range(1, \$query->post_count); \$__env->addLoop(\$__currentLoopData); while (\$query->have_posts()) : \$__env->incrementLoopIndices(); \$loop = \$__env->getLastLoop(); \$query->the_post(); ?>"); + expect($compiled)->toBe("put('p', is_a(get_post(1), 'WP_Post') ? (get_post(1))->ID : get_post(1)); ?>put('ignore_sticky_posts', true)->put('posts_per_page', -1)->put('post__in', collect(get_post(1))->map(fn (\$post) => is_a(\$post, 'WP_Post') ? \$post->ID : \$post)->all())->put('orderby', 'post__in');?>isNotEmpty() ? new WP_Query(\$posts->all()) : get_post(1); ?>have_posts()) : \$__currentLoopData = range(1, \$query->post_count); \$__env->addLoop(\$__currentLoopData); while (\$query->have_posts()) : \$__env->incrementLoopIndices(); \$loop = \$__env->getLastLoop(); \$query->the_post(); ?>"); }); it('compiles correctly with post ID array', function () { @@ -40,7 +40,7 @@ $compiled = $this->compile($directive); - expect($compiled)->toBe("put('p', is_a([1, 2, 3], 'WP_Post') ? ([1, 2, 3])->ID : [1, 2, 3]); ?>put('ignore_sticky_posts', true) ->put('posts_per_page', -1) ->put('post__in', collect([1, 2, 3]) ->map(function (\$post) { return is_a(\$post, 'WP_Post') ? \$post->ID : \$post; })->all()) ->put('orderby', 'post__in'); ?>isNotEmpty() ? new WP_Query(\$posts->all()) : [1, 2, 3]; ?>have_posts()) : \$__currentLoopData = range(1, \$query->post_count); \$__env->addLoop(\$__currentLoopData); while (\$query->have_posts()) : \$__env->incrementLoopIndices(); \$loop = \$__env->getLastLoop(); \$query->the_post(); ?>"); + expect($compiled)->toBe("put('p', is_a([1, 2, 3], 'WP_Post') ? ([1, 2, 3])->ID : [1, 2, 3]); ?>put('ignore_sticky_posts', true)->put('posts_per_page', -1)->put('post__in', collect([1, 2, 3])->map(fn (\$post) => is_a(\$post, 'WP_Post') ? \$post->ID : \$post)->all())->put('orderby', 'post__in');?>isNotEmpty() ? new WP_Query(\$posts->all()) : [1, 2, 3]; ?>have_posts()) : \$__currentLoopData = range(1, \$query->post_count); \$__env->addLoop(\$__currentLoopData); while (\$query->have_posts()) : \$__env->incrementLoopIndices(); \$loop = \$__env->getLastLoop(); \$query->the_post(); ?>"); }); it('compiles correctly with post ID array containing object', function () { @@ -48,7 +48,7 @@ $compiled = $this->compile($directive); - expect($compiled)->toBe("put('p', is_a([1, get_post(2), 3], 'WP_Post') ? ([1, get_post(2), 3])->ID : [1, get_post(2), 3]); ?>put('ignore_sticky_posts', true) ->put('posts_per_page', -1) ->put('post__in', collect([1, get_post(2), 3]) ->map(function (\$post) { return is_a(\$post, 'WP_Post') ? \$post->ID : \$post; })->all()) ->put('orderby', 'post__in'); ?>isNotEmpty() ? new WP_Query(\$posts->all()) : [1, get_post(2), 3]; ?>have_posts()) : \$__currentLoopData = range(1, \$query->post_count); \$__env->addLoop(\$__currentLoopData); while (\$query->have_posts()) : \$__env->incrementLoopIndices(); \$loop = \$__env->getLastLoop(); \$query->the_post(); ?>"); + expect($compiled)->toBe("put('p', is_a([1, get_post(2), 3], 'WP_Post') ? ([1, get_post(2), 3])->ID : [1, get_post(2), 3]); ?>put('ignore_sticky_posts', true)->put('posts_per_page', -1)->put('post__in', collect([1, get_post(2), 3])->map(fn (\$post) => is_a(\$post, 'WP_Post') ? \$post->ID : \$post)->all())->put('orderby', 'post__in');?>isNotEmpty() ? new WP_Query(\$posts->all()) : [1, get_post(2), 3]; ?>have_posts()) : \$__currentLoopData = range(1, \$query->post_count); \$__env->addLoop(\$__currentLoopData); while (\$query->have_posts()) : \$__env->incrementLoopIndices(); \$loop = \$__env->getLastLoop(); \$query->the_post(); ?>"); }); }); @@ -76,7 +76,7 @@ $compiled = $this->compile($directive); - expect($compiled)->toBe(" 'post'], 'WP_Post') || is_numeric(['post_type' => 'post'])) : ?>put('p', is_a(['post_type' => 'post'], 'WP_Post') ? (['post_type' => 'post'])->ID : ['post_type' => 'post']); ?> 'post'])) : ?>put('ignore_sticky_posts', true) ->put('posts_per_page', -1) ->put('post__in', collect(['post_type' => 'post']) ->map(function (\$post) { return is_a(\$post, 'WP_Post') ? \$post->ID : \$post; })->all()) ->put('orderby', 'post__in'); ?>isNotEmpty() ? new WP_Query(\$posts->all()) : ['post_type' => 'post']; ?>have_posts()) : ?>"); + expect($compiled)->toBe(" 'post'], 'WP_Post') || is_numeric(['post_type' => 'post'])) : ?>put('p', is_a(['post_type' => 'post'], 'WP_Post') ? (['post_type' => 'post'])->ID : ['post_type' => 'post']); ?> 'post'])) : ?>put('ignore_sticky_posts', true)->put('posts_per_page', -1)->put('post__in', collect(['post_type' => 'post'])->map(fn (\$post) => is_a(\$post, 'WP_Post') ? \$post->ID : \$post)->all())->put('orderby', 'post__in');?>isNotEmpty() ? new WP_Query(\$posts->all()) : ['post_type' => 'post']; ?>have_posts()) : ?>"); }); }); @@ -104,7 +104,7 @@ $compiled = $this->compile($directive); - expect($compiled)->toBe(" 'post'], 'WP_Post') || is_numeric(['post_type' => 'post'])) : ?>put('p', is_a(['post_type' => 'post'], 'WP_Post') ? (['post_type' => 'post'])->ID : ['post_type' => 'post']); ?> 'post'])) : ?>put('ignore_sticky_posts', true) ->put('posts_per_page', -1) ->put('post__in', collect(['post_type' => 'post']) ->map(function (\$post) { return is_a(\$post, 'WP_Post') ? \$post->ID : \$post; })->all()) ->put('orderby', 'post__in'); ?>isNotEmpty() ? new WP_Query(\$posts->all()) : ['post_type' => 'post']; ?>have_posts()) : ?>"); + expect($compiled)->toBe(" 'post'], 'WP_Post') || is_numeric(['post_type' => 'post'])) : ?>put('p', is_a(['post_type' => 'post'], 'WP_Post') ? (['post_type' => 'post'])->ID : ['post_type' => 'post']); ?> 'post'])) : ?>put('ignore_sticky_posts', true)->put('posts_per_page', -1)->put('post__in', collect(['post_type' => 'post'])->map(fn (\$post) => is_a(\$post, 'WP_Post') ? \$post->ID : \$post)->all())->put('orderby', 'post__in');?>isNotEmpty() ? new WP_Query(\$posts->all()) : ['post_type' => 'post']; ?>have_posts()) : ?>"); }); }); @@ -536,7 +536,7 @@ $compiled = $this->compile($directive); - expect($compiled)->toBe(""); + expect($compiled)->toBe(""); }); it('compiles correctly with size', function () { @@ -544,7 +544,7 @@ $compiled = $this->compile($directive); - expect($compiled)->toBe(""); + expect($compiled)->toBe(""); }); it('compiles correctly with size and alt tag', function () { @@ -552,7 +552,7 @@ $compiled = $this->compile($directive); - expect($compiled)->toBe(" 'Alt Text']); ?>"); + expect($compiled)->toBe(" 'Alt Text']); ?>"); }); it('compiles correctly with size and options array', function () { @@ -560,7 +560,7 @@ $compiled = $this->compile($directive); - expect($compiled)->toBe(" 'Alt Text','class' => 'class']); ?>"); + expect($compiled)->toBe(" 'Alt Text','class' => 'class']); ?>"); }); it('compiles correctly as a raw URL', function () { @@ -568,7 +568,7 @@ $compiled = $this->compile($directive); - expect($compiled)->toBe(''); + expect($compiled)->toBe(''); }); it('compiles correctly using a field name', function () { @@ -576,7 +576,7 @@ $compiled = $this->compile($directive); - expect($compiled)->toBe(""); + expect($compiled)->toBe(""); }); it('compiles correctly using a field name and size', function () { @@ -584,7 +584,7 @@ $compiled = $this->compile($directive); - expect($compiled)->toBe(""); + expect($compiled)->toBe(""); }); it('compiles correctly using a field name, size and alt tag', function () { @@ -592,7 +592,7 @@ $compiled = $this->compile($directive); - expect($compiled)->toBe(" 'Alt Text']); ?>"); + expect($compiled)->toBe(" 'Alt Text']); ?>"); }); it('compiles correctly using a field name, size and options array', function () { @@ -600,7 +600,7 @@ $compiled = $this->compile($directive); - expect($compiled)->toBe(" 'Alt Text','class' => 'class']); ?>"); + expect($compiled)->toBe(" 'Alt Text','class' => 'class']); ?>"); }); });